home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / modules / libimg / public / ni_pixmp.h < prev   
Encoding:
C/C++ Source or Header  |  1998-04-08  |  6.7 KB  |  186 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.  *  ni_pixmp.h --- Cross platform pixmap data structure.
  20.  *  $Id: ni_pixmp.h,v 3.1 1998/03/28 03:34:58 ltabb Exp $
  21.  */
  22.  
  23.  
  24. #ifndef _NI_PIXMAP_H
  25. #define _NI_PIXMAP_H
  26. #include "xp_mem.h"
  27. /************** Colorimetry/Gamma Correction Information. ********************
  28. * This doesn't need to be implemented initially, but it's here for future    * 
  29. * usage.                                                                     */
  30.  
  31. /* The chrominance part of a CIE xyY color specification */
  32. typedef struct CIEchroma {
  33.     float x;
  34.     float y;
  35. } CIEchroma;
  36.  
  37.  
  38. /* Define a device-independent color space using the white point and
  39.    primary colors of a gamut formed by RGB tristimulus values. */
  40. typedef struct NI_RGBColorSpace {
  41.     CIEchroma white_point;
  42.     CIEchroma primary_red;
  43.     CIEchroma primary_green;
  44.     CIEchroma primary_blue;
  45. } NI_RGBColorSpace;
  46.  
  47.  
  48. typedef struct NI_ColorSpec {
  49.     double gamma;
  50.     NI_RGBColorSpace rgb_colorspace;
  51. } NI_ColorSpec;
  52.  
  53.  
  54. /***************** Colorspace and Colormap Information ***********************/
  55.  
  56. /* Possible colorspace types. */
  57. typedef enum _NI_ColorSpaceType
  58. {
  59.     NI_TrueColor   = 0x01,         /* RGB data.       */
  60.     NI_PseudoColor = 0x02,         /* Indexed data.   */
  61.     NI_GreyScale   = 0x04          /* Greyscale data. */
  62. } NI_ColorSpaceType;
  63.  
  64.  
  65. /* RGB bit allocation and offsets. */
  66. typedef struct _NI_RGBBits {
  67.     uint8 red_bits;             /* Number of bits assigned to red channel. */
  68.     uint8 red_shift;            /* Offset for red channel bits. */
  69.     uint8 green_bits;           /* Number of bits assigned to green channel. */
  70.     uint8 green_shift;          /* Offset for green channel bits. */
  71.     uint8 blue_bits;            /* Number of bits assigned to blue channel. */
  72.     uint8 blue_shift;           /* Offset for blue channel bits. */
  73. } NI_RGBBits;
  74.  
  75.  
  76. /* An indexed RGB triplet. */
  77. typedef struct _NI_IRGB {
  78.     uint8 index;
  79.     uint8 red, green, blue;
  80. } NI_IRGB;
  81.  
  82.  
  83. /* A RGB triplet representing a single pixel in the image's colormap
  84.    (if present.) */
  85. typedef struct _NI_RGB
  86. {
  87.     uint8 red, green, blue, pad; /* Windows requires the fourth byte &
  88.                                     many compilers pad it anyway. */
  89.     uint16 hist_count;           /* Histogram frequency count. */
  90. } NI_RGB;
  91.  
  92.  
  93. /* Colormap information. */
  94. typedef struct _NI_ColorMap {
  95.     int32 num_colors;           /* Number of colors in the colormap.
  96.                                    A negative value can be used to denote a
  97.                                    possibly non-unique set. */
  98.     NI_RGB *map;                /* Colormap colors. */
  99.     uint8 *index;               /* NULL, if map is in index order.  Otherwise
  100.                                    specifies the indices of the map entries. */
  101.     void *table;                /* Lookup table for this colormap.  Private to
  102.                                    the Image Library. */
  103. } NI_ColorMap;
  104.  
  105.  
  106. /* Special purpose flags for OS-specific problems. */
  107. typedef enum {
  108.     WIN95_ROUNDING = 0x01       /* Windows 95 color quantization bug. */
  109. } NI_OSFlags;
  110.  
  111.  
  112. /* Colorspace information. */
  113. typedef struct _NI_ColorSpace {
  114.     NI_ColorSpaceType type;     /* NI_Truecolor, NI_Pseudocolor or
  115.                                    NI_Greyscale. */
  116.  
  117.     /* The dimensions of the colorspace. */
  118.     union {
  119.         NI_RGBBits rgb;         /* For TrueColor. */
  120.         uint8 index_depth;      /* For PseudoColor and GreyScale. */
  121.     } bit_alloc;                /* Allocation of bits. */
  122.     uint8 pixmap_depth;         /* Total bit depth (including alpha or pad.) */
  123.  
  124.     /* Colormap information.  This may be used for one of three purposes:
  125.        - If the colorspace belongs to a PseudoColor source image, then the
  126.          colormap represents the mapping from the source image indices to
  127.          the corresponding RGB components.
  128.        - If the colorspace belongs to a TrueColor source image, then a
  129.          colormap may be provided as a suggested palette for displaying the
  130.          image on PseudoColor displays.
  131.        - If the colorspace belongs to a PseudoColor Display Front End or a
  132.          destination image for a PseudoColor Display Front End, then the
  133.          colormap represents the mapping from the display's palette indices
  134.          to the corresponding RGB components. */
  135.     NI_ColorMap cmap;
  136.  
  137.     /* Image Library private data for this colorspace. */
  138.     void *private_data;
  139.  
  140.     /* Special purpose flags for OS-specific problems. */
  141.     uint8 os_flags;             /* Flags are of type NI_OSFlags. */
  142.  
  143.     /* Reference counter. */
  144.     uint32 ref_count;
  145. } NI_ColorSpace;
  146.  
  147.  
  148. /* A pixmap's header information. */
  149. typedef struct _NI_PixmapHeader
  150. {
  151.     /* Size. */
  152.     uint32 width;               /* Width. */
  153.     uint32 height;              /* Height. */
  154.     uint32 widthBytes;          /* width * depth / 8.  May be aligned for
  155.                                    optimizations. */
  156.     
  157.     /* Colorspace. */
  158.     NI_ColorSpace *color_space; /* Colorspace and colormap information. */
  159.  
  160.     /* Transparency. */
  161.     NI_IRGB *transparent_pixel; /* The image's transparent pixel
  162.                                    (if present.) */
  163.     uint8 alpha_bits;           /* Number of bits assigned to alpha channel. */
  164.     uint8 alpha_shift;          /* Offset for alpha channel bits. */
  165.     int32 is_interleaved_alpha; /* Is alpha channel interleaved with
  166.                                    image data? */
  167.  
  168.     /* Gamma/color correction. */
  169.     NI_ColorSpec color_spec;
  170. } NI_PixmapHeader;
  171.  
  172.  
  173. /* A pixmap. */
  174. typedef struct _NI_Pixmap
  175. {
  176.     NI_PixmapHeader header;     /* Header information. */
  177.     void XP_HUGE *bits;         /* Pointer to the bits. */
  178.     void *client_data;          /* Pixmap-specific data opaque to the Image
  179.                                    Library e.g. display front-ends which
  180.                                    support scaling may use this to store the
  181.                                    actual size at which the image is to be
  182.                                    displayed. */
  183. } NI_Pixmap;
  184.  
  185. #endif /* _NI_PIXMAP_H */
  186.