1 // ----------------------------------------------------------------------------
2 //
3 // FPX FILE MANAGEMENT
4 //
5 // MODULE : FileFlashPixIO
6 // LANGUAGE : C++
7 // AUTHOR : Philippe BOSSUT
8 // DATE : Thursday, December 16th 1993
9 // DESCRIPTION :
10 // COMMENT : This package is a part of the FlashPix Toolkit I/O
11 // SCCSID : @(#)f_fpxio.h 1.3 12:36:08 22 Jul 1997
12 // ----------------------------------------------------------------------------
13 // Copyright (c) 1999 Digital Imaging Group, Inc.
14 // For conditions of distribution and use, see copyright notice
15 // in Flashpix.h
16 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
18 #ifndef FileFlashPixIO_h
19 #define FileFlashPixIO_h
20 #ifndef Commun_h
21 #include "common.h"
22 #endif
23
24 // ----------------------------------------------------------------------------
25
26 // Includes
27 // --------
28
29 #ifndef PHierarchicalImage_h
30 #include "ph_image.h"
31 #endif
32 #ifndef FPXBaselineIO_h
33 #include "fpxlibio.h"
34 #endif
35
36
37 // Constants
38 // ---------
39
40 #define FPX_TILE_WIDTH 64 // Baseline limitation: handle only 64x64 tiles...
41
42 // Class Declarations
43 // ------------------
44
45 class PFileFlashPixIO;
46
47 class OLEStorage; // to not include OLEStorage
48 class OLEProperty; // to not include OLEProperty
49 class OLEHeaderStream; // to not include OLEHeaderStream.h
50
51 // Class Definitions
52 // -----------------
53
54 // Handle on an FPX Image Object file:
55
56 class PFileFlashPixIO : public PHierarchicalImage {
57
58 friend class PFlashPixImageView;
59 friend class PResolutionLevel;
60 friend class PResolutionFlashPix;
61 friend class PTile;
62 friend class PTileFlashPix;
63 friend class PageImage;
64
65 public:
66 // Constructors and destructor :
67
68 // Open the file in Create Mode
69 PFileFlashPixIO (FicNom& refName,
70 int width, int height, float resolution,
71 FPXBaselineColorSpace baseSpace, unsigned long backColor,
72 FPXCompressionOption FPXCompressOption,
73 Boolean baseUncalibrated = FALSE);
74 PFileFlashPixIO (OLEStorage* theOwningStorage, const char* theStorageName,
75 int width, int height, float resolution,
76 FPXBaselineColorSpace baseSpace, unsigned long backColor,
77 FPXCompressionOption FPXCompressOption,
78 Boolean baseUncalibrated = FALSE);
79 // Open the file in Read Mode only
80 PFileFlashPixIO (FicNom& refName, const char* theStorageName = NULL);
81 PFileFlashPixIO (OLEStorage* theOwningStorage, const char* theStorageName);
82 // Open the file in Read/Write mode (but not Create)
83 PFileFlashPixIO (FicNom& refName, const char* theStorageName, mode_Ouverture openMode);
84 PFileFlashPixIO (OLEStorage* theOwningStorage, const char* theStorageName, mode_Ouverture openMode);
85
86 virtual ~PFileFlashPixIO ();
87
88 // Public interface: Customize a RI Image:
89 // ---------------------------------------
90
91 // Path management : see code for comments...
92 virtual OSErr ReadPaths (data_Record** path, int* nbRecords, int* clipPathNum);
93 virtual OSErr WritePaths (data_Record* path, int nbRecords, int clipPathNum);
94
95 // Special method for FlashPix:
96 // -------------------------
97 void GetResolutionSize (short resolution, int* width, int* height);
98 void GetResolutionTileSize (short resolution, int* nbTilesWidth, int* nbTilesHeight);
99 int GetTileWidth();
100
101 void GetResolutionInfo(FPXResolution* FPXResoInfo, Boolean createdOnly = TRUE);
102 void SetResolutionInfo(FPXResolution* FPXResoInfo);
103
104 // Set compression
105 virtual void SetCompression (Typ_Compression theCompression);
106 virtual void SetCompressionSubType (long theCompressionSubType);
107 virtual long GetCompressionSubType ();
108 virtual FPXCompressionOption GetCompression ();
109
110 // Set quality factor
111 virtual void SetQualityFactor (unsigned char theQualityFactor);
112
113 // Set jpeg compression table index
114 void SetCompressTableGroup (long theCompressTableGroup);
115
116 // CHG_FIX_FLAT_TNAIL - provide access to member nbCreatedResolutions
117 virtual long GetNumCreatedResolutions ( );
118
119 // Raw data read and write functions
120 FPXStatus ReadRawTile (unsigned long theResolution, unsigned long whichTile,
121 FPXCompressionOption* compressOption,
122 unsigned char* compressQuality,
123 long* compressSubtype,
124 unsigned int* dataLength,
125 void** data);
126 FPXStatus WriteRawTile (unsigned long theResolution, unsigned long whichTile,
127 FPXCompressionOption compressOption,
128 unsigned char compressQuality,
129 long compressSubtype,
130 unsigned int dataLength,
131 void* data);
132 FPXStatus FlushModifiedTiles( );
133
134 protected:
135 // Protected interface: Customize a Hierarchical Image:
136 // ----------------------------------------------------
137
138 // File management:
139 virtual FPXStatus OpenFile(); // Read or Init header file information
140 virtual FPXStatus CloseFile(); // End sub images computation and writing before closing the file
141
142 // Resolution hierarchy management:
143 virtual FPXStatus InitResolutionLevelsTable(); // Update pointers array of sub images
144 virtual FPXStatus CreateInitResolutionLevelList(); // Make a sub image list in read or write mode
145 virtual FPXStatus CreateEmptyResolutionLevelList(); // Make a sub image list in create mode
146 virtual PResolutionLevel* CreateEmptyResolutionLevel(int width, int height, int* whichImage); // Make a sub image in create mode
147 virtual PResolutionLevel* CreateInitResolutionLevel(int* offset, long id); // Make a sub image in read or write mode
148
149 FPXStatus MakeNewThumbnail(OLEProperty *aProp);
150 private:
151 // Private init of a PFileFlashPixIO -> this is not a virtual method
152 void Init();
153
154 // CAUTION: volatile values. The caller must create and call OpenFile() before deleting the objects pointed here (tricky...)
155 OLEStorage* owningStorage; // The owning storage if any
156 const char* storageName; // The storage name if any
157
158 FPXCompressionOption FPXCompression; // Compression mode used in this image file
159 long FPXCompressionSubType; // Compression option (subsampling, color conversion and jpeg table, etc) used in this image file
160 unsigned char FPXQualityFactor; // Quality factor in compression used in this image file
161
162 FPXResolutionUnit fileUnit; // Unit used to express sizes in this file
163 long nbCreatedResolutions; // number of resolutions really created in this FPX file
164 Boolean tilesHasBeenModified; // true if a tile has been written during the session
165 };
166
167
168 // 'inline' Functions
169 // ------------------
170
SetCompression(Typ_Compression theCompression)171 inline void PFileFlashPixIO::SetCompression (Typ_Compression theCompression) { FPXCompression = (FPXCompressionOption)theCompression; }
GetCompressionSubType()172 inline long PFileFlashPixIO::GetCompressionSubType () { return FPXCompressionSubType; }
GetCompression()173 inline FPXCompressionOption PFileFlashPixIO::GetCompression () { return FPXCompression; }
174
175 // CHG_FIX_FLAT_TNAIL - provide access to member nbCreatedResolutions
GetNumCreatedResolutions()176 inline long PFileFlashPixIO::GetNumCreatedResolutions() { return nbCreatedResolutions; }
177
178 // 'extern' Functions
179 // -----------------
180
181 // Create a fpx file
182 FPXStatus CreateImageByFilename (
183 FicNom& fileName,
184 unsigned int width,
185 unsigned int height,
186 unsigned int tileWidth, // not implemented in Baseline (always 64)
187 unsigned int tileHeight, // not implemented in Baseline (always 64)
188 FPXColorspace colorspace,
189 FPXBackground backgroundColor,
190 FPXCompressionOption compressOption,
191 FPXImageHandle** theFPX);
192
193 // Open a fpx file
194 FPXStatus OpenImageByFilename (
195 FicNom& fileName,
196 const char* storagePathInFile, // for the moment, only the root storage is considered
197 unsigned int* width,
198 unsigned int* height,
199 unsigned int* tileWidth,
200 unsigned int* tileHeight,
201 FPXColorspace* colorspace,
202 FPXImageHandle** theFPX);
203
204 FPXStatus CreateImageWithViewByFilename (
205 FicNom& fileName,
206 unsigned int width,
207 unsigned int height,
208 unsigned int tileWidth, // not implemented in Baseline (always 64)
209 unsigned int tileHeight, // not implemented in Baseline (always 64)
210 FPXColorspace colorspace,
211 FPXBackground backgroundColor,
212 FPXCompressionOption compressOption,
213 FPXAffineMatrix* affineMatrix,
214 FPXContrastAdjustment* contrastValue,
215 FPXColorTwistMatrix* colorTwist,
216 FPXFilteringValue* filteringValue,
217 FPXROI* regionOfInterest,
218 FPXResultAspectRatio* resultAspectRatio,
219 FPXImageHandle** theFPX);
220
221 FPXStatus FPX_CreateImageWithViewByStorage (
222 IStorage* owningStorage,
223 const char* storageName,
224 unsigned int width,
225 unsigned int height,
226 unsigned int tileWidth,
227 unsigned int tileHeight,
228 FPXColorspace colorspace,
229 FPXBackground backgroundColor,
230 FPXCompressionOption compressOption,
231 FPXAffineMatrix* affineMatrix,
232 FPXContrastAdjustment* contrastValue,
233 FPXColorTwistMatrix* colorTwist,
234 FPXFilteringValue* filteringValue,
235 FPXROI* regionOfInterest,
236 FPXResultAspectRatio* resultAspectRatio,
237 FPXImageHandle** theFPX);
238
239 // 'extern' Variables
240 // -----------------
241
242 // ----------------------------------------------------------------------------
243 #endif // FileFlashPixIO_h
244 // ----------------------------------------------------------------------------
245