1 //  ----------------------------------------------------------------------------
2 //  MODULE    : FPXImageView
3 //  LANGUAGE  : C++
4 //  CREATOR   : Philippe BOSSUT
5 //  CREAT. DATE : Friday, March 29, 1996
6 //  DESCRIPTION :
7 //  COMMENTS  : FPX Image View can be implemented in a hundred of different
8 //          ways. Providing all the primitives for every little tiny fileds
9 //          specified in the format is just unworkable (for the user of the
10 //          class). We then implemented a version of the FPX Image View which
11 //          is "Core Reader/Writer" oriented. Basically, this means that only
12 //          the fields available through the FPX Reference Implementation are
13 //          implemented as parameters and all the rest is implemented as
14 //          automatic variables by the PFlashPixImageView class.
15 //          For instance, there are a bunch of functions to tweak the viewing
16 //          parameters like position, contrast, filtering and the rest, but
17 //          there is no function to read or write the operation property set.
18 //          This one is handled completly automatically.
19 //      SCCSID          : @(#)fpximgvw.h  1.4 12:46:42 01 Jul 1997
20 //  ----------------------------------------------------------------------------
21 //  Copyright (c) 1999 Digital Imaging Group, Inc.
22 //  For conditions of distribution and use, see copyright notice
23 //  in Flashpix.h
24 //  ----------------------------------------------------------------------------
25   #ifndef FPXImageView_h
26   #define FPXImageView_h
27   #ifndef Commun_h
28     #include  "common.h"
29   #endif
30 //  ----------------------------------------------------------------------------
31 
32 //  Includes
33 //  --------
34 
35 #ifndef SystemIVUE_h
36   #include "ri_sys.h"
37 #endif
38 #ifndef AdvancedIVUE_h
39   #include  "viewimg.h"
40 #endif
41 
42 #ifndef FileFlashPixView_h
43   #include  "f_fpxvw.h"
44 #endif
45 
46 //  Constants
47 //  ---------
48 
49 //  Types Declarations
50 //  ------------------
51 
52 //  Types Definitions
53 //  -----------------
54 
55   /*
56    * Global Info Property Set
57    */
58 
59   typedef struct {
60               FPXbool       lockedPropertiesIsValid;
61               FPXLongArray          lockedProperties;
62 
63               FPXbool       transformedImageTitleIsValid;
64               FPXWideStr      transformedImageTitle;
65 
66               FPXbool       lastModifierIsValid;
67               FPXWideStr      lastModifier;
68 
69               FPXLongArray          visibleOutputs;
70               long                  maxImageIndex;
71               long                  maxTransformIndex;
72               long                  maxOperatorIndex;
73   } FPXGlobalInfo;
74 
75   /*
76    * Source and Result Description Property Set
77    */
78 
79   typedef enum {
80               FPX_DATA_NOT_CACHED = 0,
81               FPX_DATA_CACHED
82   } FPXImageExistence;
83 
84   typedef enum {
85               FPX_DATA_PURGEABLE = 0,
86               FPX_DATA_NOT_PURGEABLE
87   } FPXImagePermission;
88 
89   typedef struct {
90               FPXImageExistence     existenceData;
91               FPXImagePermission    permission;
92   } FPXImageStatus;
93 
94   typedef struct {
95               CLSID                 dataObjectID;
96 
97               FPXbool       lockedPropertiesIsValid;
98               FPXLongArray          lockedProperties;
99 
100               FPXbool       dataObjectTitleIsValid;
101               FPXWideStr      dataObjectTitle;
102 
103               FPXbool       lastModifierIsValid;
104               FPXWideStr      lastModifier;
105 
106               FPXbool       revisionNumberIsValid;
107               long          revisionNumber;
108 
109               FPXbool       creationDateIsValid;
110               FPXfiletime           creationDate;
111 
112               FPXbool       modificationDateIsValid;
113               FPXfiletime           modificationDate;
114 
115               FPXbool       creatingApplicationIsValid;
116               FPXWideStr            creatingApplication;
117 
118               FPXImageStatus        status;
119               long                  creator;
120               FPXLongArray          users;
121 
122               FPXbool       heightIsValid;
123               int                  height;
124 
125               FPXbool       widthIsValid;
126               int                  width;
127   } FPXImageDescription;
128 
129   /*
130    * Transform Property Set
131    */
132 
133   typedef struct {
134               CLSID                 transformNodeID;
135               CLSID                 operationClassID;
136 
137               FPXbool       lockedPropertiesIsValid;
138               FPXLongArray          lockedProperties;
139 
140               FPXbool       transformTitleIsValid;
141               FPXWideStr      transformTitle;
142 
143               FPXbool       lastModifierIsValid;
144               FPXWideStr      lastModifier;
145 
146               FPXbool       revisionNumberIsValid;
147               long          revisionNumber;
148 
149               FPXbool       creationDateIsValid;
150               FPXfiletime           creationDate;
151 
152               FPXbool       modificationDateIsValid;
153               FPXfiletime           modificationDate;
154 
155               FPXbool       creatingApplicationIsValid;
156               FPXWideStr            creatingApplication;
157 
158               FPXLongArray          inputDataObjects;
159               FPXLongArray          outputDataObjects;
160               long                  operationNumber;
161 
162               // The actual transform parameters are written or read using independent
163               // methods (see SetImageXx() and GetImageXx()) of the PFlashPixImageView class
164               // Note that all of these properties are optionnal.
165   } FPXTransform;
166 
167   /*
168    * Operation Property Set
169    */
170 
171   typedef struct {
172               CLSID                 operationID;
173   } FPXOperation;
174 
175 //  Classes Declarations
176 //  --------------------
177 
178   class PFlashPixImageView;
179 
180   class PSearchHookObject;
181 
182 //  Classes Definitions
183 //  -------------------
184 
185   class PFlashPixImageView : public ViewImage {
186 
187   public:
188                  // CHG_VIS_OUT - added visibleOutputIndex argument to constructors that
189                  // open a file.
190                  // Open the file in Read Mode only
191                  PFlashPixImageView (FicNom& refName, const char* theStorageName = NULL,
192                             long visibleOutputIndex = 0,
193                             FPXStatus * status = NULL);
194                  PFlashPixImageView (OLEStorage* theOwningStorage, const char* theStorageName,
195                             long visibleOutputIndex = 0);
196                  // Open the file in Create Mode
197                  PFlashPixImageView (FicNom& refName, int width, int height, float resolution,
198                           FPXBaselineColorSpace baseSpace, unsigned long backColor,
199                           FPXCompressionOption FPXCompressOption,
200                           Boolean createFPXImageView = FALSE,
201                           Boolean baseUncalibrated   = FALSE);
202                  PFlashPixImageView (OLEStorage* theOwningStorage, const char* theStorageName, int width, int height, float resolution,
203                           FPXBaselineColorSpace baseSpace, unsigned long backColor,
204                           FPXCompressionOption FPXCompressOption,
205                           Boolean createFPXImageView = FALSE,
206                           Boolean baseUncalibrated   = FALSE);
207                  // Open the file in Read/Write mode (but not Create)
208                  PFlashPixImageView (FicNom& refName, const char* theStorageName,
209                             mode_Ouverture openMode, long visibleOutputIndex = 0,
210                             PSearchHookObject* hook = 0, FPXStatus * status = NULL);
211                  PFlashPixImageView (OLEStorage* theOwningStorage, const char* theStorageName,
212                             mode_Ouverture openMode, long visibleOutputIndex = 0,
213                             FPXStatus * status = NULL);
214                  // Create a FPX Image View from an already opened image
215                  PFlashPixImageView (PRIImage* theImage);
216         virtual     ~PFlashPixImageView ();
217 
218         FPXStatus     OpenFile();
219         FPXStatus     CloseFile();
220 
221         // Set and Get Transform properties
222         FPXStatus     SetImageROI (FPXROI* theROI);
223         FPXStatus     GetImageROI (FPXROI* theROI);
224         FPXStatus     SetImageFilteringValue (FPXFilteringValue* theFiltering);
225         FPXStatus     GetImageFilteringValue (FPXFilteringValue* theFiltering);
226         FPXStatus   SetImageAffineMatrix (FPXAffineMatrix*  theAffineMatrix);
227         FPXStatus   GetImageAffineMatrix (FPXAffineMatrix*  theAffineMatrix);
228         FPXStatus     SetImageResultAspectRatio (FPXResultAspectRatio* theAspectRatio);
229         FPXStatus     GetImageResultAspectRatio (FPXResultAspectRatio* theAspectRatio);
230         FPXStatus     SetImageColorTwistMatrix (FPXColorTwistMatrix* theColorTwistMatrix);
231         FPXStatus     GetImageColorTwistMatrix (FPXColorTwistMatrix* theColorTwistMatrix);
232         FPXStatus     SetImageContrastAdjustment (FPXContrastAdjustment* theContrastAdjustment);
233         FPXStatus     GetImageContrastAdjustment (FPXContrastAdjustment* theContrastAdjustment);
234 
235         void      SetImageEditedFlag();
GetCurrentFile()236         PFileFlashPixView*  GetCurrentFile()  { return filePtr; }
237 
238         FPXStatus     SaveImageFilteringValue ();
239         FPXStatus     SaveImageColorTwistMatrix ();
240         FPXStatus     SaveImageContrastAdjustment ();
241         FPXStatus   SaveImageAffineMatrix ();
242         FPXStatus     SaveImageROI ();
243         FPXStatus     SaveImageResultAspectRatio ();
getInternalBuffer()244         unsigned char*  getInternalBuffer(){return internalBuffer;};
245         void        setInternalBuffer(long theWidth, long theHeight);
246 
247   protected:
248     Boolean   readOnlyFile;
249     unsigned char*    internalBuffer;
250     long        internalBufSize;
251   private:
252         // Implement default Baseline behavior for the other property sets
253         FPXStatus     SaveSummaryInfoPropertySet();
254         FPXStatus   MakeNewThumbnail(OLEProperty *aProp);
255 
256         FPXStatus     SaveGlobalInfoPropertySet();
257         FPXStatus     SaveSourcePropertySet();
258         FPXStatus     SaveResultPropertySet();
259         FPXStatus     SaveTransformPropertySet();
260         FPXStatus     SaveOperationPropertySet();
261         FPXStatus     SaveExtensionListPropertySet();
262 
263         void      InitGlobalInfoPropertySet(FPXGlobalInfo* theGlobalInfo);
264         void      InitSourcePropertySet(FPXImageDescription* theImageDesc);
265         void      InitResultPropertySet(FPXImageDescription* theImageDesc);
266         void      InitTransformPropertySet(FPXTransform* theTransform);
267         void      InitOperationPropertySet(FPXOperation* theOperation);
268         void      InitExtensionListPropertySet(FPXExtensionDescription* theExtension);
269 
270         // Set and Get property sets functions: one day, these functions will be made public and
271         // provided to the user through some calls in the Reference Implementation API...
272         FPXStatus   SetGlobalInfoPropertySet(FPXGlobalInfo* theGlobalInfo);
273         FPXStatus   SetSourcePropertySet(FPXImageDescription* theSourceDescription);
274         FPXStatus   SetResultPropertySet(FPXImageDescription* theResultDescription);
275         FPXStatus   SetTransformPropertySet(FPXTransform* theTransform);
276         FPXStatus   SetOperationPropertySet(FPXOperation* theOperation);
277         FPXStatus   SetExtensionListPropertySet(FPXExtensionDescription* theExtension, char* extensionName);
278 
279         FPXStatus   GetGlobalInfoPropertySet(FPXGlobalInfo* theGlobalInfo);
280         FPXStatus   GetSourcePropertySet(FPXImageDescription* theSourceDescription);
281         FPXStatus   GetResultPropertySet(FPXImageDescription* theResultDescription);
282         FPXStatus   GetTransformPropertySet(FPXTransform* theTransform);
283         FPXStatus   GetOperationPropertySet(FPXOperation* theOperation);
284         FPXStatus   GetExtensionListPropertySet(FPXExtensionDescription* theExtension, char* extensionName);
285 
286         // Load and Save Transform properties
287         void      InitTransformProperties ();
288 
289         FPXStatus     LoadImageROI ();
290 
291         FPXStatus     LoadImageFilteringValue ();
292 
293         FPXStatus   LoadImageAffineMatrix ();
294 
295         FPXStatus     LoadImageResultAspectRatio ();
296 
297         FPXStatus     LoadImageColorTwistMatrix ();
298 
299         FPXStatus     LoadImageContrastAdjustment ();
300 
301         PFileFlashPixView*  filePtr;      // The image file descriptor
302 
303         // Geometric parameters
304         Boolean         hasRegionOfInterest;
305         Boolean           hasAffineMatrix;
306         Boolean         hasAspectRatio;
307         FPXROI          regionOfInterest;
308         FPXAffineMatrix       affineMatrix;
309         FPXResultAspectRatio  aspectRatio;
310 
311         // Display parameters
312         Boolean         hasFiltering;
313         Boolean         hasColorTwistMatrix;
314         Boolean         hasContrastAdjustment;
315         FPXFilteringValue     filtering;
316         FPXColorTwistMatrix   colorTwistMatrix;
317         FPXContrastAdjustment contrastAdjustment;
318 
319         Boolean     transformsHaveBeenEdited; // True if a SetXx() function is called on a transform
320         Boolean     imageHasBeenEdited;     // True if WriteRectangle() or other pixel editing function has been called
321   };
322 
323 //  'inline' Functions
324 //  ------------------
325 
SetImageEditedFlag()326 inline void  PFlashPixImageView::SetImageEditedFlag() { imageHasBeenEdited = TRUE; }
327 
328 //  'extern' Functions
329 //  ------------------
330 
331 //  'extern' Variables
332 //  ------------------
333 
334 //  ----------------------------------------------------------------------------
335   #endif // FPXImageView_h
336 //  ----------------------------------------------------------------------------
337