github.com/kaydxh/golang@v0.0.131/pkg/gocv/cgo/third_path/graphics-magick/include/GraphicsMagick/magick/blob.h (about) 1 /* 2 Copyright (C) 2003-2018 GraphicsMagick Group 3 Copyright (C) 2002 ImageMagick Studio 4 Copyright 1991-1999 E. I. du Pont de Nemours and Company 5 6 This program is covered by multiple licenses, which are described in 7 Copyright.txt. You should have received a copy of Copyright.txt with this 8 package; otherwise see http://www.graphicsmagick.org/www/Copyright.html. 9 10 Image Compression/Decompression Methods. 11 */ 12 #ifndef _MAGICK_BLOB_H 13 #define _MAGICK_BLOB_H 14 15 #if defined(__cplusplus) || defined(c_plusplus) 16 extern "C" { 17 #endif 18 19 #include "magick/image.h" 20 21 /* 22 Minimum input file size before considering for memory map. 23 */ 24 #define MinBlobExtent 32768L 25 26 /* 27 Forward declarations. 28 */ 29 typedef struct _BlobInfo BlobInfo; 30 31 /* 32 * 33 * BlobInfo methods 34 * 35 */ 36 37 /* 38 Makes a duplicate of the given blob info structure, or if blob info 39 is NULL, a new one. 40 */ 41 extern MagickExport BlobInfo* CloneBlobInfo(const BlobInfo *blob_info); 42 43 /* 44 Increments the reference count associated with the pixel blob, 45 returning a pointer to the blob. 46 */ 47 extern MagickExport BlobInfo* ReferenceBlob(BlobInfo *blob); 48 49 /* 50 Deallocate memory associated with the BlobInfo structure. 51 */ 52 extern MagickExport void DestroyBlobInfo(BlobInfo *blob) MAGICK_FUNC_DEPRECATED; 53 54 /* 55 If BLOB is a memory mapping then unmap it. Reset BlobInfo structure 56 to its default state. 57 */ 58 extern MagickExport void DetachBlob(BlobInfo *blob); 59 60 /* 61 Initialize a BlobInfo structure. 62 */ 63 extern MagickExport void GetBlobInfo(BlobInfo *blob); 64 65 /* 66 Attach memory buffer to a BlobInfo structure. 67 */ 68 extern MagickExport void AttachBlob(BlobInfo *blob_info, 69 const void *blob, 70 const size_t length); 71 72 /* 73 * 74 * Functions for managing a BLOB (type BlobInfo) attached to an Image. 75 * 76 */ 77 78 /* 79 Deallocate all memory associated with an Image blob (reference counted). 80 */ 81 extern MagickExport void DestroyBlob(Image *image); 82 83 84 /* 85 * 86 * Formatted image I/O functions 87 * 88 */ 89 90 /* 91 Read an Image from a formatted in-memory "file" image ("BLOB"). 92 */ 93 extern MagickExport Image* BlobToImage(const ImageInfo *image_info, 94 const void *blob, 95 const size_t length, 96 ExceptionInfo *exception); 97 98 /* 99 Return an Image populated with salient information regarding a 100 formatted in-memory "file" image ("BLOB") but without reading the 101 image pixels. 102 */ 103 extern MagickExport Image* PingBlob(const ImageInfo *image_info, 104 const void *blob, 105 const size_t length, 106 ExceptionInfo *exception); 107 108 /* 109 Writes an Image to a formatted (like a file) in-memory 110 representation. 111 */ 112 extern MagickExport void *ImageToBlob(const ImageInfo *image_info, 113 Image *image, 114 size_t *length, 115 ExceptionInfo *exception); 116 117 /* 118 * 119 * Core File or BLOB I/O functions. 120 * 121 */ 122 123 /* 124 Blob open modes. 125 */ 126 typedef enum 127 { 128 UndefinedBlobMode, /* Undefined */ 129 ReadBlobMode, /* Open for reading (text) */ /* only locale.c */ 130 ReadBinaryBlobMode, /* Open for reading (binary) */ 131 WriteBlobMode, /* Open for writing (text) */ /* only mvg.c txt.c */ 132 WriteBinaryBlobMode /* Open for writing (binary) */ 133 } BlobMode; 134 135 /* 136 Open an input or output stream for access. May also use a stream 137 provided via image_info->stream. 138 */ 139 extern MagickExport MagickPassFail OpenBlob(const ImageInfo *image_info, 140 Image *image, 141 const BlobMode mode, 142 ExceptionInfo *exception); 143 144 /* 145 Close I/O to the file or BLOB. 146 */ 147 extern MagickExport MagickPassFail CloseBlob(Image *image); 148 149 150 /* 151 Read data from the file or BLOB into a buffer. 152 */ 153 extern MagickExport size_t ReadBlob(Image *image, 154 const size_t length, 155 void *data); 156 157 /* 158 Read data from the file or BLOB into a buffer, but support zero-copy 159 if possible. 160 */ 161 extern MagickExport size_t ReadBlobZC(Image *image, 162 const size_t length, 163 void **data); 164 165 /* 166 Write data from a buffer to the file or BLOB. 167 */ 168 extern MagickExport size_t WriteBlob(Image *image, 169 const size_t length, 170 const void *data); 171 172 /* 173 Move the current read or write offset position in the file or BLOB. 174 */ 175 extern MagickExport magick_off_t SeekBlob(Image *image, 176 const magick_off_t offset, 177 const int whence); 178 179 /* 180 Obtain the current read or write offset position in the file or 181 BLOB. 182 */ 183 extern MagickExport magick_off_t TellBlob(const Image *image); 184 185 /* 186 Test to see if EOF has been detected while reading the file or BLOB. 187 */ 188 extern MagickExport int EOFBlob(const Image *image); 189 190 /* 191 Test to see if an error has been encountered while doing I/O to the file 192 or BLOB. Non-zero is returned if an error occured. 193 */ 194 extern MagickExport int GetBlobStatus(const Image *image) MAGICK_FUNC_PURE; 195 196 /* 197 Return the first errno present when an error has been encountered while 198 doing I/O to the file or BLOB. This is only useful if GetBlobStatus() has 199 already reported that an error occured. 200 */ 201 extern MagickExport int GetBlobFirstErrno(const Image *image) MAGICK_FUNC_PURE; 202 203 /* 204 Test to see if blob is currently open. 205 */ 206 extern MagickExport MagickBool GetBlobIsOpen(const Image *image) MAGICK_FUNC_PURE; 207 208 /* 209 Obtain the current size of the file or BLOB. Zero is returned if 210 the size can not be determined. If BLOB is no longer open, then 211 return the size when the BLOB was closed. 212 */ 213 extern MagickExport magick_off_t GetBlobSize(const Image *image); 214 215 216 /* 217 Obtain the underlying stdio FILE* for the file (if any). 218 */ 219 extern MagickExport FILE *GetBlobFileHandle(const Image *image) MAGICK_FUNC_PURE; 220 221 /* 222 Obtain a pointer to the base of where BLOB data is stored. The data 223 is only available if the data is stored on the heap, or is memory 224 mapped. Otherwise NULL is returned. 225 */ 226 extern MagickExport unsigned char *GetBlobStreamData(const Image *image) MAGICK_FUNC_PURE; 227 228 229 /* 230 * 231 * Formatted File or BLOB I/O functions. 232 * 233 */ 234 235 /* 236 Read a single byte from the file or BLOB. Returns an EOF character if EOF 237 has been detected. 238 */ 239 extern MagickExport int ReadBlobByte(Image *image); 240 241 /* 242 Read a 16-bit little-endian unsigned "short" value from the file or BLOB. 243 */ 244 extern MagickExport magick_uint16_t ReadBlobLSBShort(Image *image); 245 246 /* 247 Read a 16-bit little-endian signed "short" value from the file or BLOB. 248 */ 249 extern MagickExport magick_int16_t ReadBlobLSBSignedShort(Image *image); 250 251 /* 252 Read an array of little-endian unsigned 16-bit "short" values from the 253 file or BLOB. 254 */ 255 extern MagickExport size_t ReadBlobLSBShorts(Image *image, size_t octets, 256 magick_uint16_t *data); 257 258 /* 259 Read a 16-bit big-endian unsigned "short" value from the file or 260 BLOB. 261 */ 262 extern MagickExport magick_uint16_t ReadBlobMSBShort(Image *image); 263 264 /* 265 Read a 16-bit big-endian signed "short" value from the file or BLOB. 266 */ 267 extern MagickExport magick_int16_t ReadBlobMSBSignedShort(Image *image); 268 269 /* 270 Read an array of big-endian 16-bit "short" values from the file or BLOB. 271 */ 272 extern MagickExport size_t ReadBlobMSBShorts(Image *image, size_t octets, 273 magick_uint16_t *data); 274 275 /* 276 Read a 32-bit little-endian unsigned "long" value from the file or BLOB. 277 */ 278 extern MagickExport magick_uint32_t ReadBlobLSBLong(Image *image); 279 280 /* 281 Read a 32-bit little-endian signed "long" value from the file or BLOB. 282 */ 283 extern MagickExport magick_int32_t ReadBlobLSBSignedLong(Image *image); 284 285 /* 286 Read an array of little-endian 32-bit "long" values from the file or BLOB. 287 */ 288 extern MagickExport size_t ReadBlobLSBLongs(Image *image, size_t octets, 289 magick_uint32_t *data); 290 291 /* 292 Read a 32-bit big-endian unsigned "long" value from the file or BLOB. 293 */ 294 extern MagickExport magick_uint32_t ReadBlobMSBLong(Image *image); 295 296 /* 297 Read a 32-bit big-endian signed "long" value from the file or BLOB. 298 */ 299 extern MagickExport magick_int32_t ReadBlobMSBSignedLong(Image *image); 300 301 /* 302 Read an array of big-endian 32-bit "long" values from the file or BLOB. 303 */ 304 extern MagickExport size_t ReadBlobMSBLongs(Image *image, size_t octets, 305 magick_uint32_t *data); 306 307 /* 308 Read a little-endian 32-bit "float" value from the file or BLOB. 309 */ 310 extern MagickExport float ReadBlobLSBFloat(Image *image); 311 312 /* 313 Read an array of little-endian 32-bit "float" values from the file or 314 BLOB. 315 */ 316 extern MagickExport size_t ReadBlobLSBFloats(Image *image, size_t octets, 317 float *data); 318 319 /* 320 Read a big-endian 32-bit "float" value from the file or BLOB. 321 */ 322 extern MagickExport float ReadBlobMSBFloat(Image *image); 323 324 /* 325 Read an array of big-endian 32-bit "float" values from the file or BLOB. 326 */ 327 extern MagickExport size_t ReadBlobMSBFloats(Image *image, size_t octets, 328 float *data); 329 330 /* 331 Read a little-endian 64-bit "double" value from the file or BLOB. 332 */ 333 extern MagickExport double ReadBlobLSBDouble(Image *image); 334 335 /* 336 Read an array of little-endian 64-bit "double" values from the file or 337 BLOB. 338 */ 339 extern MagickExport size_t ReadBlobLSBDoubles(Image *image, size_t octets, 340 double *data); 341 342 /* 343 Read a big-endian 64-bit "double" value from the file or BLOB. 344 */ 345 extern MagickExport double ReadBlobMSBDouble(Image *image); 346 347 /* 348 Read an array of big-endian 64-bit "double" values from the file or BLOB. 349 */ 350 extern MagickExport size_t ReadBlobMSBDoubles(Image *image, size_t octets, 351 double *data); 352 353 /* 354 Read a string from the file or blob until a newline character is read or 355 an end-of-file condition is encountered. 356 */ 357 extern MagickExport char *ReadBlobString(Image *image, 358 char *string); 359 360 /* 361 Write a single byte to the file or BLOB. 362 */ 363 extern MagickExport size_t WriteBlobByte(Image *image, 364 const magick_uint8_t value); 365 366 /* 367 Write the content of an entire disk file to the file or BLOB. 368 */ 369 extern MagickExport MagickPassFail WriteBlobFile(Image *image, 370 const char *filename); 371 372 /* 373 Write a 16-bit signed "short" value to the file or BLOB in little-endian 374 order. 375 */ 376 extern MagickExport size_t WriteBlobLSBShort(Image *image, 377 const magick_uint16_t value); 378 379 /* 380 Write a 16-bit signed "short" value to the file or BLOB in little-endian 381 order. 382 */ 383 extern MagickExport size_t WriteBlobLSBSignedShort(Image *image, 384 const magick_int16_t value); 385 386 /* 387 Write a 32-bit unsigned "long" value to the file or BLOB in little-endian 388 order. 389 */ 390 extern MagickExport size_t WriteBlobLSBLong(Image *image, 391 const magick_uint32_t value); 392 393 /* 394 Write a 32-bit signed "long" value to the file or BLOB in little-endian 395 order. 396 */ 397 extern MagickExport size_t WriteBlobLSBSignedLong(Image *image, 398 const magick_int32_t value); 399 400 401 402 /* 403 Write a 32-bit unsigned "long" value to the file or BLOB in big-endian 404 order. 405 */ 406 extern MagickExport size_t WriteBlobMSBLong(Image *image, 407 const magick_uint32_t value); 408 409 /* 410 Write a 32-bit signed "long" value to the file or BLOB in big-endian 411 order. 412 */ 413 extern MagickExport size_t WriteBlobMSBSignedLong(Image *image, 414 const magick_int32_t value); 415 416 /* 417 Write a 16-bit unsigned "short" value to the file or BLOB in big-endian 418 order. 419 */ 420 extern MagickExport size_t WriteBlobMSBShort(Image *image, 421 const magick_uint16_t value); 422 423 /* 424 Write a 16-bit signed "short" value to the file or BLOB in big-endian 425 order. 426 */ 427 extern MagickExport size_t WriteBlobMSBSignedShort(Image *image, 428 const magick_int16_t value); 429 430 /* 431 Write a C string to the file or BLOB, without the terminating NULL byte. 432 */ 433 extern MagickExport size_t WriteBlobString(Image *image, 434 const char *string); 435 436 /* 437 * 438 * BLOB attribute access. 439 * 440 */ 441 442 /* 443 Blob supports seek operations. BlobSeek() and BlobTell() may safely be 444 used. 445 */ 446 extern MagickExport MagickBool BlobIsSeekable(const Image *image) MAGICK_FUNC_PURE; 447 448 /* 449 Allow file descriptor to be closed (if True). 450 */ 451 extern MagickExport void SetBlobClosable(Image *image, 452 MagickBool closable); 453 454 /* 455 Blob is for a temporary file which should be deleted (if True). 456 */ 457 extern MagickExport void SetBlobTemporary(Image *image, 458 MagickBool isTemporary); 459 460 /* 461 Returns MagickTrue if the file associated with the blob is a temporary 462 file and should be removed when the associated image is destroyed. 463 */ 464 extern MagickExport MagickBool GetBlobTemporary(const Image *image) MAGICK_FUNC_PURE; 465 466 /* 467 * 468 * Memory mapped file support. 469 * 470 */ 471 472 /* 473 Memory mapping modes. 474 */ 475 typedef enum 476 { 477 ReadMode, /* Map for read-only access */ 478 WriteMode, /* Map for write-only access (useless) */ 479 IOMode /* Map for read/write access */ 480 } MapMode; 481 482 /* 483 Release memory mapping for a region. 484 */ 485 extern MagickExport MagickPassFail UnmapBlob(void *map, 486 const size_t length); 487 488 /* 489 Perform a requested memory mapping of a file descriptor. 490 */ 491 extern MagickExport void *MapBlob(int file, 492 const MapMode mode, 493 magick_off_t offset, 494 size_t length); 495 496 /* 497 * 498 * Buffer to File / File to Buffer functions. 499 * 500 */ 501 502 /* 503 Writes a buffer to a named file. 504 */ 505 extern MagickExport MagickPassFail BlobToFile(const char *filename, 506 const void *blob, 507 const size_t length, 508 ExceptionInfo *exception); 509 510 /* 511 Read the contents of a file into memory. 512 */ 513 extern MagickExport void *FileToBlob(const char *filename, 514 size_t *length, 515 ExceptionInfo *exception); 516 517 /* 518 * 519 * Junk yet to be categorized. 520 * 521 */ 522 523 /* 524 Reserve space for a specified output size. 525 */ 526 extern MagickExport MagickPassFail BlobReserveSize(Image *image, magick_off_t size); 527 528 /* 529 Copies data from the input stream to a file. Useful in case it is 530 necessary to perform seek operations on the input data. 531 */ 532 extern MagickExport MagickPassFail ImageToFile(Image *image, 533 const char *filename, 534 ExceptionInfo *exception); 535 536 /* 537 Search for a configuration file (".mgk" file) using appropriate 538 rules and return as an in-memory buffer. 539 */ 540 extern MagickExport void *GetConfigureBlob(const char *filename, 541 char *path, 542 size_t *length, 543 ExceptionInfo *exception); 544 545 /* 546 Converts a least-significant byte first buffer of integers to 547 most-significant byte first. 548 */ 549 extern MagickExport void MSBOrderLong(unsigned char *buffer, 550 const size_t length); 551 552 /* 553 Converts a least-significant byte first buffer of integers to 554 most-significant byte first. 555 */ 556 extern MagickExport void MSBOrderShort(unsigned char *p, 557 const size_t length); 558 559 /* 560 Checks if the blob of the specified image is referenced by other images. If 561 the reference count is higher then 1 a new blob is assigned to the image. 562 */ 563 extern MagickExport void DisassociateBlob(Image *); 564 565 #if defined(__cplusplus) || defined(c_plusplus) 566 } 567 #endif 568 569 #endif 570 571 /* 572 * Local Variables: 573 * mode: c 574 * c-basic-offset: 2 575 * fill-column: 78 576 * End: 577 */