home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / modules / libimg / public / il_util.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  5.9 KB  |  134 lines

  1. /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. /* -*- Mode: C; tab-width: 4 -*-
  20.  *  il_util.h Colormap and colorspace utilities.
  21.  *             
  22.  *   $Id: il_util.h,v 3.1 1998/03/28 03:34:57 ltabb Exp $
  23.  */
  24.  
  25.  
  26. #ifndef _IL_UTIL_H
  27. #define _IL_UTIL_H
  28.  
  29. #include "ni_pixmp.h"  /* Cross-platform pixmap structure. */
  30. #include "il_types.h"
  31.  
  32. XP_BEGIN_PROTOS
  33.  
  34. /************************* Colormap utilities ********************************/
  35.  
  36. /* Create a new color map consisting of a given set of reserved colors, and
  37.    a color cube.  num_colors represents the requested size of the colormap,
  38.    including the reserved colors.  The actual number of colors in the colormap
  39.    could be less depending on the color cube that is allocated.
  40.  
  41.    The Image Library will only make use of entries in the color cube.  This
  42.    function represents the current state of affairs, and it will eventually
  43.    be replaced when the Image Library has the capability to dither to an
  44.    arbitrary palette. */
  45. extern IL_ColorMap *
  46. IL_NewCubeColorMap(IL_RGB *reserved_colors, uint16 num_reserved_colors,
  47.                    uint16 num_colors);
  48.  
  49. /* Create an optimal fixed palette of the specified size, starting with
  50.    the given set of reserved colors.
  51.    XXX - This will not be implemented initially. */
  52. extern IL_ColorMap *
  53. IL_NewOptimalColorMap(IL_RGB *reserved_colors, uint16 num_reserved_colors,
  54.                       uint16 num_colors);
  55.  
  56. /* Create an empty colormap.  The caller is responsible for filling in the
  57.    colormap entries. */
  58. extern IL_ColorMap *
  59. IL_NewColorMap(void);
  60.  
  61. /* Append the specified color to an existing IL_ColorMap, returning TRUE if
  62.    successful.  The position of the new color in the IL_ColorMap's map array
  63.    is returned in new_color->index.  The caller should also update the
  64.    corresponding entry in the IL_ColorMap's index array,
  65.    cmap->index[new_color->index], if the actual colormap indices do not
  66.    correspond to the order of the entries in the map array.
  67.  
  68.    Note: For now, at least, this function does not cause the Image Library's
  69.    lookup table to be altered, so the Image Library will continue to dither
  70.    to the old colormap.  Therefore, the current purpose of this function is
  71.    to add colors (such as a background color for transparent images) which
  72.    are not a part of the Image Library's color cube. */
  73. extern int
  74. IL_AddColorToColorMap(IL_ColorMap *cmap, IL_IRGB *new_color);
  75.  
  76. /* Free all memory associated with a given colormap.
  77.    Note: This should *not* be used to destroy a colormap once it has been
  78.    passed into IL_CreatePseudoColorSpace.  Use IL_ReleaseColorSpace instead. */
  79. extern void
  80. IL_DestroyColorMap (IL_ColorMap *cmap);
  81.  
  82. /* Reorder the entries in a colormap.  new_order is an array mapping the old
  83.    indices to the new indices.
  84.    XXX Is this really necessary? */
  85. extern void
  86. IL_ReorderColorMap(IL_ColorMap *cmap, uint16 *new_order);
  87.  
  88.  
  89. /************************** Colorspace utilities *****************************/
  90.  
  91. /* Create a new True-colorspace of the dimensions specified by IL_RGBBits and
  92.    set the reference count to 1.  The pixmap_depth is the sum of the bits
  93.    assigned to the three color channels, plus any additional allowance that
  94.    might be necessary, e.g. for an alpha channel, or for alignment.  Note: the
  95.    contents of the IL_RGBBits structure will be copied, so they need not be
  96.    preserved after the call to IL_CreateTrueColorSpace. */
  97. extern IL_ColorSpace *
  98. IL_CreateTrueColorSpace(IL_RGBBits *rgb, uint8 pixmap_depth);
  99.  
  100. /* Create a new Pseudo-colorspace using the given colormap and set the
  101.    reference count to 1.  The index_depth is the bit-depth of the colormap
  102.    indices (typically 8), while the pixmap_depth is the index_depth plus any
  103.    additional allowance that might be necessary e.g. for an alpha channel, or
  104.    for alignment.  Note: IL_ColorMaps passed into IL_CreatePseudoColorSpace
  105.    become a part of the IL_ColorSpace structure.  The IL_ColorMap pointer is
  106.    invalid after the the call to IL_CreatePseudoColorSpace, so it should
  107.    neither be accessed, nor destroyed using IL_DestroyColorMap.  Access to
  108.    the colormap, *is* available through the colormap member of the
  109.    IL_ColorSpace.  Memory associated with the colormap will be freed by
  110.    IL_ReleaseColorSpace when the reference count reaches zero. */
  111. extern IL_ColorSpace *
  112. IL_CreatePseudoColorSpace(IL_ColorMap *cmap, uint8 index_depth,
  113.                           uint8 pixmap_depth);
  114.  
  115. /* Create a new Greyscale-colorspace of depth specified by index_depth and
  116.    set the reference count to 1.  The pixmap_depth is the index_depth plus
  117.    any additional allowance that might be necessary e.g. for an alpha channel,
  118.    or for alignment. */
  119. extern IL_ColorSpace *
  120. IL_CreateGreyScaleColorSpace(uint8 index_depth, uint8 pixmap_depth);
  121.  
  122. /* Decrements the reference count for an IL_ColorSpace.  If the reference
  123.    count reaches zero, all memory associated with the colorspace (including
  124.    any colormap associated memory) will be freed. */
  125. extern void
  126. IL_ReleaseColorSpace(IL_ColorSpace *color_space);
  127.  
  128. /* Increment the reference count for an IL_ColorSpace. */
  129. extern void
  130. IL_AddRefToColorSpace(IL_ColorSpace *color_space);
  131.  
  132. XP_END_PROTOS
  133. #endif /* _IL_UTIL_H */
  134.