home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1996 February / PCWK0296.iso / sharewar / dos / program / gs300sr1 / gs300sr1.exe / GXDEVMEM.H < prev    next >
C/C++ Source or Header  |  1994-07-27  |  4KB  |  98 lines

  1. /* Copyright (C) 1989, 1991, 1992, 1993 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of Aladdin Ghostscript.
  4.   
  5.   Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author
  6.   or distributor accepts any responsibility for the consequences of using it,
  7.   or for whether it serves any particular purpose or works at all, unless he
  8.   or she says so in writing.  Refer to the Aladdin Ghostscript Free Public
  9.   License (the "License") for full details.
  10.   
  11.   Every copy of Aladdin Ghostscript must include a copy of the License,
  12.   normally in a plain ASCII text file named PUBLIC.  The License grants you
  13.   the right to copy, modify and redistribute Aladdin Ghostscript, but only
  14.   under certain conditions described in the License.  Among other things, the
  15.   License requires that the copyright notice and this notice be preserved on
  16.   all copies.
  17. */
  18.  
  19. /* gxdevmem.h */
  20. /* "Memory" device structure for Ghostscript library */
  21. /* Requires gxdevice.h */
  22.  
  23. /*
  24.  * A 'memory' device is essentially a stored bitmap.
  25.  * There are several different kinds: 1-bit black and white,
  26.  * 2-, 4-, and 8-bit mapped color, and 16-, 24-, and 32-bit RGB color.
  27.  * (16-bit uses 5/6/5 bits per color.  32-bit uses a padding byte;
  28.  * 24-bit takes less space, but is slower.)  All use the same structure,
  29.  * since it's so awkward to get the effect of subclasses in C.
  30.  * We should support 32-bit CMYK color, but we don't yet.
  31.  *
  32.  * Regardless of the machine byte order, we store bytes big-endian.
  33.  * This is required if the bits will be used as the source for a
  34.  * rendering operation, and doesn't cost much to maintain.  Since
  35.  * memory devices also are guaranteed to allocate the bitmap consecutively,
  36.  * the bitmap can serve directly as input to copy_mono or copy_color
  37.  * operations.
  38.  */
  39. typedef struct gx_device_memory_s gx_device_memory;
  40. struct gx_device_memory_s {
  41.     gx_device_forward_common;    /* (see gxdevice.h) */
  42.     gs_matrix initial_matrix;    /* the initial transformation */
  43.     uint raster;            /* bytes per scan line, */
  44.                     /* filled in by 'open' */
  45.     bool foreign_bits;        /* if true, bits are not in */
  46.                     /* GC-able space */
  47.     byte *base;
  48.     byte **line_ptrs;        /* scan line pointers */
  49. #define scan_line_base(dev,y) (dev->line_ptrs[y])
  50.     /* If the bitmap_memory pointer is non-zero, it is used for */
  51.     /* allocating the bitmap when the device is opened, */
  52.     /* and freeing it when the device is closed. */
  53.     gs_memory_t *bitmap_memory;
  54.         /* Following is only needed for monochrome. */
  55.     int invert;            /* 0 if 1=white, -1 if 1=black */
  56.         /* Following is only needed for mapped color. */
  57.     gs_string palette;        /* RGB triples */
  58.         /* Following is only used for 24-bit color. */
  59.     struct _c24 {
  60.         gx_color_index rgb;    /* cache key */
  61.         bits32 rgbr, gbrg, brgb;    /* cache value */
  62.     } color24;
  63. };
  64. extern_st(st_device_memory);
  65. #define public_st_device_memory() /* in gdevmem1.c */\
  66.   gs_public_st_composite(st_device_memory, gx_device_memory,\
  67.     "gx_device_memory", device_memory_enum_ptrs, device_memory_reloc_ptrs)
  68. #define st_device_memory_max_ptrs (st_device_forward_max_ptrs + 2)
  69.  
  70. /*
  71.  * Memory devices may have special setup requirements.
  72.  * In particular, it may not be obvious how much space to allocate
  73.  * for the bitmap.  Here is the routine that computes this
  74.  * from the width and height in the device structure.
  75.  */
  76. ulong    gdev_mem_bitmap_size(P1(const gx_device_memory *));
  77. /*
  78.  * Compute the raster (bytes per line) similarly.
  79.  */
  80. #define gdev_mem_raster(mdev)\
  81.   gx_device_raster((const gx_device *)(mdev), 1)
  82.  
  83. /* Determine the appropriate memory device for a given */
  84. /* number of bits per pixel (0 if none suitable). */
  85. const gx_device_memory *gdev_mem_device_for_bits(P1(int));
  86.  
  87. /* Make a memory device. */
  88. /* The gs_memory_t argument is 0 if the device is temporary and local, */
  89. /* or the allocator that was used to allocate it if it is a real object. */
  90. /* The int argument is 1 if the device should be a page device, */
  91. /* 0 if it should propagate this property from its target, or */
  92. /* -1 if it should not be a page device. */
  93. void    gs_make_mem_mono_device(P2(gx_device_memory *, gs_memory_t *));
  94. void    gs_make_mem_device(P4(gx_device_memory *, const gx_device_memory *, gs_memory_t *, int));
  95.  
  96. /* Test whether a device is a memory device. */
  97. bool    gs_device_is_memory(P1(const gx_device *));
  98.