Where Online Learning is simpler!
The C and C++ Include Header Files
cat -n /usr/include/python3.14/Imaging.h
1 /* 2 * The Python Imaging Library 3 * $Id$ 4 * 5 * declarations for the imaging core library 6 * 7 * Copyright (c) 1997-2005 by Secret Labs AB 8 * Copyright (c) 1995-2005 by Fredrik Lundh 9 * 10 * See the README file for information on usage and redistribution. 11 */ 12 13 #include "ImPlatform.h" 14 #include "Mode.h" 15 16 #if defined(__cplusplus) 17 extern "C" { 18 #endif 19 20 #ifndef M_PI 21 #define M_PI 3.1415926535897932384626433832795 22 #endif 23 24 #include "Arrow.h" 25 26 /* -------------------------------------------------------------------- */ 27 28 /* 29 * Image data organization: 30 * 31 * mode bytes byte order 32 * ------------------------------- 33 * 1 1 1 34 * L 1 L 35 * P 1 P 36 * I 4 I (32-bit integer, native byte order) 37 * F 4 F (32-bit IEEE float, native byte order) 38 * RGB 4 R, G, B, - 39 * RGBA 4 R, G, B, A 40 * CMYK 4 C, M, Y, K 41 * YCbCr 4 Y, Cb, Cr, - 42 * Lab 4 L, a, b, - 43 * 44 * experimental modes (incomplete): 45 * LA 4 L, -, -, A 46 * PA 4 P, -, -, A 47 * I;16 2 I (16-bit integer, native byte order) 48 * 49 * "P" is an 8-bit palette mode, which should be mapped through the 50 * palette member to get an output image. Check palette->mode to 51 * find the corresponding "real" mode. 52 * 53 * For information on how to access Imaging objects from your own C 54 * extensions, see http://www.effbot.org/zone/pil-extending.htm 55 */ 56 57 /* Handles */ 58 59 typedef struct ImagingMemoryInstance *Imaging; 60 61 typedef struct ImagingAccessInstance *ImagingAccess; 62 typedef struct ImagingHistogramInstance *ImagingHistogram; 63 typedef struct ImagingOutlineInstance *ImagingOutline; 64 typedef struct ImagingPaletteInstance *ImagingPalette; 65 66 /* handle magics (used with PyCapsule). */ 67 #define IMAGING_MAGIC "Pillow Imaging" 68 69 /* pixel types */ 70 #define IMAGING_TYPE_UINT8 0 71 #define IMAGING_TYPE_INT32 1 72 #define IMAGING_TYPE_FLOAT32 2 73 #define IMAGING_TYPE_SPECIAL 3 /* check mode for details */ 74 75 typedef struct { 76 char *ptr; 77 int size; 78 } ImagingMemoryBlock; 79 80 struct ImagingMemoryInstance { 81 /* Format */ 82 ModeID mode; /* Image mode (IMAGING_MODE_*) */ 83 int type; /* Data type (IMAGING_TYPE_*) */ 84 int depth; /* Depth (ignored in this version) */ 85 int bands; /* Number of bands (1, 2, 3, or 4) */ 86 int xsize; /* Image dimension. */ 87 int ysize; 88 89 /* Colour palette (for "P" images only) */ 90 ImagingPalette palette; 91 92 /* Data pointers */ 93 UINT8 **image8; /* Set for 8-bit images (pixelsize=1). */ 94 INT32 **image32; /* Set for 32-bit images (pixelsize=4). */ 95 96 /* Internals */ 97 char **image; /* Actual raster data. */ 98 char *block; /* Set if data is allocated in a single block. */ 99 ImagingMemoryBlock *blocks; /* Memory blocks for pixel storage */ 100 101 int pixelsize; /* Size of a pixel, in bytes (1, 2 or 4) */ 102 int linesize; /* Size of a line, in bytes (xsize * pixelsize) */ 103 104 /* Virtual methods */ 105 void (*destroy)(Imaging im); 106 107 /* arrow */ 108 int refcount; /* Number of arrow arrays that have been allocated */ 109 char band_names[4][3]; /* names of bands, max 2 char + null terminator */ 110 char arrow_band_format[2]; /* single character + null terminator */ 111 112 int read_only; /* flag for read-only. set for arrow borrowed arrays */ 113 PyObject *arrow_array_capsule; /* upstream arrow array source */ 114 115 int blocks_count; /* Number of blocks that have been allocated */ 116 int lines_per_block; /* Number of lines in a block have been allocated */ 117 118 #ifdef Py_GIL_DISABLED 119 PyMutex mutex; 120 #endif 121 }; 122 123 #define IMAGING_PIXEL_1(im, x, y) ((im)->image8[(y)][(x)]) 124 #define IMAGING_PIXEL_L(im, x, y) ((im)->image8[(y)][(x)]) 125 #define IMAGING_PIXEL_LA(im, x, y) ((im)->image[(y)][(x) * 4]) 126 #define IMAGING_PIXEL_P(im, x, y) ((im)->image8[(y)][(x)]) 127 #define IMAGING_PIXEL_PA(im, x, y) ((im)->image[(y)][(x) * 4]) 128 #define IMAGING_PIXEL_I(im, x, y) ((im)->image32[(y)][(x)]) 129 #define IMAGING_PIXEL_F(im, x, y) (((FLOAT32 *)(im)->image32[y])[x]) 130 #define IMAGING_PIXEL_RGB(im, x, y) ((im)->image[(y)][(x) * 4]) 131 #define IMAGING_PIXEL_RGBA(im, x, y) ((im)->image[(y)][(x) * 4]) 132 #define IMAGING_PIXEL_CMYK(im, x, y) ((im)->image[(y)][(x) * 4]) 133 #define IMAGING_PIXEL_YCbCr(im, x, y) ((im)->image[(y)][(x) * 4]) 134 135 #define IMAGING_PIXEL_UINT8(im, x, y) ((im)->image8[(y)][(x)]) 136 #define IMAGING_PIXEL_INT32(im, x, y) ((im)->image32[(y)][(x)]) 137 #define IMAGING_PIXEL_FLOAT32(im, x, y) (((FLOAT32 *)(im)->image32[y])[x]) 138 139 struct ImagingAccessInstance { 140 ModeID mode; 141 void (*get_pixel)(Imaging im, int x, int y, void *pixel); 142 void (*put_pixel)(Imaging im, int x, int y, const void *pixel); 143 }; 144 145 struct ImagingHistogramInstance { 146 /* Format */ 147 ModeID mode; /* Mode ID of corresponding source image */ 148 int bands; /* Number of bands (1, 2, 3, or 4) */ 149 150 /* Data */ 151 long *histogram; /* Histogram (bands*256 longs) */ 152 }; 153 154 struct ImagingPaletteInstance { 155 /* Format */ 156 ModeID mode; 157 158 /* Data */ 159 int size; 160 UINT8 palette[1024]; /* Palette data (same format as image data) */ 161 162 INT16 *cache; /* Palette cache (used for predefined palettes) */ 163 int keep_cache; /* This palette will be reused; keep cache */ 164 }; 165 166 typedef struct ImagingMemoryArena { 167 int alignment; /* Alignment in memory of each line of an image */ 168 int block_size; /* Preferred block size, bytes */ 169 int blocks_max; /* Maximum number of cached blocks */ 170 int blocks_cached; /* Current number of blocks not associated with images */ 171 ImagingMemoryBlock *blocks_pool; 172 int stats_new_count; /* Number of new allocated images */ 173 int stats_allocated_blocks; /* Number of allocated blocks */ 174 int stats_reused_blocks; /* Number of blocks which were retrieved from a pool */ 175 int stats_reallocated_blocks; /* Number of blocks which were actually reallocated 176 after retrieving */ 177 int stats_freed_blocks; /* Number of freed blocks */ 178 int use_block_allocator; /* don't use arena, use block allocator */ 179 #ifdef Py_GIL_DISABLED 180 PyMutex mutex; 181 #endif 182 } *ImagingMemoryArena; 183 184 /* Objects */ 185 /* ------- */ 186 187 extern struct ImagingMemoryArena ImagingDefaultArena; 188 extern int 189 ImagingMemorySetBlocksMax(ImagingMemoryArena arena, int blocks_max); 190 extern void 191 ImagingMemoryClearCache(ImagingMemoryArena arena, int new_size); 192 extern void 193 ImagingMemorySetBlockAllocator(ImagingMemoryArena arena, int use_block_allocator); 194 195 extern Imaging 196 ImagingNew(ModeID mode, int xsize, int ysize); 197 extern Imaging 198 ImagingNewDirty(ModeID mode, int xsize, int ysize); 199 extern Imaging 200 ImagingNew2Dirty(ModeID mode, Imaging imOut, Imaging imIn); 201 extern void 202 ImagingDelete(Imaging im); 203 204 extern Imaging 205 ImagingNewBlock(ModeID mode, int xsize, int ysize); 206 207 extern Imaging 208 ImagingNewArrow( 209 const ModeID mode, 210 int xsize, 211 int ysize, 212 PyObject *schema_capsule, 213 PyObject *array_capsule 214 ); 215 216 extern Imaging 217 ImagingNewPrologue(ModeID mode, int xsize, int ysize); 218 extern Imaging 219 ImagingNewPrologueSubtype(ModeID mode, int xsize, int ysize, int structure_size); 220 221 extern void 222 ImagingCopyPalette(Imaging destination, Imaging source); 223 224 extern void 225 ImagingHistogramDelete(ImagingHistogram histogram); 226 227 extern ImagingAccess 228 ImagingAccessNew(Imaging im); 229 extern void 230 _ImagingAccessDelete(Imaging im, ImagingAccess access); 231 #define ImagingAccessDelete(im, access) /* nop, for now */ 232 233 extern ImagingPalette 234 ImagingPaletteNew(ModeID mode); 235 extern ImagingPalette 236 ImagingPaletteNewBrowser(void); 237 extern ImagingPalette 238 ImagingPaletteDuplicate(ImagingPalette palette); 239 extern void 240 ImagingPaletteDelete(ImagingPalette palette); 241 242 extern int 243 ImagingPaletteCachePrepare(ImagingPalette palette); 244 extern void 245 ImagingPaletteCacheUpdate(ImagingPalette palette, int r, int g, int b); 246 extern void 247 ImagingPaletteCacheDelete(ImagingPalette palette); 248 249 #define ImagingPaletteCache(p, r, g, b) \ 250 p->cache[(r >> 2) + (g >> 2) * 64 + (b >> 2) * 64 * 64] 251 252 extern Imaging 253 ImagingQuantize(Imaging im, int colours, int mode, int kmeans); 254 255 /* Threading */ 256 /* --------- */ 257 258 typedef void *ImagingSectionCookie; 259 260 extern void 261 ImagingSectionEnter(ImagingSectionCookie *cookie); 262 extern void 263 ImagingSectionLeave(ImagingSectionCookie *cookie); 264 265 /* Exceptions */ 266 /* ---------- */ 267 268 extern void * 269 ImagingError_MemoryError(void); 270 extern void * 271 ImagingError_ModeError(void); /* maps to ValueError by default */ 272 extern void * 273 ImagingError_Mismatch(void); /* maps to ValueError by default */ 274 extern void * 275 ImagingError_ValueError(const char *message); 276 277 /* Transform callbacks */ 278 /* ------------------- */ 279 280 /* standard transforms */ 281 #define IMAGING_TRANSFORM_AFFINE 0 282 #define IMAGING_TRANSFORM_PERSPECTIVE 2 283 #define IMAGING_TRANSFORM_QUAD 3 284 285 /* standard filters */ 286 #define IMAGING_TRANSFORM_NEAREST 0 287 #define IMAGING_TRANSFORM_BOX 4 288 #define IMAGING_TRANSFORM_BILINEAR 2 289 #define IMAGING_TRANSFORM_HAMMING 5 290 #define IMAGING_TRANSFORM_BICUBIC 3 291 #define IMAGING_TRANSFORM_LANCZOS 1 292 293 typedef int (*ImagingTransformMap)(double *X, double *Y, int x, int y, void *data); 294 typedef int (*ImagingTransformFilter)(void *out, Imaging im, double x, double y); 295 296 /* Image Manipulation Methods */ 297 /* -------------------------- */ 298 299 extern Imaging 300 ImagingAlphaComposite(Imaging imIn1, Imaging imIn2); 301 extern Imaging 302 ImagingBlend(Imaging imIn1, Imaging imIn2, float alpha); 303 extern Imaging 304 ImagingCopy(Imaging im); 305 extern Imaging 306 ImagingConvert(Imaging im, ModeID mode, ImagingPalette palette, int dither); 307 extern Imaging 308 ImagingConvertInPlace(Imaging im, ModeID mode); 309 extern Imaging 310 ImagingConvertMatrix(Imaging im, ModeID mode, float m[]); 311 extern Imaging 312 ImagingConvertTransparent(Imaging im, ModeID mode, int r, int g, int b); 313 extern Imaging 314 ImagingCrop(Imaging im, int x0, int y0, int x1, int y1); 315 extern Imaging 316 ImagingExpand(Imaging im, int x, int y); 317 extern Imaging 318 ImagingFill(Imaging im, const void *ink); 319 extern int 320 ImagingFill2( 321 Imaging into, const void *ink, Imaging mask, int x0, int y0, int x1, int y1 322 ); 323 extern Imaging 324 ImagingFillBand(Imaging im, int band, int color); 325 extern Imaging 326 ImagingFillLinearGradient(ModeID mode); 327 extern Imaging 328 ImagingFillRadialGradient(ModeID mode); 329 extern Imaging 330 ImagingFilter(Imaging im, int xsize, int ysize, const FLOAT32 *kernel, FLOAT32 offset); 331 extern Imaging 332 ImagingFlipLeftRight(Imaging imOut, Imaging imIn); 333 extern Imaging 334 ImagingFlipTopBottom(Imaging imOut, Imaging imIn); 335 extern Imaging 336 ImagingGaussianBlur( 337 Imaging imOut, Imaging imIn, float xradius, float yradius, int passes 338 ); 339 extern Imaging 340 ImagingGetBand(Imaging im, int band); 341 extern Imaging 342 ImagingMerge(ModeID mode, Imaging bands[4]); 343 extern int 344 ImagingSplit(Imaging im, Imaging bands[4]); 345 extern int 346 ImagingGetBBox(Imaging im, int bbox[4], int alpha_only); 347 typedef struct { 348 int x, y; 349 INT32 count; 350 INT32 pixel; 351 } ImagingColorItem; 352 extern ImagingColorItem * 353 ImagingGetColors(Imaging im, int maxcolors, int *colors); 354 extern int 355 ImagingGetExtrema(Imaging im, void *extrema); 356 extern int 357 ImagingGetProjection(Imaging im, UINT8 *xproj, UINT8 *yproj); 358 extern ImagingHistogram 359 ImagingGetHistogram(Imaging im, Imaging mask, void *extrema); 360 extern Imaging 361 ImagingModeFilter(Imaging im, int size); 362 extern Imaging 363 ImagingNegative(Imaging im); 364 extern Imaging 365 ImagingOffset(Imaging im, int xoffset, int yoffset); 366 extern int 367 ImagingPaste(Imaging into, Imaging im, Imaging mask, int x0, int y0, int x1, int y1); 368 extern Imaging 369 ImagingPoint(Imaging im, ModeID tablemode, const void *table); 370 extern Imaging 371 ImagingPointTransform(Imaging imIn, double scale, double offset); 372 extern Imaging 373 ImagingPutBand(Imaging im, Imaging imIn, int band); 374 extern Imaging 375 ImagingRankFilter(Imaging im, int size, int rank); 376 extern Imaging 377 ImagingRotate90(Imaging imOut, Imaging imIn); 378 extern Imaging 379 ImagingRotate180(Imaging imOut, Imaging imIn); 380 extern Imaging 381 ImagingRotate270(Imaging imOut, Imaging imIn); 382 extern Imaging 383 ImagingTranspose(Imaging imOut, Imaging imIn); 384 extern Imaging 385 ImagingTransverse(Imaging imOut, Imaging imIn); 386 extern Imaging 387 ImagingResample(Imaging imIn, int xsize, int ysize, int filter, float box[4]); 388 extern Imaging 389 ImagingReduce(Imaging imIn, int xscale, int yscale, int box[4]); 390 extern Imaging 391 ImagingTransform( 392 Imaging imOut, 393 Imaging imIn, 394 int method, 395 int x0, 396 int y0, 397 int x1, 398 int y1, 399 double a[8], 400 int filter, 401 int fill 402 ); 403 extern Imaging 404 ImagingUnsharpMask(Imaging imOut, Imaging im, float radius, int percent, int threshold); 405 extern Imaging 406 ImagingBoxBlur(Imaging imOut, Imaging imIn, float xradius, float yradius, int n); 407 extern Imaging 408 ImagingColorLUT3D_linear( 409 Imaging imOut, 410 Imaging imIn, 411 int table_channels, 412 int size1D, 413 int size2D, 414 int size3D, 415 INT16 *table 416 ); 417 418 extern Imaging 419 ImagingCopy2(Imaging imOut, Imaging imIn); 420 extern Imaging 421 ImagingConvert2(Imaging imOut, Imaging imIn); 422 423 /* Channel operations */ 424 /* any mode, except "F" */ 425 extern Imaging 426 ImagingChopLighter(Imaging imIn1, Imaging imIn2); 427 extern Imaging 428 ImagingChopDarker(Imaging imIn1, Imaging imIn2); 429 extern Imaging 430 ImagingChopDifference(Imaging imIn1, Imaging imIn2); 431 extern Imaging 432 ImagingChopMultiply(Imaging imIn1, Imaging imIn2); 433 extern Imaging 434 ImagingChopScreen(Imaging imIn1, Imaging imIn2); 435 extern Imaging 436 ImagingChopAdd(Imaging imIn1, Imaging imIn2, float scale, int offset); 437 extern Imaging 438 ImagingChopSubtract(Imaging imIn1, Imaging imIn2, float scale, int offset); 439 extern Imaging 440 ImagingChopAddModulo(Imaging imIn1, Imaging imIn2); 441 extern Imaging 442 ImagingChopSubtractModulo(Imaging imIn1, Imaging imIn2); 443 extern Imaging 444 ImagingChopSoftLight(Imaging imIn1, Imaging imIn2); 445 extern Imaging 446 ImagingChopHardLight(Imaging imIn1, Imaging imIn2); 447 extern Imaging 448 ImagingOverlay(Imaging imIn1, Imaging imIn2); 449 450 /* "1" images only */ 451 extern Imaging 452 ImagingChopAnd(Imaging imIn1, Imaging imIn2); 453 extern Imaging 454 ImagingChopOr(Imaging imIn1, Imaging imIn2); 455 extern Imaging 456 ImagingChopXor(Imaging imIn1, Imaging imIn2); 457 458 /* Graphics */ 459 extern int 460 ImagingDrawArc( 461 Imaging im, 462 int x0, 463 int y0, 464 int x1, 465 int y1, 466 float start, 467 float end, 468 const void *ink, 469 int width, 470 int op 471 ); 472 extern int 473 ImagingDrawBitmap(Imaging im, int x0, int y0, Imaging bitmap, const void *ink, int op); 474 extern int 475 ImagingDrawChord( 476 Imaging im, 477 int x0, 478 int y0, 479 int x1, 480 int y1, 481 float start, 482 float end, 483 const void *ink, 484 int fill, 485 int width, 486 int op 487 ); 488 extern int 489 ImagingDrawEllipse( 490 Imaging im, 491 int x0, 492 int y0, 493 int x1, 494 int y1, 495 const void *ink, 496 int fill, 497 int width, 498 int op 499 ); 500 extern int 501 ImagingDrawLine(Imaging im, int x0, int y0, int x1, int y1, const void *ink, int op); 502 extern int 503 ImagingDrawWideLine( 504 Imaging im, 505 int x0, 506 int y0, 507 int x1, 508 int y1, 509 const void *ink, 510 int width, 511 int op, 512 Imaging mask 513 ); 514 extern int 515 ImagingDrawPieslice( 516 Imaging im, 517 int x0, 518 int y0, 519 int x1, 520 int y1, 521 float start, 522 float end, 523 const void *ink, 524 int fill, 525 int width, 526 int op 527 ); 528 extern int 529 ImagingDrawPoint(Imaging im, int x, int y, const void *ink, int op); 530 extern int 531 ImagingDrawPolygon( 532 Imaging im, 533 int points, 534 int *xy, 535 const void *ink, 536 int fill, 537 int width, 538 int op, 539 Imaging mask 540 ); 541 extern int 542 ImagingDrawRectangle( 543 Imaging im, 544 int x0, 545 int y0, 546 int x1, 547 int y1, 548 const void *ink, 549 int fill, 550 int width, 551 int op 552 ); 553 554 /* Level 2 graphics (WORK IN PROGRESS) */ 555 extern ImagingOutline 556 ImagingOutlineNew(void); 557 extern void 558 ImagingOutlineDelete(ImagingOutline outline); 559 560 extern int 561 ImagingDrawOutline( 562 Imaging im, ImagingOutline outline, const void *ink, int fill, int op 563 ); 564 565 extern int 566 ImagingOutlineMove(ImagingOutline outline, float x, float y); 567 extern int 568 ImagingOutlineLine(ImagingOutline outline, float x, float y); 569 extern int 570 ImagingOutlineCurve( 571 ImagingOutline outline, float x1, float y1, float x2, float y2, float x3, float y3 572 ); 573 extern int 574 ImagingOutlineTransform(ImagingOutline outline, double a[6]); 575 576 extern int 577 ImagingOutlineClose(ImagingOutline outline); 578 579 /* Special effects */ 580 extern Imaging 581 ImagingEffectSpread(Imaging imIn, int distance); 582 extern Imaging 583 ImagingEffectNoise(int xsize, int ysize, float sigma); 584 extern Imaging 585 ImagingEffectMandelbrot(int xsize, int ysize, double extent[4], int quality); 586 587 /* File I/O */ 588 /* -------- */ 589 590 /* Built-in drivers */ 591 extern Imaging 592 ImagingOpenPPM(const char *filename); 593 extern int 594 ImagingSavePPM(Imaging im, const char *filename); 595 596 /* Codecs */ 597 typedef struct ImagingCodecStateInstance *ImagingCodecState; 598 typedef int (*ImagingCodec)( 599 Imaging im, ImagingCodecState state, UINT8 *buffer, int bytes 600 ); 601 602 extern int 603 ImagingBcnDecode(Imaging im, ImagingCodecState state, UINT8 *buffer, Py_ssize_t bytes); 604 extern int 605 ImagingBcnEncode(Imaging im, ImagingCodecState state, UINT8 *buffer, int bytes); 606 extern int 607 ImagingBitDecode(Imaging im, ImagingCodecState state, UINT8 *buffer, Py_ssize_t bytes); 608 extern int 609 ImagingEpsEncode(Imaging im, ImagingCodecState state, UINT8 *buffer, int bytes); 610 extern int 611 ImagingFliDecode(Imaging im, ImagingCodecState state, UINT8 *buffer, Py_ssize_t bytes); 612 extern int 613 ImagingGifDecode(Imaging im, ImagingCodecState state, UINT8 *buffer, Py_ssize_t bytes); 614 extern int 615 ImagingGifEncode(Imaging im, ImagingCodecState state, UINT8 *buffer, int bytes); 616 extern int 617 ImagingHexDecode(Imaging im, ImagingCodecState state, UINT8 *buffer, Py_ssize_t bytes); 618 #ifdef HAVE_LIBJPEG 619 extern int 620 ImagingJpegDecode(Imaging im, ImagingCodecState state, UINT8 *buffer, Py_ssize_t bytes); 621 extern int 622 ImagingJpegDecodeCleanup(ImagingCodecState state); 623 extern int 624 ImagingJpegUseJCSExtensions(void); 625 626 extern int 627 ImagingJpegEncode(Imaging im, ImagingCodecState state, UINT8 *buffer, int bytes); 628 #endif 629 #ifdef HAVE_OPENJPEG 630 extern int 631 ImagingJpeg2KDecode( 632 Imaging im, ImagingCodecState state, UINT8 *buffer, Py_ssize_t bytes 633 ); 634 extern int 635 ImagingJpeg2KDecodeCleanup(ImagingCodecState state); 636 extern int 637 ImagingJpeg2KEncode(Imaging im, ImagingCodecState state, UINT8 *buffer, int bytes); 638 extern int 639 ImagingJpeg2KEncodeCleanup(ImagingCodecState state); 640 #endif 641 #ifdef HAVE_LIBTIFF 642 extern int 643 ImagingLibTiffDecode( 644 Imaging im, ImagingCodecState state, UINT8 *buffer, Py_ssize_t bytes 645 ); 646 extern int 647 ImagingLibTiffEncode(Imaging im, ImagingCodecState state, UINT8 *buffer, int bytes); 648 #endif 649 extern int 650 ImagingMspDecode(Imaging im, ImagingCodecState state, UINT8 *buffer, Py_ssize_t bytes); 651 extern int 652 ImagingPackbitsDecode( 653 Imaging im, ImagingCodecState state, UINT8 *buffer, Py_ssize_t bytes 654 ); 655 extern int 656 ImagingPcdDecode(Imaging im, ImagingCodecState state, UINT8 *buffer, Py_ssize_t bytes); 657 extern int 658 ImagingPcxDecode(Imaging im, ImagingCodecState state, UINT8 *buffer, Py_ssize_t bytes); 659 extern int 660 ImagingPcxEncode(Imaging im, ImagingCodecState state, UINT8 *buffer, int bytes); 661 extern int 662 ImagingRawDecode(Imaging im, ImagingCodecState state, UINT8 *buffer, Py_ssize_t bytes); 663 extern int 664 ImagingRawEncode(Imaging im, ImagingCodecState state, UINT8 *buffer, int bytes); 665 extern int 666 ImagingSgiRleDecode( 667 Imaging im, ImagingCodecState state, UINT8 *buffer, Py_ssize_t bytes 668 ); 669 extern int 670 ImagingSunRleDecode( 671 Imaging im, ImagingCodecState state, UINT8 *buffer, Py_ssize_t bytes 672 ); 673 extern int 674 ImagingTgaRleDecode( 675 Imaging im, ImagingCodecState state, UINT8 *buffer, Py_ssize_t bytes 676 ); 677 extern int 678 ImagingTgaRleEncode(Imaging im, ImagingCodecState state, UINT8 *buffer, int bytes); 679 extern int 680 ImagingXbmDecode(Imaging im, ImagingCodecState state, UINT8 *buffer, Py_ssize_t bytes); 681 extern int 682 ImagingXbmEncode(Imaging im, ImagingCodecState state, UINT8 *buffer, int bytes); 683 #ifdef HAVE_LIBZ 684 extern int 685 ImagingZipDecode(Imaging im, ImagingCodecState state, UINT8 *buffer, Py_ssize_t bytes); 686 extern int 687 ImagingZipDecodeCleanup(ImagingCodecState state); 688 extern int 689 ImagingZipEncode(Imaging im, ImagingCodecState state, UINT8 *buffer, int bytes); 690 extern int 691 ImagingZipEncodeCleanup(ImagingCodecState state); 692 #endif 693 694 typedef void (*ImagingShuffler)(UINT8 *out, const UINT8 *in, int pixels); 695 696 /* Public shufflers */ 697 extern void 698 ImagingPackBGR(UINT8 *out, const UINT8 *in, int pixels); 699 extern void 700 ImagingUnpackYCC(UINT8 *out, const UINT8 *in, int pixels); 701 extern void 702 ImagingUnpackYCCA(UINT8 *out, const UINT8 *in, int pixels); 703 704 extern void 705 ImagingConvertRGB2YCbCr(UINT8 *out, const UINT8 *in, int pixels); 706 extern void 707 ImagingConvertYCbCr2RGB(UINT8 *out, const UINT8 *in, int pixels); 708 709 extern ImagingShuffler 710 ImagingFindUnpacker(ModeID mode, RawModeID rawmode, int *bits_out); 711 extern ImagingShuffler 712 ImagingFindPacker(ModeID mode, RawModeID rawmode, int *bits_out); 713 714 struct ImagingCodecStateInstance { 715 int count; 716 int state; 717 int errcode; 718 int x, y; 719 int ystep; 720 int xsize, ysize, xoff, yoff; 721 ImagingShuffler shuffle; 722 int bits, bytes; 723 UINT8 *buffer; 724 void *context; 725 PyObject *fd; 726 }; 727 728 /* Codec read/write python fd */ 729 extern Py_ssize_t 730 _imaging_read_pyFd(PyObject *fd, char *dest, Py_ssize_t bytes); 731 extern Py_ssize_t 732 _imaging_write_pyFd(PyObject *fd, char *src, Py_ssize_t bytes); 733 extern int 734 _imaging_seek_pyFd(PyObject *fd, Py_ssize_t offset, int whence); 735 extern Py_ssize_t 736 _imaging_tell_pyFd(PyObject *fd); 737 738 /* Arrow */ 739 740 extern int 741 export_imaging_array(Imaging im, struct ArrowArray *array); 742 extern int 743 export_imaging_schema(Imaging im, struct ArrowSchema *schema); 744 745 /* Errcodes */ 746 #define IMAGING_CODEC_END 1 747 #define IMAGING_CODEC_OVERRUN -1 748 #define IMAGING_CODEC_BROKEN -2 749 #define IMAGING_CODEC_UNKNOWN -3 750 #define IMAGING_CODEC_CONFIG -8 751 #define IMAGING_CODEC_MEMORY -9 752 #define IMAGING_ARROW_INCOMPATIBLE_MODE -10 753 #define IMAGING_ARROW_MEMORY_LAYOUT -11 754 755 #include "ImagingUtils.h" 756 extern UINT8 *clip8_lookups; 757 758 /* Mutex lock/unlock helpers */ 759 #ifdef Py_GIL_DISABLED 760 #define MUTEX_LOCK(m) PyMutex_Lock(m) 761 #define MUTEX_UNLOCK(m) PyMutex_Unlock(m) 762 #else 763 #define MUTEX_LOCK(m) 764 #define MUTEX_UNLOCK(m) 765 #endif 766 767 #if defined(__cplusplus) 768 } 769 #endif