pix.h 51 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112
  1. /*====================================================================*
  2. - Copyright (C) 2001 Leptonica. All rights reserved.
  3. -
  4. - Redistribution and use in source and binary forms, with or without
  5. - modification, are permitted provided that the following conditions
  6. - are met:
  7. - 1. Redistributions of source code must retain the above copyright
  8. - notice, this list of conditions and the following disclaimer.
  9. - 2. Redistributions in binary form must reproduce the above
  10. - copyright notice, this list of conditions and the following
  11. - disclaimer in the documentation and/or other materials
  12. - provided with the distribution.
  13. -
  14. - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  15. - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  16. - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  17. - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
  18. - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  19. - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  20. - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  21. - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  22. - OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  23. - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  24. - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25. *====================================================================*/
  26. #ifndef LEPTONICA_PIX_H
  27. #define LEPTONICA_PIX_H
  28. /*
  29. * pix.h
  30. *
  31. * Valid image types in leptonica:
  32. * Pix: 1 bpp, with and without colormap
  33. * Pix: 2 bpp, with and without colormap
  34. * Pix: 4 bpp, with and without colormap
  35. * Pix: 8 bpp, with and without colormap
  36. * Pix: 16 bpp (1 spp)
  37. * Pix: 32 bpp (rgb, 3 spp)
  38. * Pix: 32 bpp (rgba, 4 spp)
  39. * FPix: 32 bpp float
  40. * DPix: 64 bpp double
  41. * Notes:
  42. * (1) The only valid Pix image type with alpha is rgba.
  43. * In particular, the alpha component is not used in
  44. * cmapped images.
  45. * (2) PixComp can hold any Pix with IFF_PNG encoding.
  46. *
  47. * This file defines most of the image-related structs used in leptonica:
  48. * struct Pix
  49. * struct PixColormap
  50. * struct RGBA_Quad
  51. * struct Pixa
  52. * struct Pixaa
  53. * struct Box
  54. * struct Boxa
  55. * struct Boxaa
  56. * struct Pta
  57. * struct Ptaa
  58. * struct Pixacc
  59. * struct PixTiling
  60. * struct FPix
  61. * struct FPixa
  62. * struct DPix
  63. * struct PixComp
  64. * struct PixaComp
  65. *
  66. * This file has definitions for:
  67. * Colors for RGB
  68. * Perceptual color weights
  69. * Colormap conversion flags
  70. * Rasterop bit flags
  71. * Structure access flags (for insert, copy, clone, copy-clone)
  72. * Sorting flags (by type and direction)
  73. * Blending flags
  74. * Graphics pixel setting flags
  75. * Size filtering flags
  76. * Color component selection flags
  77. * 16-bit conversion flags
  78. * Rotation and shear flags
  79. * Affine transform order flags
  80. * Grayscale filling flags
  81. * Flags for setting to white or black
  82. * Flags for getting white or black pixel value
  83. * Flags for 8 and 16 bit pixel sums
  84. * Dithering flags
  85. * Distance flags
  86. * Statistical measures
  87. * Set selection flags
  88. * Text orientation flags
  89. * Edge orientation flags
  90. * Line orientation flags
  91. * Scan direction flags
  92. * Box size adjustment flags
  93. * Flags for selecting box boundaries from two choices
  94. * Handling overlapping bounding boxes in boxa
  95. * Horizontal warp
  96. * Pixel selection for resampling
  97. * Thinning flags
  98. * Runlength flags
  99. * Edge filter flags
  100. * Subpixel color component ordering in LCD display
  101. * HSV histogram flags
  102. * Region flags (inclusion, exclusion)
  103. * Flags for adding text to a pix
  104. * Flags for plotting on a pix
  105. * Flags for selecting display program
  106. * Flags in the 'special' pix field for non-default operations
  107. * Handling negative values in conversion to unsigned int
  108. * Relative to zero flags
  109. * Flags for adding or removing traling slash from string *
  110. */
  111. /*-------------------------------------------------------------------------*
  112. * Basic Pix *
  113. *-------------------------------------------------------------------------*/
  114. /* The 'special' field is by default 0, but it can hold integers
  115. * that direct non-default actions, e.g., in png and jpeg I/O. */
  116. struct Pix
  117. {
  118. l_uint32 w; /* width in pixels */
  119. l_uint32 h; /* height in pixels */
  120. l_uint32 d; /* depth in bits (bpp) */
  121. l_uint32 spp; /* number of samples per pixel */
  122. l_uint32 wpl; /* 32-bit words/line */
  123. l_uint32 refcount; /* reference count (1 if no clones) */
  124. l_int32 xres; /* image res (ppi) in x direction */
  125. /* (use 0 if unknown) */
  126. l_int32 yres; /* image res (ppi) in y direction */
  127. /* (use 0 if unknown) */
  128. l_int32 informat; /* input file format, IFF_* */
  129. l_int32 special; /* special instructions for I/O, etc */
  130. char *text; /* text string associated with pix */
  131. struct PixColormap *colormap; /* colormap (may be null) */
  132. l_uint32 *data; /* the image data */
  133. };
  134. typedef struct Pix PIX;
  135. struct PixColormap
  136. {
  137. void *array; /* colormap table (array of RGBA_QUAD) */
  138. l_int32 depth; /* of pix (1, 2, 4 or 8 bpp) */
  139. l_int32 nalloc; /* number of color entries allocated */
  140. l_int32 n; /* number of color entries used */
  141. };
  142. typedef struct PixColormap PIXCMAP;
  143. /* Colormap table entry (after the BMP version).
  144. * Note that the BMP format stores the colormap table exactly
  145. * as it appears here, with color samples being stored sequentially,
  146. * in the order (b,g,r,a). */
  147. struct RGBA_Quad
  148. {
  149. l_uint8 blue;
  150. l_uint8 green;
  151. l_uint8 red;
  152. l_uint8 alpha;
  153. };
  154. typedef struct RGBA_Quad RGBA_QUAD;
  155. /*-------------------------------------------------------------------------*
  156. * Colors for 32 bpp *
  157. *-------------------------------------------------------------------------*/
  158. /* Notes:
  159. * (1) These are the byte indices for colors in 32 bpp images.
  160. * They are used through the GET/SET_DATA_BYTE accessors.
  161. * The 4th byte, typically known as the "alpha channel" and used
  162. * for blending, is used to a small extent in leptonica.
  163. * (2) Do not change these values! If you redefine them, functions
  164. * that have the shifts hardcoded for efficiency and conciseness
  165. * (instead of using the constants below) will break. These
  166. * functions are labelled with "***" next to their names at
  167. * the top of the files in which they are defined.
  168. * (3) The shifts to extract the red, green, blue and alpha components
  169. * from a 32 bit pixel are defined here.
  170. */
  171. enum {
  172. COLOR_RED = 0,
  173. COLOR_GREEN = 1,
  174. COLOR_BLUE = 2,
  175. L_ALPHA_CHANNEL = 3
  176. };
  177. static const l_int32 L_RED_SHIFT =
  178. 8 * (sizeof(l_uint32) - 1 - COLOR_RED); /* 24 */
  179. static const l_int32 L_GREEN_SHIFT =
  180. 8 * (sizeof(l_uint32) - 1 - COLOR_GREEN); /* 16 */
  181. static const l_int32 L_BLUE_SHIFT =
  182. 8 * (sizeof(l_uint32) - 1 - COLOR_BLUE); /* 8 */
  183. static const l_int32 L_ALPHA_SHIFT =
  184. 8 * (sizeof(l_uint32) - 1 - L_ALPHA_CHANNEL); /* 0 */
  185. /*-------------------------------------------------------------------------*
  186. * Perceptual color weights *
  187. *-------------------------------------------------------------------------*/
  188. /* Notes:
  189. * (1) These numbers are ad-hoc, but they do add up to 1.
  190. * Unlike, for example, the weighting factor for conversion
  191. * of RGB to luminance, or more specifically to Y in the
  192. * YUV colorspace. Those numbers come from the
  193. * International Telecommunications Union, via ITU-R.
  194. */
  195. static const l_float32 L_RED_WEIGHT = (l_float32)0.3;
  196. static const l_float32 L_GREEN_WEIGHT = (l_float32)0.5;
  197. static const l_float32 L_BLUE_WEIGHT = (l_float32)0.2;
  198. /*-------------------------------------------------------------------------*
  199. * Flags for colormap conversion *
  200. *-------------------------------------------------------------------------*/
  201. enum {
  202. REMOVE_CMAP_TO_BINARY = 0,
  203. REMOVE_CMAP_TO_GRAYSCALE = 1,
  204. REMOVE_CMAP_TO_FULL_COLOR = 2,
  205. REMOVE_CMAP_WITH_ALPHA = 3,
  206. REMOVE_CMAP_BASED_ON_SRC = 4
  207. };
  208. /*-------------------------------------------------------------------------*
  209. *
  210. * The following operation bit flags have been modified from
  211. * Sun's pixrect.h.
  212. *
  213. * The 'op' in 'rasterop' is represented by an integer
  214. * composed with Boolean functions using the set of five integers
  215. * given below. The integers, and the op codes resulting from
  216. * boolean expressions on them, need only be in the range from 0 to 15.
  217. * The function is applied on a per-pixel basis.
  218. *
  219. * Examples: the op code representing ORing the src and dest
  220. * is computed using the bit OR, as PIX_SRC | PIX_DST; the op
  221. * code representing XORing src and dest is found from
  222. * PIX_SRC ^ PIX_DST; the op code representing ANDing src and dest
  223. * is found from PIX_SRC & PIX_DST. Note that
  224. * PIX_NOT(PIX_CLR) = PIX_SET, and v.v., as they must be.
  225. *
  226. * We would like to use the following set of definitions:
  227. *
  228. * #define PIX_SRC 0xc
  229. * #define PIX_DST 0xa
  230. * #define PIX_NOT(op) ((op) ^ 0xf)
  231. * #define PIX_CLR 0x0
  232. * #define PIX_SET 0xf
  233. *
  234. * Now, these definitions differ from Sun's, in that Sun
  235. * left-shifted each value by 1 pixel, and used the least
  236. * significant bit as a flag for the "pseudo-operation" of
  237. * clipping. We don't need this bit, because it is both
  238. * efficient and safe ALWAYS to clip the rectangles to the src
  239. * and dest images, which is what we do. See the notes in rop.h
  240. * on the general choice of these bit flags.
  241. *
  242. * However, if you include Sun's xview package, you will get their
  243. * definitions, and because I like using these flags, we will
  244. * adopt the original Sun definitions to avoid redefinition conflicts.
  245. *
  246. * Then we have, for reference, the following 16 unique op flags:
  247. *
  248. * PIX_CLR 00000 0x0
  249. * PIX_SET 11110 0x1e
  250. * PIX_SRC 11000 0x18
  251. * PIX_DST 10100 0x14
  252. * PIX_NOT(PIX_SRC) 00110 0x06
  253. * PIX_NOT(PIX_DST) 01010 0x0a
  254. * PIX_SRC | PIX_DST 11100 0x1c
  255. * PIX_SRC & PIX_DST 10000 0x10
  256. * PIX_SRC ^ PIX_DST 01100 0x0c
  257. * PIX_NOT(PIX_SRC) | PIX_DST 10110 0x16
  258. * PIX_NOT(PIX_SRC) & PIX_DST 00100 0x04
  259. * PIX_SRC | PIX_NOT(PIX_DST) 11010 0x1a
  260. * PIX_SRC & PIX_NOT(PIX_DST) 01000 0x08
  261. * PIX_NOT(PIX_SRC | PIX_DST) 00010 0x02
  262. * PIX_NOT(PIX_SRC & PIX_DST) 01110 0x0e
  263. * PIX_NOT(PIX_SRC ^ PIX_DST) 10010 0x12
  264. *
  265. *-------------------------------------------------------------------------*/
  266. #define PIX_SRC (0xc << 1)
  267. #define PIX_DST (0xa << 1)
  268. #define PIX_NOT(op) ((op) ^ 0x1e)
  269. #define PIX_CLR (0x0 << 1)
  270. #define PIX_SET (0xf << 1)
  271. #define PIX_PAINT (PIX_SRC | PIX_DST)
  272. #define PIX_MASK (PIX_SRC & PIX_DST)
  273. #define PIX_SUBTRACT (PIX_DST & PIX_NOT(PIX_SRC))
  274. #define PIX_XOR (PIX_SRC ^ PIX_DST)
  275. /*-------------------------------------------------------------------------*
  276. *
  277. * Important Notes:
  278. *
  279. * (1) The image data is stored in a single contiguous
  280. * array of l_uint32, into which the pixels are packed.
  281. * By "packed" we mean that there are no unused bits
  282. * between pixels, except for end-of-line padding to
  283. * satisfy item (2) below.
  284. *
  285. * (2) Every image raster line begins on a 32-bit word
  286. * boundary within this array.
  287. *
  288. * (3) Pix image data is stored in 32-bit units, with the
  289. * pixels ordered from left to right in the image being
  290. * stored in order from the MSB to LSB within the word,
  291. * for both big-endian and little-endian machines.
  292. * This is the natural ordering for big-endian machines,
  293. * as successive bytes are stored and fetched progressively
  294. * to the right. However, for little-endians, when storing
  295. * we re-order the bytes from this byte stream order, and
  296. * reshuffle again for byte access on 32-bit entities.
  297. * So if the bytes come in sequence from left to right, we
  298. * store them on little-endians in byte order:
  299. * 3 2 1 0 7 6 5 4 ...
  300. * This MSB to LSB ordering allows left and right shift
  301. * operations on 32 bit words to move the pixels properly.
  302. *
  303. * (4) We use 32 bit pixels for both RGB and RGBA color images.
  304. * The A (alpha) byte is ignored in most leptonica functions
  305. * operating on color images. Within each 4 byte pixel, the
  306. * colors are ordered from MSB to LSB, as follows:
  307. *
  308. * | MSB | 2nd MSB | 3rd MSB | LSB |
  309. * red green blue alpha
  310. * 0 1 2 3 (big-endian)
  311. * 3 2 1 0 (little-endian)
  312. *
  313. * Because we use MSB to LSB ordering within the 32-bit word,
  314. * the individual 8-bit samples can be accessed with
  315. * GET_DATA_BYTE and SET_DATA_BYTE macros, using the
  316. * (implicitly big-ending) ordering
  317. * red: byte 0 (MSB)
  318. * green: byte 1 (2nd MSB)
  319. * blue: byte 2 (3rd MSB)
  320. * alpha: byte 3 (LSB)
  321. *
  322. * The specific color assignment is made in this file,
  323. * through the definitions of COLOR_RED, etc. Then the R, G
  324. * B and A sample values can be retrieved using
  325. * redval = GET_DATA_BYTE(&pixel, COLOR_RED);
  326. * greenval = GET_DATA_BYTE(&pixel, COLOR_GREEN);
  327. * blueval = GET_DATA_BYTE(&pixel, COLOR_BLUE);
  328. * alphaval = GET_DATA_BYTE(&pixel, L_ALPHA_CHANNEL);
  329. * and they can be set with
  330. * SET_DATA_BYTE(&pixel, COLOR_RED, redval);
  331. * SET_DATA_BYTE(&pixel, COLOR_GREEN, greenval);
  332. * SET_DATA_BYTE(&pixel, COLOR_BLUE, blueval);
  333. * SET_DATA_BYTE(&pixel, L_ALPHA_CHANNEL, alphaval);
  334. *
  335. * For extra speed we extract these components directly
  336. * by shifting and masking, explicitly using the values in
  337. * L_RED_SHIFT, etc.:
  338. * (pixel32 >> L_RED_SHIFT) & 0xff; (red)
  339. * (pixel32 >> L_GREEN_SHIFT) & 0xff; (green)
  340. * (pixel32 >> L_BLUE_SHIFT) & 0xff; (blue)
  341. * (pixel32 >> L_ALPHA_SHIFT) & 0xff; (alpha)
  342. * All these operations work properly on both big- and little-endians.
  343. *
  344. * For a few situations, these color shift values are hard-coded.
  345. * Changing the RGB color component ordering through the assignments
  346. * in this file will cause functions marked with "***" to fail.
  347. *
  348. * (5) A reference count is held within each pix, giving the
  349. * number of ptrs to the pix. When a pixClone() call
  350. * is made, the ref count is increased by 1, and
  351. * when a pixDestroy() call is made, the reference count
  352. * of the pix is decremented. The pix is only destroyed
  353. * when the reference count goes to zero.
  354. *
  355. * (6) The version numbers (below) are used in the serialization
  356. * of these data structures. They are placed in the files,
  357. * and rarely (if ever) change. Provision is currently made for
  358. * backward compatibility in reading from boxaa version 2.
  359. *
  360. * (7) The serialization dependencies are as follows:
  361. * pixaa : pixa : boxa
  362. * boxaa : boxa
  363. * So, for example, pixaa and boxaa can be changed without
  364. * forcing a change in pixa or boxa. However, if pixa is
  365. * changed, it forces a change in pixaa, and if boxa is
  366. * changed, if forces a change in the other three.
  367. * We define four version numbers:
  368. * PIXAA_VERSION_NUMBER
  369. * PIXA_VERSION_NUMBER
  370. * BOXAA_VERSION_NUMBER
  371. * BOXA_VERSION_NUMBER
  372. *
  373. *-------------------------------------------------------------------------*/
  374. /*-------------------------------------------------------------------------*
  375. * Array of pix *
  376. *-------------------------------------------------------------------------*/
  377. /* Serialization for primary data structures */
  378. #define PIXAA_VERSION_NUMBER 2
  379. #define PIXA_VERSION_NUMBER 2
  380. #define BOXA_VERSION_NUMBER 2
  381. #define BOXAA_VERSION_NUMBER 3
  382. struct Pixa
  383. {
  384. l_int32 n; /* number of Pix in ptr array */
  385. l_int32 nalloc; /* number of Pix ptrs allocated */
  386. l_uint32 refcount; /* reference count (1 if no clones) */
  387. struct Pix **pix; /* the array of ptrs to pix */
  388. struct Boxa *boxa; /* array of boxes */
  389. };
  390. typedef struct Pixa PIXA;
  391. struct Pixaa
  392. {
  393. l_int32 n; /* number of Pixa in ptr array */
  394. l_int32 nalloc; /* number of Pixa ptrs allocated */
  395. struct Pixa **pixa; /* array of ptrs to pixa */
  396. struct Boxa *boxa; /* array of boxes */
  397. };
  398. typedef struct Pixaa PIXAA;
  399. /*-------------------------------------------------------------------------*
  400. * Basic rectangle and rectangle arrays *
  401. *-------------------------------------------------------------------------*/
  402. struct Box
  403. {
  404. l_int32 x;
  405. l_int32 y;
  406. l_int32 w;
  407. l_int32 h;
  408. l_uint32 refcount; /* reference count (1 if no clones) */
  409. };
  410. typedef struct Box BOX;
  411. struct Boxa
  412. {
  413. l_int32 n; /* number of box in ptr array */
  414. l_int32 nalloc; /* number of box ptrs allocated */
  415. l_uint32 refcount; /* reference count (1 if no clones) */
  416. struct Box **box; /* box ptr array */
  417. };
  418. typedef struct Boxa BOXA;
  419. struct Boxaa
  420. {
  421. l_int32 n; /* number of boxa in ptr array */
  422. l_int32 nalloc; /* number of boxa ptrs allocated */
  423. struct Boxa **boxa; /* boxa ptr array */
  424. };
  425. typedef struct Boxaa BOXAA;
  426. /*-------------------------------------------------------------------------*
  427. * Array of points *
  428. *-------------------------------------------------------------------------*/
  429. #define PTA_VERSION_NUMBER 1
  430. struct Pta
  431. {
  432. l_int32 n; /* actual number of pts */
  433. l_int32 nalloc; /* size of allocated arrays */
  434. l_uint32 refcount; /* reference count (1 if no clones) */
  435. l_float32 *x, *y; /* arrays of floats */
  436. };
  437. typedef struct Pta PTA;
  438. /*-------------------------------------------------------------------------*
  439. * Array of Pta *
  440. *-------------------------------------------------------------------------*/
  441. struct Ptaa
  442. {
  443. l_int32 n; /* number of pta in ptr array */
  444. l_int32 nalloc; /* number of pta ptrs allocated */
  445. struct Pta **pta; /* pta ptr array */
  446. };
  447. typedef struct Ptaa PTAA;
  448. /*-------------------------------------------------------------------------*
  449. * Pix accumulator container *
  450. *-------------------------------------------------------------------------*/
  451. struct Pixacc
  452. {
  453. l_int32 w; /* array width */
  454. l_int32 h; /* array height */
  455. l_int32 offset; /* used to allow negative */
  456. /* intermediate results */
  457. struct Pix *pix; /* the 32 bit accumulator pix */
  458. };
  459. typedef struct Pixacc PIXACC;
  460. /*-------------------------------------------------------------------------*
  461. * Pix tiling *
  462. *-------------------------------------------------------------------------*/
  463. struct PixTiling
  464. {
  465. struct Pix *pix; /* input pix (a clone) */
  466. l_int32 nx; /* number of tiles horizontally */
  467. l_int32 ny; /* number of tiles vertically */
  468. l_int32 w; /* tile width */
  469. l_int32 h; /* tile height */
  470. l_int32 xoverlap; /* overlap on left and right */
  471. l_int32 yoverlap; /* overlap on top and bottom */
  472. l_int32 strip; /* strip for paint; default is TRUE */
  473. };
  474. typedef struct PixTiling PIXTILING;
  475. /*-------------------------------------------------------------------------*
  476. * FPix: pix with float array *
  477. *-------------------------------------------------------------------------*/
  478. #define FPIX_VERSION_NUMBER 2
  479. struct FPix
  480. {
  481. l_int32 w; /* width in pixels */
  482. l_int32 h; /* height in pixels */
  483. l_int32 wpl; /* 32-bit words/line */
  484. l_uint32 refcount; /* reference count (1 if no clones) */
  485. l_int32 xres; /* image res (ppi) in x direction */
  486. /* (use 0 if unknown) */
  487. l_int32 yres; /* image res (ppi) in y direction */
  488. /* (use 0 if unknown) */
  489. l_float32 *data; /* the float image data */
  490. };
  491. typedef struct FPix FPIX;
  492. struct FPixa
  493. {
  494. l_int32 n; /* number of fpix in ptr array */
  495. l_int32 nalloc; /* number of fpix ptrs allocated */
  496. l_uint32 refcount; /* reference count (1 if no clones) */
  497. struct FPix **fpix; /* the array of ptrs to fpix */
  498. };
  499. typedef struct FPixa FPIXA;
  500. /*-------------------------------------------------------------------------*
  501. * DPix: pix with double array *
  502. *-------------------------------------------------------------------------*/
  503. #define DPIX_VERSION_NUMBER 2
  504. struct DPix
  505. {
  506. l_int32 w; /* width in pixels */
  507. l_int32 h; /* height in pixels */
  508. l_int32 wpl; /* 32-bit words/line */
  509. l_uint32 refcount; /* reference count (1 if no clones) */
  510. l_int32 xres; /* image res (ppi) in x direction */
  511. /* (use 0 if unknown) */
  512. l_int32 yres; /* image res (ppi) in y direction */
  513. /* (use 0 if unknown) */
  514. l_float64 *data; /* the double image data */
  515. };
  516. typedef struct DPix DPIX;
  517. /*-------------------------------------------------------------------------*
  518. * PixComp: compressed pix *
  519. *-------------------------------------------------------------------------*/
  520. struct PixComp
  521. {
  522. l_int32 w; /* width in pixels */
  523. l_int32 h; /* height in pixels */
  524. l_int32 d; /* depth in bits */
  525. l_int32 xres; /* image res (ppi) in x direction */
  526. /* (use 0 if unknown) */
  527. l_int32 yres; /* image res (ppi) in y direction */
  528. /* (use 0 if unknown) */
  529. l_int32 comptype; /* compressed format (IFF_TIFF_G4, */
  530. /* IFF_PNG, IFF_JFIF_JPEG) */
  531. char *text; /* text string associated with pix */
  532. l_int32 cmapflag; /* flag (1 for cmap, 0 otherwise) */
  533. l_uint8 *data; /* the compressed image data */
  534. size_t size; /* size of the data array */
  535. };
  536. typedef struct PixComp PIXC;
  537. /*-------------------------------------------------------------------------*
  538. * PixaComp: array of compressed pix *
  539. *-------------------------------------------------------------------------*/
  540. #define PIXACOMP_VERSION_NUMBER 2
  541. struct PixaComp
  542. {
  543. l_int32 n; /* number of PixComp in ptr array */
  544. l_int32 nalloc; /* number of PixComp ptrs allocated */
  545. l_int32 offset; /* indexing offset into ptr array */
  546. struct PixComp **pixc; /* the array of ptrs to PixComp */
  547. struct Boxa *boxa; /* array of boxes */
  548. };
  549. typedef struct PixaComp PIXAC;
  550. /*-------------------------------------------------------------------------*
  551. * Access and storage flags *
  552. *-------------------------------------------------------------------------*/
  553. /*
  554. * For Pix, Box, Pta and Numa, there are 3 standard methods for handling
  555. * the retrieval or insertion of a struct:
  556. * (1) direct insertion (Don't do this if there is another handle
  557. * somewhere to this same struct!)
  558. * (2) copy (Always safe, sets up a refcount of 1 on the new object.
  559. * Can be undesirable if very large, such as an image or
  560. * an array of images.)
  561. * (3) clone (Makes another handle to the same struct, and bumps the
  562. * refcount up by 1. Safe to do unless you're changing
  563. * data through one of the handles but don't want those
  564. * changes to be seen by the other handle.)
  565. *
  566. * For Pixa and Boxa, which are structs that hold an array of clonable
  567. * structs, there is an additional method:
  568. * (4) copy-clone (Makes a new higher-level struct with a refcount
  569. * of 1, but clones all the structs in the array.)
  570. *
  571. * Unlike the other structs, when retrieving a string from an Sarray,
  572. * you are allowed to get a handle without a copy or clone (i.e., that
  573. * you don't own!). You must not free or insert such a string!
  574. * Specifically, for an Sarray, the copyflag for retrieval is either:
  575. * TRUE (or 1 or L_COPY)
  576. * or
  577. * FALSE (or 0 or L_NOCOPY)
  578. * For insertion, the copyflag is either:
  579. * TRUE (or 1 or L_COPY)
  580. * or
  581. * FALSE (or 0 or L_INSERT)
  582. * Note that L_COPY is always 1, and L_INSERT and L_NOCOPY are always 0.
  583. */
  584. enum {
  585. L_INSERT = 0, /* stuff it in; no copy, clone or copy-clone */
  586. L_COPY = 1, /* make/use a copy of the object */
  587. L_CLONE = 2, /* make/use clone (ref count) of the object */
  588. L_COPY_CLONE = 3 /* make a new object and fill with with clones */
  589. /* of each object in the array(s) */
  590. };
  591. static const l_int32 L_NOCOPY = 0; /* copyflag value in sarrayGetString() */
  592. /*--------------------------------------------------------------------------*
  593. * Sort flags *
  594. *--------------------------------------------------------------------------*/
  595. enum {
  596. L_SHELL_SORT = 1, /* use shell sort */
  597. L_BIN_SORT = 2 /* use bin sort */
  598. };
  599. enum {
  600. L_SORT_INCREASING = 1, /* sort in increasing order */
  601. L_SORT_DECREASING = 2 /* sort in decreasing order */
  602. };
  603. enum {
  604. L_SORT_BY_X = 1, /* sort box or c.c. by left edge location */
  605. L_SORT_BY_Y = 2, /* sort box or c.c. by top edge location */
  606. L_SORT_BY_RIGHT = 3, /* sort box or c.c. by right edge location */
  607. L_SORT_BY_BOT = 4, /* sort box or c.c. by bot edge location */
  608. L_SORT_BY_WIDTH = 5, /* sort box or c.c. by width */
  609. L_SORT_BY_HEIGHT = 6, /* sort box or c.c. by height */
  610. L_SORT_BY_MIN_DIMENSION = 7, /* sort box or c.c. by min dimension */
  611. L_SORT_BY_MAX_DIMENSION = 8, /* sort box or c.c. by max dimension */
  612. L_SORT_BY_PERIMETER = 9, /* sort box or c.c. by perimeter */
  613. L_SORT_BY_AREA = 10, /* sort box or c.c. by area */
  614. L_SORT_BY_ASPECT_RATIO = 11 /* sort box or c.c. by width/height ratio */
  615. };
  616. /*-------------------------------------------------------------------------*
  617. * Blend flags *
  618. *-------------------------------------------------------------------------*/
  619. enum {
  620. L_BLEND_WITH_INVERSE = 1, /* add some of src inverse to itself */
  621. L_BLEND_TO_WHITE = 2, /* shift src colors towards white */
  622. L_BLEND_TO_BLACK = 3, /* shift src colors towards black */
  623. L_BLEND_GRAY = 4, /* blend src directly with blender */
  624. L_BLEND_GRAY_WITH_INVERSE = 5 /* add amount of src inverse to itself, */
  625. /* based on blender pix value */
  626. };
  627. enum {
  628. L_PAINT_LIGHT = 1, /* colorize non-black pixels */
  629. L_PAINT_DARK = 2 /* colorize non-white pixels */
  630. };
  631. /*-------------------------------------------------------------------------*
  632. * Graphics pixel setting *
  633. *-------------------------------------------------------------------------*/
  634. enum {
  635. L_SET_PIXELS = 1, /* set all bits in each pixel to 1 */
  636. L_CLEAR_PIXELS = 2, /* set all bits in each pixel to 0 */
  637. L_FLIP_PIXELS = 3 /* flip all bits in each pixel */
  638. };
  639. /*-------------------------------------------------------------------------*
  640. * Size filter flags *
  641. *-------------------------------------------------------------------------*/
  642. enum {
  643. L_SELECT_WIDTH = 1, /* width must satisfy constraint */
  644. L_SELECT_HEIGHT = 2, /* height must satisfy constraint */
  645. L_SELECT_IF_EITHER = 3, /* either width or height can satisfy */
  646. L_SELECT_IF_BOTH = 4 /* both width and height must satisfy */
  647. };
  648. enum {
  649. L_SELECT_IF_LT = 1, /* save if value is less than threshold */
  650. L_SELECT_IF_GT = 2, /* save if value is more than threshold */
  651. L_SELECT_IF_LTE = 3, /* save if value is <= to the threshold */
  652. L_SELECT_IF_GTE = 4 /* save if value is >= to the threshold */
  653. };
  654. /*-------------------------------------------------------------------------*
  655. * Color component selection flags *
  656. *-------------------------------------------------------------------------*/
  657. enum {
  658. L_SELECT_RED = 1, /* use red component */
  659. L_SELECT_GREEN = 2, /* use green component */
  660. L_SELECT_BLUE = 3, /* use blue component */
  661. L_SELECT_MIN = 4, /* use min color component */
  662. L_SELECT_MAX = 5, /* use max color component */
  663. L_SELECT_AVERAGE = 6 /* use average of color components */
  664. };
  665. /*-------------------------------------------------------------------------*
  666. * 16-bit conversion flags *
  667. *-------------------------------------------------------------------------*/
  668. enum {
  669. L_LS_BYTE = 0, /* use LSB */
  670. L_MS_BYTE = 1, /* use MSB */
  671. L_CLIP_TO_255 = 2 /* use max(val, 255) */
  672. };
  673. /*-------------------------------------------------------------------------*
  674. * Rotate and shear flags *
  675. *-------------------------------------------------------------------------*/
  676. enum {
  677. L_ROTATE_AREA_MAP = 1, /* use area map rotation, if possible */
  678. L_ROTATE_SHEAR = 2, /* use shear rotation */
  679. L_ROTATE_SAMPLING = 3 /* use sampling */
  680. };
  681. enum {
  682. L_BRING_IN_WHITE = 1, /* bring in white pixels from the outside */
  683. L_BRING_IN_BLACK = 2 /* bring in black pixels from the outside */
  684. };
  685. enum {
  686. L_SHEAR_ABOUT_CORNER = 1, /* shear image about UL corner */
  687. L_SHEAR_ABOUT_CENTER = 2 /* shear image about center */
  688. };
  689. /*-------------------------------------------------------------------------*
  690. * Affine transform order flags *
  691. *-------------------------------------------------------------------------*/
  692. enum {
  693. L_TR_SC_RO = 1, /* translate, scale, rotate */
  694. L_SC_RO_TR = 2, /* scale, rotate, translate */
  695. L_RO_TR_SC = 3, /* rotate, translate, scale */
  696. L_TR_RO_SC = 4, /* translate, rotate, scale */
  697. L_RO_SC_TR = 5, /* rotate, scale, translate */
  698. L_SC_TR_RO = 6 /* scale, translate, rotate */
  699. };
  700. /*-------------------------------------------------------------------------*
  701. * Grayscale filling flags *
  702. *-------------------------------------------------------------------------*/
  703. enum {
  704. L_FILL_WHITE = 1, /* fill white pixels (e.g, in fg map) */
  705. L_FILL_BLACK = 2 /* fill black pixels (e.g., in bg map) */
  706. };
  707. /*-------------------------------------------------------------------------*
  708. * Flags for setting to white or black *
  709. *-------------------------------------------------------------------------*/
  710. enum {
  711. L_SET_WHITE = 1, /* set pixels to white */
  712. L_SET_BLACK = 2 /* set pixels to black */
  713. };
  714. /*-------------------------------------------------------------------------*
  715. * Flags for getting white or black value *
  716. *-------------------------------------------------------------------------*/
  717. enum {
  718. L_GET_WHITE_VAL = 1, /* get white pixel value */
  719. L_GET_BLACK_VAL = 2 /* get black pixel value */
  720. };
  721. /*-------------------------------------------------------------------------*
  722. * Flags for 8 bit and 16 bit pixel sums *
  723. *-------------------------------------------------------------------------*/
  724. enum {
  725. L_WHITE_IS_MAX = 1, /* white pixels are 0xff or 0xffff; black are 0 */
  726. L_BLACK_IS_MAX = 2 /* black pixels are 0xff or 0xffff; white are 0 */
  727. };
  728. /*-------------------------------------------------------------------------*
  729. * Dither parameters *
  730. * If within this grayscale distance from black or white, *
  731. * do not propagate excess or deficit to neighboring pixels. *
  732. *-------------------------------------------------------------------------*/
  733. enum {
  734. DEFAULT_CLIP_LOWER_1 = 10, /* dist to black with no prop; 1 bpp */
  735. DEFAULT_CLIP_UPPER_1 = 10, /* dist to black with no prop; 1 bpp */
  736. DEFAULT_CLIP_LOWER_2 = 5, /* dist to black with no prop; 2 bpp */
  737. DEFAULT_CLIP_UPPER_2 = 5 /* dist to black with no prop; 2 bpp */
  738. };
  739. /*-------------------------------------------------------------------------*
  740. * Distance flags *
  741. *-------------------------------------------------------------------------*/
  742. enum {
  743. L_MANHATTAN_DISTANCE = 1, /* L1 distance (e.g., in color space) */
  744. L_EUCLIDEAN_DISTANCE = 2 /* L2 distance */
  745. };
  746. /*-------------------------------------------------------------------------*
  747. * Statistical measures *
  748. *-------------------------------------------------------------------------*/
  749. enum {
  750. L_MEAN_ABSVAL = 1, /* average of abs values */
  751. L_MEDIAN_VAL = 2, /* median value of set */
  752. L_MODE_VAL = 3, /* mode value of set */
  753. L_MODE_COUNT = 4, /* mode count of set */
  754. L_ROOT_MEAN_SQUARE = 5, /* rms of values */
  755. L_STANDARD_DEVIATION = 6, /* standard deviation from mean */
  756. L_VARIANCE = 7 /* variance of values */
  757. };
  758. /*-------------------------------------------------------------------------*
  759. * Set selection flags *
  760. *-------------------------------------------------------------------------*/
  761. enum {
  762. L_CHOOSE_CONSECUTIVE = 1, /* select 'n' consecutive */
  763. L_CHOOSE_SKIP_BY = 2 /* select at intervals of 'n' */
  764. };
  765. /*-------------------------------------------------------------------------*
  766. * Text orientation flags *
  767. *-------------------------------------------------------------------------*/
  768. enum {
  769. L_TEXT_ORIENT_UNKNOWN = 0, /* low confidence on text orientation */
  770. L_TEXT_ORIENT_UP = 1, /* portrait, text rightside-up */
  771. L_TEXT_ORIENT_LEFT = 2, /* landscape, text up to left */
  772. L_TEXT_ORIENT_DOWN = 3, /* portrait, text upside-down */
  773. L_TEXT_ORIENT_RIGHT = 4 /* landscape, text up to right */
  774. };
  775. /*-------------------------------------------------------------------------*
  776. * Edge orientation flags *
  777. *-------------------------------------------------------------------------*/
  778. enum {
  779. L_HORIZONTAL_EDGES = 0, /* filters for horizontal edges */
  780. L_VERTICAL_EDGES = 1, /* filters for vertical edges */
  781. L_ALL_EDGES = 2 /* filters for all edges */
  782. };
  783. /*-------------------------------------------------------------------------*
  784. * Line orientation flags *
  785. *-------------------------------------------------------------------------*/
  786. enum {
  787. L_HORIZONTAL_LINE = 0, /* horizontal line */
  788. L_POS_SLOPE_LINE = 1, /* 45 degree line with positive slope */
  789. L_VERTICAL_LINE = 2, /* vertical line */
  790. L_NEG_SLOPE_LINE = 3, /* 45 degree line with negative slope */
  791. L_OBLIQUE_LINE = 4 /* neither horizontal nor vertical */
  792. };
  793. /*-------------------------------------------------------------------------*
  794. * Scan direction flags *
  795. *-------------------------------------------------------------------------*/
  796. enum {
  797. L_FROM_LEFT = 0, /* scan from left */
  798. L_FROM_RIGHT = 1, /* scan from right */
  799. L_FROM_TOP = 2, /* scan from top */
  800. L_FROM_BOT = 3, /* scan from bottom */
  801. L_SCAN_NEGATIVE = 4, /* scan in negative direction */
  802. L_SCAN_POSITIVE = 5, /* scan in positive direction */
  803. L_SCAN_BOTH = 6, /* scan in both directions */
  804. L_SCAN_HORIZONTAL = 7, /* horizontal scan (direction unimportant) */
  805. L_SCAN_VERTICAL = 8 /* vertical scan (direction unimportant) */
  806. };
  807. /*-------------------------------------------------------------------------*
  808. * Box size adjustment and location flags *
  809. *-------------------------------------------------------------------------*/
  810. enum {
  811. L_ADJUST_SKIP = 0, /* do not adjust */
  812. L_ADJUST_LEFT = 1, /* adjust left edge */
  813. L_ADJUST_RIGHT = 2, /* adjust right edge */
  814. L_ADJUST_LEFT_AND_RIGHT = 3, /* adjust both left and right edges */
  815. L_ADJUST_TOP = 4, /* adjust top edge */
  816. L_ADJUST_BOT = 5, /* adjust bottom edge */
  817. L_ADJUST_TOP_AND_BOT = 6, /* adjust both top and bottom edges */
  818. L_ADJUST_CHOOSE_MIN = 7, /* choose the min median value */
  819. L_ADJUST_CHOOSE_MAX = 8, /* choose the max median value */
  820. L_SET_LEFT = 9, /* set left side to a given value */
  821. L_SET_RIGHT = 10, /* set right side to a given value */
  822. L_SET_TOP = 11, /* set top side to a given value */
  823. L_SET_BOT = 12, /* set bottom side to a given value */
  824. L_GET_LEFT = 13, /* get left side location */
  825. L_GET_RIGHT = 14, /* get right side location */
  826. L_GET_TOP = 15, /* get top side location */
  827. L_GET_BOT = 16 /* get bottom side location */
  828. };
  829. /*-------------------------------------------------------------------------*
  830. * Flags for selecting box boundaries from two choices *
  831. *-------------------------------------------------------------------------*/
  832. enum {
  833. L_USE_MINSIZE = 1, /* use boundaries giving min size */
  834. L_USE_MAXSIZE = 2, /* use boundaries giving max size */
  835. L_SUB_ON_BIG_DIFF = 3 /* substitute boundary if big abs diff */
  836. };
  837. /*-------------------------------------------------------------------------*
  838. * Handling overlapping bounding boxes in boxa *
  839. *-------------------------------------------------------------------------*/
  840. enum {
  841. L_COMBINE = 1, /* resize to bounding region; remove smaller */
  842. L_REMOVE_SMALL = 2 /* only remove smaller */
  843. };
  844. /*-------------------------------------------------------------------------*
  845. * Horizontal warp *
  846. *-------------------------------------------------------------------------*/
  847. enum {
  848. L_WARP_TO_LEFT = 1, /* increasing stretch or contraction to left */
  849. L_WARP_TO_RIGHT = 2 /* increasing stretch or contraction to right */
  850. };
  851. enum {
  852. L_LINEAR_WARP = 1, /* stretch or contraction grows linearly */
  853. L_QUADRATIC_WARP = 2 /* stretch or contraction grows quadratically */
  854. };
  855. /*-------------------------------------------------------------------------*
  856. * Pixel selection for resampling *
  857. *-------------------------------------------------------------------------*/
  858. enum {
  859. L_INTERPOLATED = 1, /* linear interpolation from src pixels */
  860. L_SAMPLED = 2 /* nearest src pixel sampling only */
  861. };
  862. /*-------------------------------------------------------------------------*
  863. * Thinning flags *
  864. *-------------------------------------------------------------------------*/
  865. enum {
  866. L_THIN_FG = 1, /* thin foreground of 1 bpp image */
  867. L_THIN_BG = 2 /* thin background of 1 bpp image */
  868. };
  869. /*-------------------------------------------------------------------------*
  870. * Runlength flags *
  871. *-------------------------------------------------------------------------*/
  872. enum {
  873. L_HORIZONTAL_RUNS = 0, /* determine runlengths of horizontal runs */
  874. L_VERTICAL_RUNS = 1 /* determine runlengths of vertical runs */
  875. };
  876. /*-------------------------------------------------------------------------*
  877. * Edge filter flags *
  878. *-------------------------------------------------------------------------*/
  879. enum {
  880. L_SOBEL_EDGE = 1, /* Sobel edge filter */
  881. L_TWO_SIDED_EDGE = 2 /* Two-sided edge filter */
  882. };
  883. /*-------------------------------------------------------------------------*
  884. * Subpixel color component ordering in LCD display *
  885. *-------------------------------------------------------------------------*/
  886. enum {
  887. L_SUBPIXEL_ORDER_RGB = 1, /* sensor order left-to-right RGB */
  888. L_SUBPIXEL_ORDER_BGR = 2, /* sensor order left-to-right BGR */
  889. L_SUBPIXEL_ORDER_VRGB = 3, /* sensor order top-to-bottom RGB */
  890. L_SUBPIXEL_ORDER_VBGR = 4 /* sensor order top-to-bottom BGR */
  891. };
  892. /*-------------------------------------------------------------------------*
  893. * HSV histogram flags *
  894. *-------------------------------------------------------------------------*/
  895. enum {
  896. L_HS_HISTO = 1, /* Use hue-saturation histogram */
  897. L_HV_HISTO = 2, /* Use hue-value histogram */
  898. L_SV_HISTO = 3 /* Use saturation-value histogram */
  899. };
  900. /*-------------------------------------------------------------------------*
  901. * Region flags (inclusion, exclusion) *
  902. *-------------------------------------------------------------------------*/
  903. enum {
  904. L_INCLUDE_REGION = 1, /* Use hue-saturation histogram */
  905. L_EXCLUDE_REGION = 2 /* Use hue-value histogram */
  906. };
  907. /*-------------------------------------------------------------------------*
  908. * Flags for adding text to a pix *
  909. *-------------------------------------------------------------------------*/
  910. enum {
  911. L_ADD_ABOVE = 1, /* Add text above the image */
  912. L_ADD_BELOW = 2, /* Add text below the image */
  913. L_ADD_LEFT = 3, /* Add text to the left of the image */
  914. L_ADD_RIGHT = 4, /* Add text to the right of the image */
  915. L_ADD_AT_TOP = 5, /* Add text over the top of the image */
  916. L_ADD_AT_BOT = 6, /* Add text over the bottom of the image */
  917. L_ADD_AT_LEFT = 7, /* Add text over left side of the image */
  918. L_ADD_AT_RIGHT = 8 /* Add text over right side of the image */
  919. };
  920. /*-------------------------------------------------------------------------*
  921. * Flags for plotting on a pix *
  922. *-------------------------------------------------------------------------*/
  923. enum {
  924. L_PLOT_AT_TOP = 1, /* Plot horizontally at top */
  925. L_PLOT_AT_MID_HORIZ = 2, /* Plot horizontally at middle */
  926. L_PLOT_AT_BOT = 3, /* Plot horizontally at bottom */
  927. L_PLOT_AT_LEFT = 4, /* Plot vertically at left */
  928. L_PLOT_AT_MID_VERT = 5, /* Plot vertically at middle */
  929. L_PLOT_AT_RIGHT = 6 /* Plot vertically at right */
  930. };
  931. /*-------------------------------------------------------------------------*
  932. * Flags for selecting display program *
  933. *-------------------------------------------------------------------------*/
  934. enum {
  935. L_DISPLAY_WITH_XZGV = 1, /* Use xzgv with pixDisplay() */
  936. L_DISPLAY_WITH_XLI = 2, /* Use xli with pixDisplay() */
  937. L_DISPLAY_WITH_XV = 3, /* Use xv with pixDisplay() */
  938. L_DISPLAY_WITH_IV = 4, /* Use irfvanview (win) with pixDisplay() */
  939. L_DISPLAY_WITH_OPEN = 5 /* Use open (apple) with pixDisplay() */
  940. };
  941. /*-------------------------------------------------------------------------*
  942. * Flag(s) used in the 'special' pix field for non-default operations *
  943. * - 0 is default *
  944. * - 10-19 are reserved for zlib compression in png write *
  945. *-------------------------------------------------------------------------*/
  946. enum {
  947. L_NO_CHROMA_SAMPLING_JPEG = 1 /* Write full resolution chroma */
  948. };
  949. /*-------------------------------------------------------------------------*
  950. * Handling negative values in conversion to unsigned int *
  951. *-------------------------------------------------------------------------*/
  952. enum {
  953. L_CLIP_TO_ZERO = 1, /* Clip negative values to 0 */
  954. L_TAKE_ABSVAL = 2 /* Convert to positive using L_ABS() */
  955. };
  956. /*-------------------------------------------------------------------------*
  957. * Relative to zero flags *
  958. *-------------------------------------------------------------------------*/
  959. enum {
  960. L_LESS_THAN_ZERO = 1, /* Choose values less than zero */
  961. L_EQUAL_TO_ZERO = 2, /* Choose values equal to zero */
  962. L_GREATER_THAN_ZERO = 3 /* Choose values greater than zero */
  963. };
  964. /*-------------------------------------------------------------------------*
  965. * Flags for adding or removing traling slash from string *
  966. *-------------------------------------------------------------------------*/
  967. enum {
  968. L_ADD_TRAIL_SLASH = 1, /* Add trailing slash to string */
  969. L_REMOVE_TRAIL_SLASH = 2 /* Remove trailing slash from string */
  970. };
  971. #endif /* LEPTONICA_PIX_H */