home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / g / gs252src.zip / GS252 / GXDEVMEM.H < prev    next >
C/C++ Source or Header  |  1992-09-07  |  4KB  |  102 lines

  1. /* Copyright (C) 1989, 1991, 1992 Aladdin Enterprises.  All rights reserved.
  2.    Distributed by Free Software Foundation, Inc.
  3.  
  4. This file is part of Ghostscript.
  5.  
  6. Ghostscript is distributed in the hope that it will be useful, but
  7. WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  8. to anyone for the consequences of using it or for whether it serves any
  9. particular purpose or works at all, unless he says so in writing.  Refer
  10. to the Ghostscript General Public License for full details.
  11.  
  12. Everyone is granted permission to copy, modify and redistribute
  13. Ghostscript, but only under the conditions described in the Ghostscript
  14. General Public License.  A copy of this license is supposed to have been
  15. given to you along with Ghostscript so you can know your rights and
  16. responsibilities.  It should be in a file named COPYING.  Among other
  17. things, the copyright notice and this notice must be preserved on all
  18. copies.  */
  19.  
  20. /* gxdevmem.h */
  21. /* "Memory" device structure for Ghostscript library */
  22. /* Requires gxdevice.h */
  23.  
  24. /*
  25.  * A 'memory' device is essentially a stored bitmap.
  26.  * There are several different kinds: 1-bit black and white,
  27.  * 2-, 4-, and 8-bit mapped color, and 16-, 24-, and 32-bit true color.
  28.  * (16-bit uses 5/6/5 bits per color.  24- and 32-bit are equivalent:
  29.  * 24-bit takes less space, but is slower.)  All use the same structure,
  30.  * since it's so awkward to get the effect of subclasses in C.
  31.  *
  32.  * On little-endian machines, the bytes can be stored in either order.
  33.  * Little-endian order is the default, since this allows efficient
  34.  * updating; big-endian is required if the bits will be used as the
  35.  * source for a rendering operation (e.g., in the character cache).
  36.  * We provide an operation to normalize the byte order, and we trust the
  37.  * client not to do any rendering operations if the byte order is
  38.  * reversed.
  39.  */
  40. typedef struct gx_device_memory_s gx_device_memory;
  41. struct gx_device_memory_s {
  42.     gx_device_common;        /* (see gxdevice.h) */
  43.     gs_matrix initial_matrix;    /* the initial transformation */
  44.     uint raster;            /* bytes per scan line, */
  45.                     /* filled in by 'open' */
  46.     byte *base;
  47.     byte **line_ptrs;        /* scan line pointers */
  48.     int bytes_le;            /* chunk size (2 bytes) if */
  49.                     /* bytes are stored in */
  50.                     /* little-endian order, else 0 */
  51.     /* Following is only needed for monochrome. */
  52.     int invert;            /* 0 if 1=white, -1 if 1=black */
  53.     /* Following are only needed for mapped color. */
  54.     int palette_size;        /* # of entries */
  55.     byte *palette;            /* RGB triples */
  56.     /* Following are used for all memory devices. */
  57.     /* If the memory_procs are non-zero, they are used for */
  58.     /* allocating the bitmap when the device is opened, */
  59.     /* and freeing it when the device is closed. */
  60.     gs_memory_procs memory_procs;
  61. };
  62. extern const gx_device_memory
  63.     mem_mono_device,
  64.     mem_mapped2_color_device,
  65.     mem_mapped4_color_device,
  66.     mem_mapped8_color_device,
  67.     mem_true16_color_device,
  68.     mem_true24_color_device,
  69.     mem_true32_color_device;
  70.  
  71. /*
  72.  * Memory devices may have special setup requirements.
  73.  * In particular, it may not be obvious how much space to allocate
  74.  * for the bitmap.  Here is the routine that computes this
  75.  * from the width and height in the device structure.
  76.  */
  77. extern ulong gdev_mem_bitmap_size(P1(const gx_device_memory *));
  78. /*
  79.  * Compute the raster (bytes per line) similarly.
  80.  */
  81. #define gdev_mem_raster(mdev)\
  82.   gx_device_raster((const gx_device *)(mdev), 1)
  83.  
  84. /* Determine the appropriate memory device for a given */
  85. /* number of bits per pixel (0 if none suitable). */
  86. extern const gx_device_memory *gdev_mem_device_for_bits(P1(int));
  87.  
  88. /* Test whether a device is a memory device. */
  89. extern int gs_device_is_memory(P1(const gx_device *));
  90.  
  91. /* Ensure that the data bytes are in big-endian order. */
  92. /* This is only needed when the bitmap will be used as the source */
  93. /* for a copy_mono operation, and is only used for the character cache */
  94. /* and similar RAM-resident devices. */
  95. extern void gdev_mem_ensure_byte_order(P1(gx_device_memory *));
  96.  
  97. /*
  98.  * A memory device is guaranteed to allocate the bitmap consecutively,
  99.  * i.e., in the form that can serve as input to copy_mono or copy_color
  100.  * operations (provided that the bytes are in big-endian order, of course).
  101.  */
  102.