home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / modules / libimg / src / il_utilp.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  3.0 KB  |  79 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_utilp.h Colormap and colorspace utilities - types and definitions
  21.  *             private to Image Library.            
  22.  *
  23.  *   $Id: il_utilp.h,v 3.1 1998/03/28 03:35:02 ltabb Exp $
  24.  */
  25.  
  26.  
  27. /************************* Colormap utilities ********************************/
  28.  
  29. /* Parameters for building a color cube and its associated lookup table. */
  30. #define LOOKUP_TABLE_SIZE  32768
  31. #define LOOKUP_TABLE_RED   32
  32. #define LOOKUP_TABLE_GREEN 32
  33. #define LOOKUP_TABLE_BLUE  32
  34. #define CUBE_MAX_SIZE      256
  35.  
  36. /* Macro to convert 8-bit/channel RGB data into an 8-bit colormap index. */
  37. #define COLORMAP_INDEX(lookup_table, red, green, blue)     \
  38.         lookup_table[LOOKUP_TABLE_INDEX(red, green, blue)]
  39.  
  40. /* Macro to convert 8-bit/channel RGB data into a 16-bit lookup table index.
  41.    The lookup table value is the index to the colormap. */
  42. #define LOOKUP_TABLE_INDEX(red, green, blue) \
  43.         ((USE_5_BITS(red) << 10) |           \
  44.         (USE_5_BITS(green) << 5) |           \
  45.         USE_5_BITS(blue))
  46.  
  47. /* Take the 5 most significant bits of an 8-bit value. */
  48. #define USE_5_BITS(x) ((x) >> 3)
  49.  
  50. /* Scaling macro for creating color cubes. */
  51. #define CUBE_SCALE(val, double_new_size_minus1, old_size_minus1, \
  52.                    double_old_size_minus1)                       \
  53.         ((val) * (double_new_size_minus1) + (old_size_minus1)) / \
  54.         (double_old_size_minus1)
  55.  
  56.  
  57. /************************** Colorspace utilities *****************************/
  58.  
  59. /* Image Library private part of an IL_ColorSpace structure. */
  60. typedef struct il_ColorSpaceData {
  61.     /* RGB24 to RGBN depth conversion maps.  Each of these maps take an
  62.        8-bit input for a color channel and converts it into that channel's
  63.        contribution to a depth N pixmap e.g. for a 24 to 16-bit color
  64.        conversion, the output pixel is given by
  65.  
  66.        uint8 red, green, blue;
  67.        uint16 output_pixel;
  68.        output_pixel = r8torgbn[red] + g8torgbn[green] + b8torgbn[blue];
  69.  
  70.        Depth conversion maps are created for the following destination image
  71.        pixmap depths: N = 8, 16 and 32.  The type of the array elements is a
  72.        uintN. */
  73.     void *r8torgbn;
  74.     void *g8torgbn;
  75.     void *b8torgbn;
  76. } il_ColorSpaceData;
  77.  
  78.  
  79.