-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathfpxlib.h
More file actions
2166 lines (1720 loc) · 61.4 KB
/
fpxlib.h
File metadata and controls
2166 lines (1720 loc) · 61.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* FPXLib.h
*
* FlashPix Library API
*/
/****************************************************************************/
#ifndef FPXLibAPI_h
#define FPXLibAPI_h
/****************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
#include <inttypes.h>
#include <stddef.h>
typedef struct IStream IStream;
typedef struct IStorage IStorage;
typedef struct _XGUID
{
uint32_t Data1;
uint16_t Data2;
uint16_t Data3;
uint8_t Data4[8];
} XGUID, GUID, CLSID, IID;
#ifndef FARSTRUCT
#define FARSTRUCT
#endif
#ifndef __RPC_FAR
#define __RPC_FAR
#endif
typedef struct tagCLIPDATA {
uint32_t cbSize;
int32_t ulClipFmt;
uint8_t __RPC_FAR *pClipData;
} CLIPDATA;
#if !defined(WCHAR) && !defined(__BORLANDC__)
typedef uint16_t WCHAR;
typedef WCHAR *LPWSTR;
#endif
typedef uint16_t WORD;
typedef uint32_t DWORD;
/***************************************************************************
TOOLKIT HANDLE
***************************************************************************/
#ifdef __cplusplus
typedef class PFlashPixImageView FPXImageHandle;
#else
typedef struct PFlashPixImageView FPXImageHandle;
#endif
/****************************************************************************
BASIC TYPEDEFS
****************************************************************************/
typedef uint8_t FPXbool;
typedef struct {
size_t length; /* number of chars */
uint8_t *ptr;
} FPXStr;
typedef struct {
size_t length; /* number of shorts */
uint16_t *ptr;
} FPXShortArray;
typedef struct FPXLongArray {
size_t length; /* number of longs */
uint32_t *ptr;
} FPXLongArray;
typedef struct {
size_t length; /* number of reals */
float *ptr;
} FPXRealArray;
typedef struct FPXWideStr {
size_t length; /* length of string off ptr in bytes */
uint16_t *ptr; /* Inside fpxlib wchar_t is 2-bytes XXX */
} FPXWideStr;
typedef struct {
size_t length; /* number of strings */
FPXStr *ptr;
} FPXStrArray;
typedef struct {
size_t length; /* number of wide strings */
FPXWideStr *ptr;
} FPXWideStrArray;
typedef struct {
size_t length; /* number of strings */
CLSID *ptr;
} FPXClsIDArray;
#if !defined(WIN32)
typedef struct FARSTRUCT tagFILETIME
{
DWORD dwLowDateTime;
DWORD dwHighDateTime;
} FILETIME;
#endif
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
typedef FILETIME FPXfiletime; /* cf. OLE FILETIME in compobj.h */
#ifndef DATE
typedef double DATE;
#endif
/****************************************************************************
TOOLKIT ERROR CODES
****************************************************************************/
typedef enum {
FPX_OK = 0,
FPX_INVALID_FORMAT_ERROR = 1,
FPX_FILE_WRITE_ERROR = 2,
FPX_FILE_READ_ERROR = 3,
FPX_FILE_NOT_FOUND = 4,
FPX_COLOR_CONVERSION_ERROR = 5,
FPX_SEVER_INIT_ERROR = 6,
FPX_LOW_MEMORY_ERROR = 7,
FPX_IMAGE_TOO_BIG_ERROR = 8,
FPX_INVALID_COMPRESSION_ERROR = 9,
FPX_INVALID_RESOLUTION = 10,
FPX_INVALID_FPX_HANDLE = 11,
FPX_TOO_MANY_LINES = 12,
FPX_BAD_COORDINATES = 13,
FPX_FILE_SYSTEM_FULL = 14,
FPX_MISSING_TABLE = 15,
FPX_RETURN_PARAMETER_TOO_LARGE = 16,
FPX_NOT_A_VIEW = 17,
FPX_VIEW_IS_TRANFORMLESS = 18,
FPX_ERROR = 19,
FPX_UNIMPLEMENTED_FUNCTION = 20,
FPX_INVALID_IMAGE_DESC = 21,
FPX_INVALID_JPEG_TABLE = 22,
FPX_ILLEGAL_JPEG_ID = 23,
FPX_MEMORY_ALLOCATION_FAILED = 24,
FPX_NO_MEMORY_MANAGEMENT = 25,
FPX_OBJECT_CREATION_FAILED = 26,
FPX_EXTENSION_FAILED = 27,
FPX_FREE_NULL_PTR = 28,
FPX_INVALID_TILE = 29,
FPX_FILE_IN_USE = 30,
FPX_FILE_CREATE_ERROR = 31,
FPX_FILE_NOT_OPEN_ERROR = 32,
FPX_USER_ABORT = 33,
FPX_OLE_FILE_ERROR = 34,
FPX_INVALID_PIXEL_FORMAT = 35,
FPX_MAX_KNOWN_ERROR, /* Insert subsequent codes above this one */
// Numbers above 1000 are reserved for warnings. When returning a warning, the
// function did something (default behavior) and it's safe for the application
// to move on. It's up to the application to display a warning message to the user.
FPX_W_COORDINATES_OUT_OF_RANGE = 1000
} FPXStatus;
FPXStatus FPX_GetErrorString (FPXStatus errorCode,
char *errorString,
unsigned short maxStrLen);
/*
* Some C functions to ease the usage of these structures.
*/
void FPXUpdateTime (FPXfiletime* theFPXTime);
void InitFPXStr (FPXStr* theFPXArray);
void InitFPXShortArray (FPXShortArray* theFPXArray);
void InitFPXLongArray (FPXLongArray* theFPXArray);
void InitFPXRealArray (FPXRealArray* theFPXArray);
void InitFPXWideStr (FPXWideStr* theFPXArray);
void InitFPXWideStrArray (FPXWideStrArray* theFPXArray);
void InitFPXStrArray (FPXStrArray* theFPXArray);
FPXStatus FPX_Strcpy (FPXStr* theFPXStr, const char* string);
FPXStatus FPX_WideStrcpy (FPXWideStr* theFPXStr, const char* string);
int FPX_WideStrcmp (const FPXWideStr* fpxWStr1, const FPXWideStr* fpxWStr2);
size_t FPX_LPWSTRlen (const WCHAR * wideStr);
FPXStatus FPX_DeleteFPXStr (FPXStr* theFPXArray);
FPXStatus FPX_DeleteFPXShortArray (FPXShortArray* theFPXArray);
FPXStatus FPX_DeleteFPXLongArray (FPXLongArray* theFPXArray);
FPXStatus FPX_DeleteFPXRealArray (FPXRealArray* theFPXArray);
FPXStatus FPX_DeleteFPXWideStr (FPXWideStr* theFPXArray);
FPXStatus FPX_DeleteFPXWideStrArray (FPXWideStrArray* theFPXArray);
FPXStatus FPX_DeleteFPXStrArray (FPXStrArray* theFPXArray);
FPXStatus FPX_AllocFPXStr (FPXStr* theFPXArray, unsigned int nbElem);
FPXStatus FPX_AllocFPXShortArray (FPXShortArray* theFPXArray, unsigned int nbElem);
FPXStatus FPX_AllocFPXLongArray (FPXLongArray* theFPXArray, unsigned int nbElem);
FPXStatus FPX_AllocFPXRealArray (FPXRealArray* theFPXArray, unsigned int nbElem);
FPXStatus FPX_AllocFPXWideStr (FPXWideStr* theFPXArray, unsigned int nbElem);
FPXStatus FPX_AllocFPXWideStrArray (FPXWideStrArray* theFPXArray, unsigned int nbElem);
FPXStatus FPX_AllocFPXStrArray (FPXStrArray* theFPXArray, unsigned int nbElem);
/****************************************************************************
TOOLKIT COMPRESSION CONTROL
***************************************************************************/
/* Desired compression style */
typedef enum {
NONE = 0, /* no compression used. */
SINGLE_COLOR = 1, /* use single color compression */
JPEG_UNSPECIFIED = 2, /* let the toolkit pick the tables. */
JPEG_BY_QUALITY = 3, /* we will specify the quality. */
JPEG_BY_TABLE_GROUP = 4 /* we will specify the table group to use */
} FPXCompressionOption;
/* A JPEG quantizer table
XXX Is it bigendian or little endian? JPEG byte order or host machine?
Probably should be in JPEG format.
Rem: unsigned short quantizer is large enough for non-baseline JPEG.
(16bit lossless)
*/
typedef struct {
unsigned char *bits;
unsigned char *vals;
unsigned char hclass; /* 0: DC, 1: AC */
unsigned char ident; /* 0,1,2,or 3 for extended JPEG systems */
/* 0, or 1 for baseline JPEG */
} FPXJPEGHUFFTable;
typedef struct {
unsigned char *quantizer; /* Table elements specified in zigzag order */
unsigned char ident; /* 0,1,2,3 */
} FPXJPEGQuantTable;
/* A JPEG abbreviated stream for table info.
XXX we will fill in the details later. It's basically a bunch of
overhead, bytes counts, Q tables, and H tables.
*/
#define FPX_MAX_TABLE_STREAM_SIZE 1400
typedef struct {
unsigned short theStreamSize;
unsigned char theStream[FPX_MAX_TABLE_STREAM_SIZE];
} FPXJPEGTableGroup;
/* Make a FPXJPEGTableGroup from a bunch of Q and H tables. */
/* Not all tables need be supplied. A NULL indicates such an omission. */
FPXStatus FPX_CreateJPEGTableGroup (
FPXJPEGTableGroup* theGroup,
short numOfQuanTable,
unsigned char * quanTableChanID,
FPXJPEGQuantTable* quanTable,
short numOfHuffTable,
unsigned char * huffDCTableChanID,
unsigned char * huffACTableChanID,
FPXJPEGHUFFTable* huffTable );
/***************************************************************************
TOOLKIT RESOLUTION CONTROL
***************************************************************************/
/* Number of levels in the pyramid and the compression used for each.
* This allows user control of the compression/quality on a per resolution
* basis during FPX file creation.
*/
#define FPXMAXRESOLUTIONS 29 /* 8x8 pixel tiles, 2^32 x 2^32 image */
/* Control the compression on a per resolution basis. */
typedef struct {
FPXCompressionOption compressOption;
unsigned char compressQuality;
unsigned char compressTableGroup;
} FPXPerResolutionControl;
typedef struct {
short numberOfResolutions;
FPXPerResolutionControl compressionControl[FPXMAXRESOLUTIONS];
} FPXResolution;
/***************************************************************************
TOOLKIT IMAGE COMPONENT COLORS/ORGANIZATIONS
***************************************************************************/
/* Some FPX defined colors for components.
*
* Whenever an alpha channel is seen, the other channels are assumed to
* be premultiplied by it. When an opacity of 0 (transparent) is seen
* in the alpha channel, the toolkit will NOT automatically insert chroma
* channels that are equal to the known background color, when either
* reading or writing FPX images. This work is left to the application and
* is not considered a function of the toolkit.
*/
typedef enum { PHOTO_YCC_Y,
PHOTO_YCC_C1,
PHOTO_YCC_C2,
NIFRGB_R,
NIFRGB_G,
NIFRGB_B,
ALPHA,
MONOCHROME
} FPXComponentColor;
/* Some FPX defined/allowed data types for components. */
typedef enum { DATA_TYPE_UNSIGNED_BYTE,
DATA_TYPE_SIGNED_BYTE,
DATA_TYPE_UNSIGNED_SHORT,
DATA_TYPE_SIGNED_SHORT,
DATA_TYPE_FLOAT,
DATA_TYPE_DOUBLE
} FPXDataType;
/* Define the color/datatype of a component. */
typedef struct {
FPXComponentColor myColor; /* Y, C1, C2, R, B, G, or ALPHA */
FPXDataType myDataType; /* unsigned byte, signed short, etc */
} FPXComponentColorType;
#define FPX_MAX_COMPONENTS 4
/* Specify a color space by a collection of color/datatype values.
* NOTE: only certain combinations are allowed by the FPX spec.
*/
typedef struct FPXColorspace {
FPXbool isUncalibrated;
short numberOfComponents;
FPXComponentColorType theComponents[FPX_MAX_COMPONENTS];
} FPXColorspace;
/***************************************************************************
TOOLKIT GLOBAL CONTROL
***************************************************************************/
/* FPX_Delete() is needed in the special case that the calling program
* has to delete objects created by the toolkit. In this case
* a crash will occur unless the TOOLKIT calls delete.
*/
FPXStatus FPX_Delete(void *FPXObj);
/* Create an instance of the tool kit. The Tool kit can be used only if this
* function is called prior any other call.
*/
FPXStatus FPX_InitSystem ();
/* Delete the instance of the tool kit. The Tool kit cannot be used
* after a call to this function has been made.
*/
FPXStatus FPX_ClearSystem ();
/* Get tool kit name (here "Reference") and version number.
*/
FPXStatus FPX_GetToolkitVersion (
char* versionName,
long* versionNumber);
/* Global options
* --------------
*/
typedef enum {
FPX_INCHES = 0,
FPX_METERS,
FPX_CENTIMETERS,
FPX_MILLIMETERS
} FPXResolutionUnit;
typedef enum {
FPX_NEAREST_NEIGHBOR = 0,
FPX_LINEAR_INTERPOLATION
} FPXResampleMethod;
typedef enum {
FPX_OVERWRITE_BACKGROUND = 0,
FPX_PROTECT_BACKGROUND
} FPXComposeMethod;
/* Background colors are used for for background compression.
* Values are in order of components of the color space specified
* for the FPX image.
*/
typedef struct {
signed int color1_value;
signed int color2_value;
signed int color3_value;
signed int color4_value;
} FPXBackground;
/* Set the unit used in resolution independent transactions
* in the viewing tools.
*/
FPXStatus FPX_SetUnit (
FPXResolutionUnit newUnit);
FPXStatus FPX_GetUnit (
FPXResolutionUnit* newUnit);
/* Set the method used to compute an intermediate resolution.
* (formerly FPX_SetAntialias())
*/
FPXStatus FPX_SetResampleMethod (
FPXResampleMethod method);
/* Set the method used when composing images in the viewing tools.
* (formerly FPX_NoJaggies())
*/
FPXStatus FPX_SetComposeMethod (
FPXComposeMethod method);
/* Set the default color used when composing images in the viewing tools.
* (formerly FPX_SetBackgroundColor())
*/
FPXStatus FPX_SetViewBackgroundColor (
FPXColorspace colorspace,
FPXBackground color);
/***************************************************************************
TOOLKIT MEMORY CONTROL
***************************************************************************/
/* This function sets the amount of memory to be used by the FPX toolkit.
* This value does NOT include the amount that could also be used
* by the subordinate OLE layer. There is currently no way to limit
* OLE memory usage.
*
* 0 means use unlimited available.
*/
FPXStatus FPX_SetToolkitMemoryLimit (
size_t * memoryLimit);
FPXStatus FPX_GetToolkitMemoryLimit (
size_t * memoryLimit);
FPXStatus FPX_GetToolkitMemoryAvailable (
size_t * availableMemory);
FPXStatus FPX_GetToolkitMemoryUsed (
size_t * usedMemory);
// Memory management functions
// ---------------------------
/* Purge the Toolkit memory (basically, the cached tiles).
* Return the amount of memory really purged
*/
size_t FPX_PurgeToolkitMemory (
size_t memoryToBePurged);
/* Lock a FPX image tiles to avoid having them purged
* during a FPX_PurgeToolkitMemory()
*/
FPXStatus FPX_LockFPXImage (
FPXImageHandle* theFPX);
/***************************************************************************
* FPX FILE CREATION
***************************************************************************/
/* FPX_CreateImageByFilename() - create a new, empty, FPX image.
*
* Input image must already be in output color space.
* I.e. if you want a YCC FPX, feed us YCC!
*/
FPXStatus FPX_CreateImageByFilename (
#ifdef macintosh
const FSSpec& fileSpecs,
#else
const char* fileName,
#endif
unsigned int width,
unsigned int height,
unsigned int tileWidth,
unsigned int tileHeight,
FPXColorspace colorspace,
FPXBackground backgroundColor,
FPXCompressionOption compressOption,
FPXImageHandle** theFPX);
/***************************************************************************
HIERARCHY GENERATION AND FLAT IMAGES HANDLING routines
***************************************************************************/
/* No automatic decimation will be done by the Toolkit if this function is
* called and as long as the symetric function FPX_GenerateHierarchy()
* is not called.
* If a file is created, written and closed with this option set, the resulting
* file will be a flat image (no hierarchy).
*/
FPXStatus FPX_DoNotComputeHierarchy (
FPXImageHandle* theFPX);
/* When this function is called, the hierarchy is recomputed from bottom up, using
* what is available from the high res up to the lowest res. This function unset
* the "no compute" flag, thus allowing automatic decimation to occur on a file
* when editing.
*/
FPXStatus FPX_GenerateHierarchy (
FPXImageHandle* theFPX);
/***************************************************************************
TOOLKIT SET/GET routines
***************************************************************************/
/* FPX_GetResolutionInfo() - return the resolution pyramid info from the image.
*
* After creating a new, empty image, use this to
* get info about the pyramid for later user (such as
* controlling compression on a per level basis).
* Error possible for NULL handle.
*/
FPXStatus FPX_GetResolutionInfo (
FPXImageHandle* theFPX,
FPXResolution* theResolutionInfo);
/* For a given image, set the pyramid info.
* Should only modify the compression option and quality/tablegroup for the
* pyramid layers.
*
* Or set the number of levels to 1 (flatten it for non-hierarchical FPX).
* error return(for stuff that was diddled that shouldn't have been or bad
* values.)
*/
FPXStatus FPX_SetResolutionInfo (
FPXImageHandle* theFPX,
FPXResolution* theResolutionInfo);
/***************************************************************************
TOOLKIT PROGRESS CALLBACK
***************************************************************************/
/* Typedef for the progress function used by FPX function calls which may
* take a while. The two arguments passed to the progress function are
* indications of how much work total is to be done by the toolkit function
* call and how much of it is done at this point. The progress function
* can abort the toolkit function by returning a non-zero value.
*/
typedef short (* FPXProgressFunction) (int totalToDo, int amountDoneSoFar);
/* Set the progressive function for the Toolkit. The function will be called
* automatically whenever it's necesary.
*/
FPXStatus FPX_SetProgressFunction (
FPXProgressFunction theProgressive);
/***************************************************************************
TOOLKIT FILE CLOSING
***************************************************************************/
/* Close out a FlashPix image.
* Finish creation of the image and writing to file.
* May take a long time and so includes a progress callback.
* May error for lots of reasons.
*/
FPXStatus FPX_CloseImage (
FPXImageHandle* theFPX);
/***************************************************************************
TOOLKIT COLOR COMPONENTS
***************************************************************************/
/* A struct to hold the component descriptor.
* Holds the color/datatype,
* subsampling factors,
* column and line strides,
* and pointer to the data.
*/
typedef struct {
FPXComponentColorType myColorType; /* the color and datatype */
/* of this component. */
unsigned int horzSubSampFactor; /* horizontal subsampling */
unsigned int vertSubSampFactor; /* vertical subsampling */
int columnStride; /* items to next column on */
/* this row. */
int lineStride; /* items to next line in */
/* this column. */
unsigned char* theData; /* maybe void * XXX? */
} FPXImageComponentDesc;
/* A struct to hold the image descriptor.
* Holds the number of components (channels) and
* their descriptors. NOTE that the components implicitly
* describe the colorspace.
*/
typedef struct FPXImageDesc {
unsigned int numberOfComponents;
FPXImageComponentDesc components[FPX_MAX_COMPONENTS];
} FPXImageDesc;
/* In Baseline, channels are premultiplied by the alpha channel.
* However, using non premultiplied images is no big deal: just a
* bit to set in the color subfield.
* These functions allow the handling of FPX with or without
* premultiplication.
* CAUTION:
* - if some tiles are already written, FPX_SetAlphaType
* returns an error.
* - these functions are not implemented in Baseline
*/
typedef enum {
PREMULTIPLIED_CHANNELS,
INDEPENDENT_CHANNELS
} FPXPreComputedAlpha;
FPXStatus FPX_SetAlphaType (
FPXImageHandle* theFPX,
FPXPreComputedAlpha theAlphaType);
FPXStatus FPX_GetAlphaType (
FPXImageHandle* theFPX,
FPXPreComputedAlpha* theAlphaType);
/* provide a table group and assign an ID number to it.
* Provides user control over compression quality.
* ERROR return for NULL table, illegal/already used ID.
*/
FPXStatus FPX_SetJPEGTableGroup (
FPXImageHandle* theFPX,
FPXJPEGTableGroup* theGroup,
unsigned char theTableGroupID);
/* Get a given table group from a FPX image.
*
* ERROR return for ID not valid.
*/
FPXStatus FPX_GetJPEGTableGroup (
FPXImageHandle* theFPX,
FPXJPEGTableGroup* theGroup,
unsigned char theTableGroupID);
/* specify the quant_ID's to be used for compression
*
* A table is specified for the entire image, all levels.
* Error return if no such table.
*/
FPXStatus FPX_SelectJPEGTableGroup (
FPXImageHandle* theFPX,
unsigned char theTableGroupID);
/* Alternative JPEG table control:
* builds tables according to value of compressionFactor (a la JFIF)
* not allowed with other sets of huff or quant tables.
*/
FPXStatus FPX_SetJPEGCompression (
FPXImageHandle* theFPX,
unsigned short theQualityFactor); /* 0->100 */
/* Resolution decimation quality control:
*
* Tell the toolkit how large a kernel to use.
* (Probably need to provide another call with the actual coefficients of
* a separable NxN kernel.)
*
* Errors on bad handle, bad kernel size.
*/
FPXStatus FPX_SetDecimationQuality (
FPXImageHandle* theFPX,
unsigned short decimationQuality); /* perhaps one dimension */
/* of decimation kernel. */
/* The following two calls are for writing rectangular regions
*
* into the image. But this may be too general.
* Perhaps we should only allow rectangles that multiples of the
* tile size, or just one rectangle, or XXX ?
* If we do allow general rectangles, we must verify that there is
* no overlap! XXX
*/
/* Write a rectangle of data into the image.
*
* Specify upper Left and Lower right pixel coords. of
* full sized image. Subsampled components must be handled accordingly.
*/
FPXStatus FPX_WriteImageRectangle (
FPXImageHandle* theFPX,
unsigned int X0,
unsigned int Y0,
unsigned int X1,
unsigned int Y1,
FPXImageDesc* theData);
/* Write a rectangle of background color. */
FPXStatus FPX_WriteBackgroundRectangle (
FPXImageHandle* theFPX,
unsigned int X0,
unsigned int Y0,
unsigned int X1,
unsigned int Y1,
FPXColorspace theColorspace,
FPXBackground theColor);
/* Write a line of data into the image.
* May NOT be mixed with writing of rectangles.
*
* Opening of image effectively starts the "iterator" for line
* writing at the top of the image.
* LINE of input data is in an FPXImageDesc with is presumed to
* be loaded with the line of data as the first (only?) line in the
* data.
*/
FPXStatus FPX_WriteImageLine (
FPXImageHandle* theFPX,
FPXImageDesc* theLine);
/* Write to specific resolution.
*
* The caller will have decimated the image data external to the toolkit.
* Resolution 0 is the lowest res. (smallest)
* Resolution FPXResoltion.numberOfResolutions-1 is the highest
* (largest).
* Expected use is for the user to provide all data for the entire
* resultion pyramid, one call at a time.
*/
FPXStatus FPX_WriteImageResolution (
FPXImageHandle* theFPX,
unsigned int theResolution,
FPXImageDesc* theData);
/* Flush modified tiles to the file.
*
* After pixel content has been modified by an FPX_WriteXXXX() routine, the
* changes may be cached in memory. This call ensures that the modified tiles
* are written to the file. Failure to call this may result in stale pixel data
* when lower resolutions are read.
*/
FPXStatus FPX_FlushModifiedTiles (
FPXImageHandle* theFPX);
/***************************************************************************
FPX FILE READING
***************************************************************************/
/* A struct for the various amounts of info that describe the
* compression of a tile.
*/
typedef struct {
FPXCompressionOption compressOption;
unsigned char compressQuality;
long compressSubtype;
} FPXTileCompressionInfo;
/* A compressed tile. Includes compression info as well as the
* JPEG data.
*/
typedef struct {
FPXTileCompressionInfo compInfo;
unsigned int dataLength;
void* data;
} FPXTileDesc;
FPXStatus FPX_OpenImageByFilename (
#ifdef macintosh
const FSSpec& fileSpecs,
#else
const char* fileName,
#endif
const char* storagePathInFile,
unsigned int* width,
unsigned int* height,
unsigned int* tileWidth,
unsigned int* tileHeight,
FPXColorspace* colorspace,
FPXImageHandle** theFPX);
// CHG_VIS_OUT - Added a file open call that supports specifying a visible output.
FPXStatus FPX_OpenIndexedImageByFilename (
const char* fileName,
const char* storagePathInFile,
unsigned int visibleOutputIndex,
unsigned int* width,
unsigned int* height,
unsigned int* tileWidth,
unsigned int* tileHeight,
FPXColorspace* colorspace,
FPXImageHandle** theFPX);
/* and an open from an IStorage. */
FPXStatus FPX_OpenImageByStorage (
IStorage* storagePointer,
const char* storagePathInFile,
unsigned int* width,
unsigned int* height,
unsigned int* tileWidth,
unsigned int* tileHeight,
FPXColorspace* colorspace,
FPXImageHandle** theFPX);
/* Read a rectangle of pixels from the transformed image.
*
* The specified rectangle is read from the specified resolution
* into the components provided. Color conversion and pixel shuffling
* may occur in the process as well as cropping and rotation.
* XXX ColorKnobs! ColorTwist! Sharpeness!
*
*/
FPXStatus FPX_ReadImageTransformRectangle (
FPXImageHandle* theFPX,
float X0,
float Y0,
float X1,
float Y1,
int rectWidth,
int rectHeight,
FPXImageDesc* theRectangle);
/* Read a rectangle of pixels from a given resolution.
*
* The specified rectangle is read from the specified resolution
* into the components provided.
* CAUTION : this is the symetric function to FPX_WriteImageRectangle() so
* no viewing transform is applied to the data!
*/
FPXStatus FPX_ReadImageRectangle (
FPXImageHandle* theFPX,
unsigned int X0,
unsigned int Y0,
unsigned int X1,
unsigned int Y1,
unsigned int theResolution,
FPXImageDesc* theImage);
/* Read a decompressed tile of pixels from a Resolution.
* Read the specified tile and decompress it.
* CAUTION : viewing parameters (and particularly geometric ones) cannot
* be applied to a single tile of a particular resolution.
*/
FPXStatus FPX_ReadImageTile (
FPXImageHandle* theFPX,
unsigned int whichTile,
unsigned int theResolution,
FPXImageDesc* theTile);
/* Read a compressed tile of pixels from a Resolution.
*
* if tile was not compressed, it will still return successfully.
*/
FPXStatus FPX_ReadImageCompressedTile (
FPXImageHandle* theFPX,
unsigned int whichTile,
unsigned int theResolution,
FPXTileDesc* theTile);
FPXStatus FPX_WriteImageCompressedTile (
FPXImageHandle* theFPX,
unsigned int whichTile,
unsigned int theResolution,
FPXTileDesc* theTile);
/***************************************************************************
IMAGES WITH VIEWS
***************************************************************************/
typedef struct {
float left; /* left edge */
float top; /* top edge */
float width; /* width */
float height; /* height */
} FPXROI;
typedef float FPXFilteringValue;
typedef struct {
/* first row: */
float a11;
float a12;
float a13;
float a14;
/* second row: */
float a21;
float a22;
float a23;
float a24;
/* third row: */
float a31;
float a32;
float a33;
float a34;
/* fourth row: */
float a41;
float a42;
float a43;
float a44;
} FPXAffineMatrix;
typedef float FPXResultAspectRatio;
typedef struct FPXColorTwistMatrix {
/* first row */
float byy;
float byc1;
float byc2;
float dummy1_zero; /* nominally zero. */
/* second row */
float bc1y;
float bc1c1;
float bc1c2;
float dummy2_zero; /* nominally zero. */
/* third row */
float bc2y;
float bc2c1;
float bc2c2;
float dummy3_zero; /* nominally zero. */
/* fourth row */
float dummy4_zero; /* nominally zero. */
float dummy5_zero; /* nominally zero. */
float dummy6_zero; /* nominally zero. */
float dummy7_one; /* nominally one. */
} FPXColorTwistMatrix;
typedef float FPXContrastAdjustment;
/* There is a desire to create images associated with views.
* These are Image Views with embedded Images.
* The View created may have no Transform (optionnal pointers set to NULL).
* The PIW (for instance) may wish to create such beasts.
*/
FPXStatus FPX_CreateImageWithViewByFilename (
#ifdef macintosh
const FSSpec& fileSpecs,
#else
const char* fileName,
#endif
unsigned int width,
unsigned int height,
unsigned int tileWidth,
unsigned int tileHeight,
FPXColorspace colorspace,
FPXBackground backgroundColor,
FPXCompressionOption compressOption,
FPXAffineMatrix* affineMatrix,
FPXContrastAdjustment* contrastValue,
FPXColorTwistMatrix* colorTwist,
FPXFilteringValue* filteringValue,
FPXROI* regionOfInterest,
FPXResultAspectRatio* resultAspectRatio,
FPXImageHandle** theFPX);
/********************************************************************************
ICC PROFILE
*******************************************************************************/
/* The ICC profile is a data structure defined in the ICC spec.
*
* Please visit ftp:sgigate.sgi.com/pub/icc for a copy of the spec which
* defines this structure. The format will not be addressed here.
*
* FPX will allow you to obtain the structure if it is stored in the
* file.
*
*/
FPXStatus FPX_SetICCProfile(
FPXImageHandle *theFPX,
FPXStr * theProfile,
unsigned short profileIndex);
FPXStatus FPX_GetICCProfile(
FPXImageHandle *theFPX,
FPXStr * theProfile,
unsigned short profileIndex);