]>
git.ipfire.org Git - thirdparty/cups.git/blob - driver/pack.c
4 * Bit packing routines for CUPS.
6 * Copyright 2007 by Apple Inc.
7 * Copyright 1993-2005 by Easy Software Products.
9 * These coded instructions, statements, and computer programs are the
10 * property of Apple Inc. and are protected by Federal copyright
11 * law. Distribution and use rights are outlined in the file "LICENSE.txt"
12 * which should have been included with this file. If this file is
13 * file is missing or damaged, see the license at "http://www.cups.org/".
17 * cupsPackHorizontal() - Pack pixels horizontally...
18 * cupsPackHorizontal2() - Pack 2-bit pixels horizontally...
19 * cupsPackHorizontalBit() - Pack pixels horizontally by bit...
20 * cupsPackVertical() - Pack pixels vertically...
24 * Include necessary headers...
31 * 'cupsPackHorizontal()' - Pack pixels horizontally...
35 cupsPackHorizontal(const unsigned char *ipixels
,/* I - Input pixels */
36 unsigned char *obytes
, /* O - Output bytes */
37 int width
, /* I - Number of pixels */
38 const unsigned char clearto
, /* I - Initial value of bytes */
39 const int step
) /* I - Step value between pixels */
41 register unsigned char b
; /* Current byte */
45 * Do whole bytes first...
83 * Then do the last N bytes (N < 8)...
91 if (ipixels
[6 * step
])
94 if (ipixels
[5 * step
])
97 if (ipixels
[4 * step
])
100 if (ipixels
[3 * step
])
103 if (ipixels
[2 * step
])
106 if (ipixels
[1 * step
])
118 * 'cupsPackHorizontal2()' - Pack 2-bit pixels horizontally...
122 cupsPackHorizontal2(const unsigned char *ipixels
, /* I - Input pixels */
123 unsigned char *obytes
, /* O - Output bytes */
124 int width
, /* I - Number of pixels */
125 const int step
) /* I - Stepping value */
127 register unsigned char b
; /* Current byte */
131 * Do whole bytes first...
138 b
= (b
<< 2) | *ipixels
;
140 b
= (b
<< 2) | *ipixels
;
142 b
= (b
<< 2) | *ipixels
;
151 * Then do the last N bytes (N < 4)...
159 b
= ipixels
[2 * step
];
161 b
= (b
<< 2) | ipixels
[step
];
163 b
= (b
<< 2) | ipixels
[0];
164 *obytes
= b
<< (8 - 2 * width
);
171 * 'cupsPackHorizontalBit()' - Pack pixels horizontally by bit...
175 cupsPackHorizontalBit(const unsigned char *ipixels
, /* I - Input pixels */
176 unsigned char *obytes
, /* O - Output bytes */
177 int width
, /* I - Number of pixels */
178 const unsigned char clearto
, /* I - Initial value of bytes */
179 const unsigned char bit
) /* I - Bit to check */
181 register unsigned char b
; /* Current byte */
185 * Do whole bytes first...
192 if (*ipixels
++ & bit
)
194 if (*ipixels
++ & bit
)
196 if (*ipixels
++ & bit
)
198 if (*ipixels
++ & bit
)
200 if (*ipixels
++ & bit
)
202 if (*ipixels
++ & bit
)
204 if (*ipixels
++ & bit
)
206 if (*ipixels
++ & bit
)
215 * Then do the last N bytes (N < 8)...
223 if (ipixels
[6] & bit
)
226 if (ipixels
[5] & bit
)
229 if (ipixels
[4] & bit
)
232 if (ipixels
[3] & bit
)
235 if (ipixels
[2] & bit
)
238 if (ipixels
[1] & bit
)
241 if (ipixels
[0] & bit
)
250 * 'cupsPackVertical()' - Pack pixels vertically...
254 cupsPackVertical(const unsigned char *ipixels
, /* I - Input pixels */
255 unsigned char *obytes
, /* O - Output bytes */
256 int width
, /* I - Number of input pixels */
257 const unsigned char bit
, /* I - Output bit */
258 const int step
) /* I - Number of bytes between columns */
261 * Loop through the entire array...