Commit | Line | Data |
---|---|---|
e5dfdf21 WJ |
1 | /* Copyright (C) 1989, 1991 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 '...bitmap_size' */ | |
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 | }; | |
57 | extern gx_device_memory | |
58 | mem_mono_device, | |
59 | mem_mapped2_color_device, | |
60 | mem_mapped4_color_device, | |
61 | mem_mapped8_color_device, | |
62 | mem_true16_color_device, | |
63 | mem_true24_color_device, | |
64 | mem_true32_color_device; | |
65 | ||
66 | /* Memory devices may have special setup requirements. */ | |
67 | /* In particular, it may not be obvious how much space to allocate */ | |
68 | /* for the bitmap. Here is the routine that computes this */ | |
69 | /* from the width and height in the device structure. */ | |
70 | extern ulong gdev_mem_bitmap_size(P1(gx_device_memory *)); | |
71 | ||
72 | /* Determine the appropriate memory device for a given */ | |
73 | /* number of bits per pixel (0 if none suitable). */ | |
74 | extern gx_device_memory *gdev_mem_device_for_bits(P1(int)); | |
75 | ||
76 | /* Test whether a device is a memory device. */ | |
77 | extern int gs_device_is_memory(P1(const gx_device *)); | |
78 | ||
79 | /* Ensure that the data bytes are in big-endian order. */ | |
80 | /* This is only needed when the bitmap will be used as the source */ | |
81 | /* for a copy_mono operation, and is only used for the character cache */ | |
82 | /* and similar RAM-resident devices. */ | |
83 | extern void gdev_mem_ensure_byte_order(P1(gx_device_memory *)); | |
84 | ||
85 | /* | |
86 | * A memory device is guaranteed to allocate the bitmap consecutively, | |
87 | * i.e., in the form that can serve as input to copy_mono or copy_color | |
88 | * operations (provided that the bytes are in big-endian order, of course). | |
89 | */ |