1 //  ----------------------------------------------------------------------------
2 //  MODULE    : FPXImageView.cpp
3 //  LANGUAGE  : C++
4 //  CREATOR   : Yue Zhang
5 //  DATE    : March 21, 1996
6 //  DESCRIPTION :
7 //  COMMENTS  :
8 //      SCCSID          : @(#)fpximgvw.cpp  1.9 12:46:34 01 Jul 1997
9 //  ----------------------------------------------------------------------------
10 //  Copyright (c) 1999 Digital Imaging Group, Inc.
11 //  For conditions of distribution and use, see copyright notice
12 //  in Flashpix.h
13 //  ----------------------------------------------------------------------------
14 
15 //  ----------------------------------------------------------------------------
16   #include "fpximgvw.h"
17 //  ----------------------------------------------------------------------------
18 
19 //  Includes
20 //  --------
21 
22   #include  <string.h>
23   #include  <stdio.h>
24 
25 #if defined(USE_LEGACY_INCLUDES)
26 #  include <fstream.h>
27 #else
28 #  include <fstream>
29    using namespace std;
30 #endif
31 
32 #ifdef macintosh
33   #include  <Errors.h>
34 #endif
35 #ifndef Numbers_h
36   #include  "numbers.h"
37 #endif
38 
39 #ifndef Memoire_h
40 //include "b_memory.h"
41 #endif
42 
43 #ifndef Debug_h
44   #include  "debug.h"
45 #endif
46 
47 
48 #ifndef FPXBaselineIO_h
49   #include "fpxlibio.h"
50 #endif
51 
52 #ifndef FPXBaselineView_h
53   #include "fpxlib.h"
54 #endif
55 
56 #ifndef OLECommun_h
57   #include "olecomm.h"
58 #endif
59 
60 #ifndef OLECore_h
61   #include "olecore.h"
62 #endif
63 
64 #ifndef Gen_guid_h
65   #include "gen_guid.h"
66 #endif
67 
68 #ifndef OLEStorages_h
69   #include  "olestorg.h"
70 #endif
71 
72 #ifndef OLEHeaderStream_h
73   #include  "olehstrm.h"
74 #endif
75 
76 #ifndef OLEProperties_h
77   #include  "oleprop.h"
78 #endif
79 
80 #ifndef OLEPropertySet_h
81   #include  "oleprops.h"
82 #endif
83 
84 #ifndef OLEFiles_h
85   #include  "olefiles.h"
86 #endif
87 
88 #ifndef FlashPixUtils_h
89   #include "fpxutils.h"
90 #endif
91 
92 #ifndef ColorTwist_h
93   #include "coltwist.h"
94 #endif
95 
96 #ifndef FileFlashPixIO_h
97   #include "f_fpxio.h"
98 #endif
99 
100 #ifndef PageIVUE_h
101   #include "ri_page.h"
102 #endif
103 
104 #ifndef BufferDesc_h
105   #include  "buffdesc.h"
106 #endif
107 
108 #ifndef FPXThumbnail_h
109   #include  "thmbnail.h"
110 #endif
111 
112 //  Constants
113 //  ---------
114 
115 //  Variables
116 //  ---------
117 
118 //  ----------------------------------------------------------------------------
119 //  Internal Functions
120 //  ----------------------------------------------------------------------------
121 
122 //  ----------------------------------------------------------------------------
123 //  Member Functions
124 //  ----------------------------------------------------------------------------
125 
126 // Open the file in Read Mode only
127 // CHG_VIS_OUT - added visibleOutputIndex argument to be passed to PFileFlashPixView
PFlashPixImageView(FicNom & refName,const char * theStorageName,long visibleOutputIndex,FPXStatus * fpxStatus)128 PFlashPixImageView::PFlashPixImageView (FicNom& refName, const char* theStorageName,
129                     long visibleOutputIndex,
130                     FPXStatus * fpxStatus) : ViewImage(refName)
131 
132 {
133   CLSID idBaseline     = ID_Baseline;
134   CLSID idImageView    = ID_ImageView;
135   CLSID id;
136 
137   // Init the file pointers
138   filePtr = NULL;
139   image   = NULL;
140 
141   internalBuffer = NULL;
142   internalBufSize = 0;
143 
144   // Call the generic search function which may be trapped by the different toolkits
145   refName.Search ();
146 
147   // Get the CLSID of the file
148   OLEFile file (refName, theStorageName);
149 
150   // TKTK Even though new is not used to allocate "file",
151   // an OLEError could have occurred in the OLEFile constructor
152   // The most prudent thing to do is to check for an OLEError NOW, and
153   // return if an error did occur.
154   file.GetCLSID(&id);
155 
156   if (id == idBaseline) {
157     // If this is a FPX Image object:
158     filePtr = NULL;                           // There is no Image View info
159     image   = new PFileFlashPixIO (refName, theStorageName, mode_Lecture);  // Just open directly the Image Object
160   } else if (id == idImageView) {
161     // If this is a FPX Image View object:
162     char sourceImageName [33];
163     filePtr = new PFileFlashPixView (refName, theStorageName, mode_Lecture,
164               visibleOutputIndex);              // Open the Image View
165     if (filePtr==NULL) {
166       return;
167     }
168     // PTCH_OBJFIX - use the index of the Source Description object to form the
169     //  name of the source storage.
170     GetImageStoreName(sourceImageName, filePtr->GetSourceDescNumber());
171     image = new PFileFlashPixIO(filePtr->GetRootStorage(), sourceImageName, mode_Lecture);  // Then open the source storage inside it
172   }
173 
174   if (image == NULL)
175     return;
176 
177   long status = ((PHierarchicalImage*)(image))->OpenImage();
178 
179   // Test if Image file is successfully opened
180   if (status || image->Status() != 0) {
181     delete image;
182     image = NULL;
183     return;
184   }
185 
186   // Init Viewing parameters
187   InitViewParameters();
188   transformsHaveBeenEdited  = FALSE;
189   imageHasBeenEdited      = FALSE;
190 
191   // Load the FPX Image View viewing parameters (must be done AFTER opening the image and
192   // initializing the viewing parameters)
193   OpenFile();
194 }
195 
196 
197 //  ----------------------------------------------------------------------------
198 // Open the file in Read Mode only
199 // CHG_VIS_OUT - added visibleOutputIndex argument to be passed to PFileFlashPixView
PFlashPixImageView(OLEStorage * theOwningStorage,const char * theStorageName,long visibleOutputIndex)200 PFlashPixImageView::PFlashPixImageView (OLEStorage* theOwningStorage, const char* theStorageName,
201                     long visibleOutputIndex) : ViewImage()
202 {
203   CLSID idBaseline     = ID_Baseline;
204   CLSID idImageView    = ID_ImageView;
205   CLSID id;
206 
207   // Init the file pointers
208   filePtr = NULL;
209   image   = NULL;
210 
211   internalBuffer = NULL;
212   internalBufSize = 0;
213 
214   // Get the CLSID of the storage
215   {
216   STATSTG stat;
217   theOwningStorage->Stat(&stat);
218   id = stat.clsid;
219   }
220 
221   if (id == idBaseline) {
222     // If this is a FPX Image object:
223     filePtr = NULL;                                 // There is no Image View info
224     image   = new PFileFlashPixIO (theOwningStorage, theStorageName, mode_Lecture); // Just open directly the Image Object
225   } else if (id == idImageView) {
226     // If this is a FPX Image View object:
227     filePtr = new PFileFlashPixView (theOwningStorage, theStorageName, mode_Lecture,
228                     visibleOutputIndex);              // Open the Image View
229     if (filePtr==NULL) {
230       return;
231     }
232 
233     // PTCH_OBJFIX - use the index of the Source Description object to form the
234     //  name of the source storage.
235     char sourceImageName [33];
236     GetImageStoreName(sourceImageName, filePtr->GetSourceDescNumber());
237     image = new PFileFlashPixIO(filePtr->GetRootStorage(), sourceImageName, mode_Lecture);  // Then open the source storage inside it
238   }
239 
240   if (image == NULL)
241     return;
242 
243   long status = ((PHierarchicalImage*)(image))->OpenImage();
244 
245   // Test if Image file is successfully opened
246   if (status || image->Status() != 0) {
247     delete image;
248     image = NULL;
249     return;
250   }
251 
252   // Init Viewing parameters
253   InitViewParameters();
254   transformsHaveBeenEdited  = FALSE;
255   imageHasBeenEdited      = FALSE;
256 
257   // Load the FPX Image View viewing parameters (must be done AFTER opening the image and
258   // initializing the viewing parameters)
259   OpenFile();
260 }
261 
262 
263 //  ----------------------------------------------------------------------------
264 // Open the file in Create Mode
PFlashPixImageView(FicNom & refName,int width,int height,float resolution,FPXBaselineColorSpace baseSpace,unsigned long backColor,FPXCompressionOption FPXCompressOption,Boolean createFPXImageView,Boolean baseUncalibrated)265 PFlashPixImageView::PFlashPixImageView (FicNom& refName, int width, int height, float resolution,
266                   FPXBaselineColorSpace baseSpace, unsigned long backColor,
267                   FPXCompressionOption FPXCompressOption, Boolean createFPXImageView, Boolean baseUncalibrated)
268                   : ViewImage(refName)
269 {
270 
271   internalBuffer = NULL;
272   internalBufSize = 0;
273 
274   if (!createFPXImageView) {
275     filePtr = NULL;                             // There is no Image View info
276     // Create directly the Image Object
277     image   = new PFileFlashPixIO (refName, width, height, resolution, baseSpace, backColor, FPXCompressOption, baseUncalibrated);
278   }
279   else {
280     // Create a FPX Image View object:
281     char sourceImageName [33];
282     filePtr = new PFileFlashPixView (refName, NULL, mode_Ecrasement);
283     if (filePtr==NULL) {
284       return;
285     }
286     GetImageStoreName(sourceImageName, 1);
287     // Then create a FPX Image Object inside it
288     image = new PFileFlashPixIO(filePtr->GetRootStorage(), sourceImageName,
289                  width, height, resolution, baseSpace, backColor, FPXCompressOption, baseUncalibrated);
290   }
291 
292   if (image == NULL)
293     return;
294 
295   long status = ((PHierarchicalImage*)(image))->OpenImage();
296 
297   // Test if the FPX Image Object has been successfully opened
298   if (status || image->Status() != 0) {
299     delete image;
300     image = NULL;
301     return;
302   }
303 
304   // Init Viewing parameters
305   InitViewParameters();
306   transformsHaveBeenEdited  = FALSE;
307   imageHasBeenEdited      = TRUE;
308 
309   // Normalize the FPX Image View viewing parameters (must be done AFTER opening the image and
310   // initializing the viewing parameters)
311   OpenFile();
312 }
313 
314 
315 //  ----------------------------------------------------------------------------
316 // Open the file in Create Mode
PFlashPixImageView(OLEStorage * theOwningStorage,const char * theStorageName,int width,int height,float resolution,FPXBaselineColorSpace baseSpace,unsigned long backColor,FPXCompressionOption FPXCompressOption,Boolean createFPXImageView,Boolean baseUncalibrated)317 PFlashPixImageView::PFlashPixImageView (OLEStorage* theOwningStorage, const char* theStorageName, int width, int height, float resolution,
318                   FPXBaselineColorSpace baseSpace, unsigned long backColor,
319                   FPXCompressionOption FPXCompressOption, Boolean createFPXImageView, Boolean baseUncalibrated)
320                   : ViewImage()
321 {
322   internalBuffer = NULL;
323   internalBufSize = 0;
324 
325   if (!createFPXImageView) {
326     filePtr = NULL;                             // There is no Image View info
327     // Create directly the Image Object
328     image   = new PFileFlashPixIO (theOwningStorage, theStorageName, width, height, resolution, baseSpace, backColor, FPXCompressOption, baseUncalibrated);
329   }
330   else {
331     // Create a FPX Image View object:
332     char sourceImageName [33];
333     filePtr = new PFileFlashPixView (theOwningStorage, theStorageName, mode_Ecrasement);
334     if (filePtr==NULL) {
335       return;
336     }
337     GetImageStoreName(sourceImageName, 1);
338 
339     // Then create a FPX Image Object inside it
340     image = new PFileFlashPixIO(filePtr->GetRootStorage(), sourceImageName,
341                  width, height, resolution, baseSpace, backColor, FPXCompressOption, baseUncalibrated);
342   }
343 
344   if (image == NULL)
345     return;
346 
347   long status = ((PHierarchicalImage*)(image))->OpenImage();
348 
349   // Test if Image file is successfully opened
350   if (status || image->Status() != 0) {
351     delete image;
352     image = NULL;
353     return;
354   }
355 
356   // Init Viewing parameters
357   InitViewParameters();
358   transformsHaveBeenEdited  = FALSE;
359   imageHasBeenEdited      = TRUE;
360 
361   // Normalize the FPX Image View viewing parameters (must be done AFTER opening the image and
362   // initializing the viewing parameters)
363   OpenFile();
364 }
365 
366 
367 //  ----------------------------------------------------------------------------
368 // Open the file in Read/Write mode (but not Create)
369 // CHG_VIS_OUT - added visibleOutputIndex argument to be passed to PFileFlashPixView
PFlashPixImageView(FicNom & refName,const char * theStorageName,mode_Ouverture openMode,long visibleOutputIndex,PSearchHookObject *,FPXStatus * fpxStatus)370 PFlashPixImageView::PFlashPixImageView (FicNom& refName, const char* theStorageName,
371                                         mode_Ouverture openMode, long visibleOutputIndex,
372                                         PSearchHookObject* /*hook*/, FPXStatus *fpxStatus)
373   : ViewImage(refName),
374     readOnlyFile(FALSE)
375 {
376   CLSID idBaseline  = ID_Baseline;
377   CLSID idImageView = ID_ImageView;
378   CLSID id;
379 
380   internalBuffer = NULL;
381   internalBufSize = 0;
382 
383   // Call the generic search function which may be trapped by the different toolkits
384   refName.Search ();
385 
386   // Get the CLSID of the file
387   OLEFile file (refName, theStorageName);
388 
389   file.GetCLSID(&id);
390   *fpxStatus = file.getFPXStatus();
391   if(*fpxStatus != FPX_OK)
392     return;
393 
394   if(file.isFileReadOnly())
395     readOnlyFile = TRUE;
396 
397   if (id == idBaseline) {
398     // If this is a FPX Image object:
399     filePtr = NULL;                         // There is no Image View info
400     image   = new PFileFlashPixIO (refName, theStorageName, openMode);  // Just open directly the Image Object
401   } else if (id == idImageView) {
402     // If this is a FPX Image View object:
403     char sourceImageName [33];
404     filePtr = new PFileFlashPixView (refName, theStorageName, openMode,
405                                      visibleOutputIndex);      // Open the Image View
406     if (filePtr == NULL) {
407       return;
408     }
409     // PTCH_OBJFIX - use the index of the Source Description object to form the
410     //  name of the source storage.
411     GetImageStoreName(sourceImageName, filePtr->GetSourceDescNumber());
412     image = new PFileFlashPixIO(filePtr->GetRootStorage(), sourceImageName, openMode);  // Then open the source storage inside it
413   }
414 
415   if (image == NULL)
416     return;
417 
418   long status = ((PHierarchicalImage*)(image))->OpenImage();
419 
420   // Test if Image file is successfully opened
421   if (status || image->Status() != 0) {
422     delete image;
423     image = NULL;
424     return;
425   }
426 
427   // Init Viewing parameters
428   InitViewParameters();
429   transformsHaveBeenEdited  = FALSE;
430   imageHasBeenEdited      = FALSE;
431 
432   // Load the FPX Image View viewing parameters (must be done AFTER opening the image and
433   // initializing the viewing parameters)
434   OpenFile();
435 }
436 
437 
438 //  ----------------------------------------------------------------------------
439 // Open the file in Read/Write mode (but not Create)
440 //  Called in ByStorage method
441 // CHG_VIS_OUT - added visibleOutputIndex argument to be passed to PFileFlashPixView
PFlashPixImageView(OLEStorage * theOwningStorage,const char * theStorageName,mode_Ouverture openMode,long visibleOutputIndex,FPXStatus * fpxStatus)442 PFlashPixImageView::PFlashPixImageView (OLEStorage* theOwningStorage, const char* theStorageName,
443                       mode_Ouverture openMode, long visibleOutputIndex,
444                       FPXStatus * fpxStatus ) : ViewImage()
445 
446 {
447   CLSID idBaseline  = ID_Baseline;
448   CLSID idImageView = ID_ImageView;
449   CLSID id;
450 
451   internalBuffer = NULL;
452   internalBufSize = 0;
453 
454   // Get the CLSID of the storage
455   {
456   STATSTG stat;
457   theOwningStorage->Stat(&stat);
458   id = stat.clsid;
459   }
460 
461   if (id == idBaseline) {
462     // If this is a FPX Image object:
463     filePtr = NULL;                               // There is no Image View info
464     image   = new PFileFlashPixIO (theOwningStorage, theStorageName, openMode); // Just open directly the Image Object
465   } else if (id == idImageView) {
466     // If this is a FPX Image View object:
467     char sourceImageName [33];
468     filePtr = new PFileFlashPixView (theOwningStorage, theStorageName, openMode,
469                     visibleOutputIndex);            // Open the Image View
470     if (filePtr==NULL) {
471       return;
472     }
473     // PTCH_OBJFIX - use the index of the Source Description object to form the
474     //  name of the source storage.
475     GetImageStoreName(sourceImageName, filePtr->GetSourceDescNumber());
476     image = new PFileFlashPixIO(filePtr->GetRootStorage(), sourceImageName, openMode);  // Then open the source storage inside it
477   }
478 
479   if (image == NULL)
480     return;
481 
482   long status = ((PHierarchicalImage*)(image))->OpenImage();
483 
484   // Test if Image file is successfully opened
485   if (status || image->Status() != 0) {
486     delete image;
487     image = NULL;
488     return;
489   }
490 
491   // Init Viewing parameters
492   InitViewParameters();
493   transformsHaveBeenEdited  = FALSE;
494   imageHasBeenEdited      = FALSE;
495 
496   // Load the FPX Image View viewing parameters (must be done AFTER opening the image and
497   // initializing the viewing parameters)
498   OpenFile();
499 }
500 
501 
502 //  ----------------------------------------------------------------------------
503 // Create a FPX Image View from an already opened image
PFlashPixImageView(PRIImage * theImage)504 PFlashPixImageView::PFlashPixImageView (PRIImage* theImage) : ViewImage(theImage)
505 {
506   filePtr = NULL;
507 }
508 
509 
510 //  ----------------------------------------------------------------------------
~PFlashPixImageView()511 PFlashPixImageView::~PFlashPixImageView ()
512 {
513   // Write things in the FPX Image View file if necessary and close it
514   if (transformsHaveBeenEdited || imageHasBeenEdited)
515     CloseFile();
516 
517   // Delete Image if present: to be done BEFORE deleting the embedding file
518   if (image && !doNotDelete) {
519     delete image;
520     image = NULL;   // Reinit to avoid crash destruction in ViewImage
521   }
522 
523   // Close and delete the embedding file
524   delete filePtr;
525   filePtr = NULL;
526 
527   if(internalBuffer)
528   {
529     delete internalBuffer;
530     internalBuffer = NULL;
531   }
532 }
533 
setInternalBuffer(long width,long height)534 void PFlashPixImageView::setInternalBuffer(long width, long height)
535 {
536   if(width * height * 4 > internalBufSize)
537   {
538     delete internalBuffer;
539     internalBuffer = NULL;
540     internalBuffer = new unsigned char[width * height * 4];
541     internalBufSize = width*height*4;
542   }
543 }
544 
545 //  ----------------------------------------------------------------------------
OpenFile()546 FPXStatus PFlashPixImageView::OpenFile()
547 {
548   FPXStatus status = FPX_OK;
549 
550   // Init the transform values to default
551   InitTransformProperties();
552 
553   // Load all tranform values from the file
554   LoadImageResultAspectRatio();
555   LoadImageROI();
556   LoadImageFilteringValue();
557   LoadImageAffineMatrix();
558   LoadImageColorTwistMatrix();
559   LoadImageContrastAdjustment();
560 
561   // Renormalize the original image size to 1 mm in height
562   normalizationRatio = originHeight;
563   width  /= normalizationRatio;
564   height /= normalizationRatio;
565   originWidth  /= normalizationRatio;
566   originHeight /= normalizationRatio;
567   int pixWidth, pixHeight;
568   image->GetTrueDimensions(&pixWidth,&pixHeight);
569   float resolution = (float)(pixHeight) / (float)(1.0);
570   image->SetImageSize(pixWidth,pixHeight,resolution);
571 
572   // Update the parent object geometric parameters: original crop
573   SetImageCrop ( regionOfInterest.left,
574            regionOfInterest.top ,
575            regionOfInterest.left + regionOfInterest.width ,
576            regionOfInterest.top  + regionOfInterest.height);
577 
578   // Update the parent object geometric parameters: position matrix
579   // The transformation is limited to the Baseline case, i.e., 2D affine transformation  (see Appendix A, par. A.3.2)
580   TransfoPerspective normPos (affineMatrix.a11, affineMatrix.a21,   // 2D scale, rotation and skewing
581                   affineMatrix.a12, affineMatrix.a22,
582                   affineMatrix.a14, affineMatrix.a24,   // Translation
583                   affineMatrix.a31, affineMatrix.a32);  // Perspective
584   position = normPos;
585 
586   // Update the parent object geometric parameters: final crop
587   finalWidth  = aspectRatio;
588   finalHeight = (float)1.0;
589   resizeFinalDimensions = FALSE;
590 
591   // Update the parent object display parameters:
592   SetFiltering (filtering);
593   SetContrast (contrastAdjustment);
594 
595 
596   PColorTwist twistMatrix (colorTwistMatrix);
597   SetColorTwist (&twistMatrix);
598 
599   return status;
600 }
601 
602 
603 //  ----------------------------------------------------------------------------
CloseFile()604 FPXStatus PFlashPixImageView::CloseFile()
605 {
606   FPXStatus status = FPX_OK;
607 
608   if(hasAffineMatrix)
609   {
610     LoadImageAffineMatrix();
611 
612     // Update the parent object geometric parameters: position matrix
613     // The transformation is limited to the Baseline case, i.e., 2D affine transformation  (see Appendix A, par. A.3.2)
614     TransfoPerspective normPos (affineMatrix.a11, affineMatrix.a21,   // 2D scale, rotation and skewing
615                   affineMatrix.a12, affineMatrix.a22,
616                   affineMatrix.a14, affineMatrix.a24,   // Translation
617                   affineMatrix.a31, affineMatrix.a32);
618 
619 
620     TransfoPerspective translat ((float)1.0, (float)0.0,(float) 0.0,(float) 1.0, -regionOfInterest.left, -regionOfInterest.top);
621 
622     position = normPos * translat;
623 
624     // Update the parent object geometric parameters: final crop
625     finalWidth  = aspectRatio;
626     finalHeight = (float)1.0;
627     resizeFinalDimensions = FALSE;
628   }
629   if(hasFiltering)
630   {
631     LoadImageFilteringValue();
632     SetFiltering(filtering);
633   }
634   if(hasColorTwistMatrix)
635   {
636     LoadImageColorTwistMatrix();
637     PColorTwist twistMatrix (colorTwistMatrix);
638     SetColorTwist (&twistMatrix);
639   }
640 
641   if(hasContrastAdjustment)
642   {
643     LoadImageContrastAdjustment();
644     SetContrast(contrastAdjustment);
645   }
646   // Update the geometric parameters using the parent object: final crop
647   aspectRatio =  finalWidth / finalHeight;
648 
649   // Update the geometric parameters using the parent object: original crop
650   regionOfInterest.left   = cropX0;
651   regionOfInterest.top    = cropY0;
652   regionOfInterest.width  = cropX1 - cropX0;
653   regionOfInterest.height = cropY1 - cropY0;
654 
655   // Update the geometric parameters using the parent object: position matrix
656   // The transformation is limited to the Baseline case, i.e., 2D affine transformation  (see Appendix A, par. A.3.2)
657   TransfoPerspective translat ((float)1.0,(float) 0.0,(float)0.0,(float) 1.0, regionOfInterest.left, regionOfInterest.top);
658 
659   TransfoPerspective normPos = position * translat;
660 
661   float a, b, c, d, x0, y0, px, py;
662   normPos.GetAffineMatrix(&a,&b,&c,&d,&x0,&y0);
663   normPos.GetPerspective(&px,&py);
664   affineMatrix.a11 = a; affineMatrix.a12 = c; affineMatrix.a13 = (float)0.0; affineMatrix.a14 = x0;
665   affineMatrix.a21 = b; affineMatrix.a22 = d; affineMatrix.a23 = (float)0.0; affineMatrix.a24 = y0;
666   affineMatrix.a31 = px;
667   affineMatrix.a32 = py;
668   affineMatrix.a33 = (float)1.0; affineMatrix.a34 = (float)0.0;
669   affineMatrix.a41 = (float)0.0; affineMatrix.a42 = (float)0.0; affineMatrix.a43 = (float)0.0; affineMatrix.a44 = (float)1.0;
670 
671   // Update the display parameters using the parent object:
672   PColorTwist twistMatrix;
673   GetFiltering (&filtering);
674   GetContrast (&contrastAdjustment);
675   GetColorTwist (&twistMatrix);
676   twistMatrix.ConvertToFPX(&colorTwistMatrix);
677 
678   // Save the Property Sets: this is a straighforward implementation of the default
679   // baseline behavior as specified in the spec.
680 
681   if(transformsHaveBeenEdited  || imageHasBeenEdited)
682   {
683     if (status == FPX_OK)
684       status = SaveSummaryInfoPropertySet();
685     if (status == FPX_OK)
686       status = SaveGlobalInfoPropertySet();
687     if (status == FPX_OK)
688       status = SaveSourcePropertySet();
689   }
690 
691   if ( (hasRegionOfInterest || hasAffineMatrix || hasAspectRatio  ||
692         hasFiltering || hasColorTwistMatrix || hasContrastAdjustment) && transformsHaveBeenEdited)
693   {
694     // The Result Property Set is created only if there is a viewing transform
695     if (status == FPX_OK)
696       status = SaveResultPropertySet();
697 
698     // The Transform Property Set is created only if there is a viewing transform
699     if (status == FPX_OK)
700       status = SaveTransformPropertySet();
701     if (status == FPX_OK)
702       status = SaveImageROI();
703     if (status == FPX_OK)
704       status = SaveImageResultAspectRatio();
705 
706     // The Operation Property Set is created only if there is a viewing transform
707     if (status == FPX_OK)
708       status = SaveOperationPropertySet();
709   }
710 
711   if (status == FPX_OK)
712     status = SaveExtensionListPropertySet();
713 
714   return status;
715 }
716 
717 
718 //  ------------------------------------------------------------------------------------
719 //  Default Baseline Behavior for FPX Image View Properties Access
720 //  There's no interface provided to the user to update these property sets. When saving
721 //  them, all SaveXxPropertySet() do the same:
722 //    - declare a record to hold the values
723 //    - init this record with default values
724 //    - read the values from the file
725 //    - update the values if necessary
726 //    - write back the values in the file
727 //  ------------------------------------------------------------------------------------
SaveSummaryInfoPropertySet()728 FPXStatus PFlashPixImageView::SaveSummaryInfoPropertySet()
729 {
730   FPXStatus status = FPX_OK;
731 
732   OLEProperty* aProp;
733   OLEProperty* aProp0;
734 
735 
736   // Create a thumbnail image in summary info property set if it doesn't exist
737   if ( filePtr ) {
738     if ( !filePtr->GetSummaryInfoProperty (PID_THUMBNAIL, &aProp0) ) {
739       if ( filePtr->SetSummaryInfoProperty (PID_THUMBNAIL, TYP_THUMBNAIL, &aProp) ) {
740         status = MakeNewThumbnail ( aProp);
741       } else
742         status = FPX_NOT_A_VIEW;
743 
744     // Else if image has been changed, write the thumbnail image again
745     } else if ( imageHasBeenEdited || transformsHaveBeenEdited ) {
746 
747       if ( filePtr->SetSummaryInfoProperty (PID_THUMBNAIL, TYP_THUMBNAIL, &aProp) ) {
748         status = MakeNewThumbnail ( aProp);
749       } else
750         status = FPX_NOT_A_VIEW;
751     } else
752       status = FPX_NOT_A_VIEW;
753   } else
754     status = FPX_NOT_A_VIEW;
755   return status;
756 }
757 
758 
759 //  ----------------------------------------------------------------------------
760 // Create a new thumbnail image and save it in the file
MakeNewThumbnail(OLEProperty * aProp)761 FPXStatus PFlashPixImageView::MakeNewThumbnail ( OLEProperty *aProp)
762 {
763   FPXStatus status = FPX_OK;
764 
765   // Determine the width and height of thumbnail
766   long  thumbNailWidth, thumbNailHeight;
767   if ( finalWidth >= finalHeight ) {
768     thumbNailWidth = MaxThumbNailSize;
769     thumbNailHeight = (long)((float)( thumbNailWidth * finalHeight ) / (float)finalWidth);
770   }
771   else {
772     thumbNailHeight = MaxThumbNailSize;
773     thumbNailWidth = (long)((float)( thumbNailHeight * finalWidth ) / (float)finalHeight);
774   }
775 
776   // The thumbnail should either be monochrome or 24-bit RGB (never YCC). Save the old
777   //  image's colorSpace and force a new one specifically for the thumbnail
778   // CHG_MONO_TINT - since a mono image is affected by colorTwist, don't make a
779   //  monochrome thumbnail if there is a colorTwist defined.
780   FPXBaselineColorSpace imageColorSpace = ((PFileFlashPixIO *)image)->baseSpace,
781               tnailColorSpace;
782   if (((imageColorSpace == SPACE_32_BITS_MA) || (imageColorSpace == SPACE_32_BITS_AM)
783    ||  (imageColorSpace == SPACE_32_BITS_M)) && (hasColorTwist == false) )
784     tnailColorSpace = SPACE_32_BITS_M;
785   else
786     tnailColorSpace = SPACE_32_BITS_RGB;
787   ((PFileFlashPixIO *)image)->SetUsedColorSpace( tnailColorSpace);
788 
789   // Create a buffer to hold the image to be created
790   FPXBufferDesc thumbNail( (long)1, thumbNailWidth, thumbNailHeight, tnailColorSpace);
791   if (thumbNail.Get32BitsBuffer() == NULL) {
792       return FPX_MEMORY_ALLOCATION_FAILED;
793   }
794 
795   // Thumbnails are to be composited on a white background. Save the old background
796   //  color and set the current background color to white.
797   Pixel         backgroundColor = GtheSystemToolkit->backgroundColor;
798   Pixel         whiteColor    = 0xFFFFFFFF;
799   GtheSystemToolkit->SetBackgroundColor (whiteColor, tnailColorSpace);
800 
801   // Now render a new thumbnail image
802   PageImage page (this, thumbNailWidth, thumbNailHeight, (float)0.0);
803   page.ReadPage(thumbNail.Get32BitsBuffer());
804 
805   // Create the thumbnail property in the CLIPDATA format
806   CLIPDATA  cf;
807   if ( CreateThumbnail((unsigned char *)thumbNail.Get32BitsBuffer(), tnailColorSpace,
808               (short)thumbNailWidth, (short)thumbNailHeight,&cf) )  {
809     *aProp = (CLIPDATA *)&cf;
810     delete[] cf.pClipData;
811   }
812   else
813     status = FPX_ERROR;
814 
815   // Reset the background color and colorSpace
816   GtheSystemToolkit->SetBackgroundColor (backgroundColor, imageColorSpace);
817   ((PFileFlashPixIO *)image)->SetUsedColorSpace( imageColorSpace);
818 
819   return status;
820 }
821 
822 
823 //  ----------------------------------------------------------------------------
SaveGlobalInfoPropertySet()824 FPXStatus PFlashPixImageView::SaveGlobalInfoPropertySet()
825 {
826   FPXStatus status = FPX_OK;
827 
828   // Declare a local record and initialize it with default values
829   FPXGlobalInfo globalInfo;
830   InitGlobalInfoPropertySet (&globalInfo);
831 
832   // Read the values already written in the file
833   status = GetGlobalInfoPropertySet (&globalInfo);
834 
835   if ( (hasRegionOfInterest || hasAffineMatrix    || hasAspectRatio       ||
836     hasFiltering    || hasColorTwistMatrix  || hasContrastAdjustment)
837     && transformsHaveBeenEdited)
838   {
839 
840     *(globalInfo.visibleOutputs.ptr)  = 2;
841     // Maximum index used by default
842     globalInfo.maxImageIndex     = 2; // 2 images (source and result)
843     globalInfo.maxTransformIndex = 1; // 1 transformation
844     globalInfo.maxOperatorIndex  = 1; // 1 operation
845   }
846   // Update with specific information
847   if (status == FPX_OK && (imageHasBeenEdited || transformsHaveBeenEdited)) {
848     if (globalInfo.lastModifierIsValid) {
849       FPX_DeleteFPXWideStr(&(globalInfo.lastModifier));
850       // This string has to be customized by the user in some ways...
851       FPX_WideStrcpy(&(globalInfo.lastModifier),"Reference Implementation");
852     }
853   }
854   // Write the values back in the file
855   if (status == FPX_OK)
856     status = SetGlobalInfoPropertySet (&globalInfo);
857 
858   return status;
859 
860 }
861 
862 
863 //  ----------------------------------------------------------------------------
SaveSourcePropertySet()864 FPXStatus PFlashPixImageView::SaveSourcePropertySet()
865 {
866   FPXStatus   status = FPX_OK;
867 
868   // Declare a local record and initialize it with default values
869   FPXImageDescription imageDesc;
870   InitSourcePropertySet (&imageDesc);
871 
872   // Read the values already written in the file
873   status = GetSourcePropertySet (&imageDesc);
874 
875   // CHG_WRT_USERS - If there is a result property set, then a 'users' array must be
876   //      written. So test for a result property set and write 'users' if need be.
877   OLEProperty     *aProp;
878   long        hasResultPropSet = 0;
879 
880   if (filePtr)
881     if (filePtr->GetResultDescProperty (PID_ImageID, &aProp))
882       hasResultPropSet = 1;
883 
884   if((hasRegionOfInterest   || hasAffineMatrix    || hasAspectRatio       ||
885     hasFiltering      || hasColorTwistMatrix  || hasContrastAdjustment  ||
886     hasResultPropSet))
887   {
888     if(!imageDesc.users.ptr)
889       FPX_AllocFPXLongArray(&(imageDesc.users) ,1);
890     *(imageDesc.users.ptr)  = 1;
891   }
892   else
893     // users should be 0 element array
894     imageDesc.users.length  = 0;
895 
896   // Update the informations if the transformations have been modified
897   if (status == FPX_OK && imageHasBeenEdited) {
898     if (imageDesc.lastModifierIsValid) {
899       FPX_DeleteFPXWideStr(&(imageDesc.lastModifier));
900       // This string has to be customized by the user in some ways...
901       FPX_WideStrcpy(&(imageDesc.lastModifier),"Reference Implementation");
902     }
903     if (imageDesc.revisionNumberIsValid)
904       imageDesc.revisionNumber += 1;
905 
906     if (imageDesc.modificationDateIsValid)
907       FPXUpdateTime(&(imageDesc.modificationDate));
908 
909     if (imageDesc.creatingApplicationIsValid) {
910       FPX_DeleteFPXWideStr(&(imageDesc.lastModifier));
911 
912       // This string has to be customized by the user in some ways...
913       FPX_WideStrcpy(&(imageDesc.creatingApplication),"Reference Implementation");
914     }
915   }
916 
917   // PTCH_CACHEIMGSIZ - the size of the cached source image is required. If the size
918   //  has not been set, then do so before saving.
919   if ((imageDesc.heightIsValid == FALSE) || (imageDesc.widthIsValid == FALSE)) {
920     int  w = 0;
921     int  h = 0;
922     if (image)
923       image->GetDimensions (&w, &h);
924     imageDesc.height = h;
925     imageDesc.width  = w;
926     imageDesc.heightIsValid = TRUE;
927     imageDesc.widthIsValid  = TRUE;
928   }
929 
930   // Write the values back in the file
931   if (status == FPX_OK)
932     status = SetSourcePropertySet (&imageDesc);
933 
934   // Release the memory allocated (if any...)
935   FPX_DeleteFPXLongArray (&(imageDesc.lockedProperties));
936   FPX_DeleteFPXWideStr   (&(imageDesc.dataObjectTitle));
937   FPX_DeleteFPXWideStr   (&(imageDesc.lastModifier));
938   FPX_DeleteFPXWideStr   (&(imageDesc.creatingApplication));
939   FPX_DeleteFPXLongArray (&(imageDesc.users));
940 
941   return status;
942 }
943 
944 
945 
946 //  ----------------------------------------------------------------------------
SaveResultPropertySet()947 FPXStatus PFlashPixImageView::SaveResultPropertySet()
948 {
949   FPXStatus status = FPX_OK;
950 
951   // Declare a local record and initialize it with default values
952   FPXImageDescription imageDesc;
953   InitResultPropertySet (&imageDesc);
954 
955   // Read the values already written in the file
956   status = GetResultPropertySet (&imageDesc);
957 
958   // Nothing to update in the result (the Reference Implementation never update the result)
959 
960   // Write the values back in the file
961   if (status == FPX_OK)
962     status = SetResultPropertySet (&imageDesc);
963 
964   // Release the memory allocated (if any...)
965   FPX_DeleteFPXLongArray (&(imageDesc.lockedProperties));
966   FPX_DeleteFPXWideStr   (&(imageDesc.dataObjectTitle));
967   FPX_DeleteFPXWideStr   (&(imageDesc.lastModifier));
968   FPX_DeleteFPXWideStr   (&(imageDesc.creatingApplication));
969   FPX_DeleteFPXLongArray (&(imageDesc.users));
970 
971   return status;
972 }
973 
974 
975 //  ----------------------------------------------------------------------------
SaveTransformPropertySet()976 FPXStatus PFlashPixImageView::SaveTransformPropertySet()
977 {
978   FPXStatus status = FPX_OK;
979 
980   // Declare a local record and initialize it with default values
981   FPXTransform transform;
982   InitTransformPropertySet (&transform);
983 
984   // Read the values already written in the file
985   status = GetTransformPropertySet (&transform);
986 
987   // Update the informations if the transformations have been modified
988   if (status == FPX_OK && transformsHaveBeenEdited) {
989     if (transform.lastModifierIsValid) {
990       FPX_DeleteFPXWideStr(&(transform.lastModifier));
991 
992       // This string has to be customized by the user in some ways...
993       FPX_WideStrcpy(&(transform.lastModifier),"Reference Implementation");
994     }
995     if (transform.revisionNumberIsValid)
996       transform.revisionNumber += 1;
997     if (transform.modificationDateIsValid)
998       FPXUpdateTime(&(transform.modificationDate));
999 
1000     if (transform.creatingApplicationIsValid) {
1001       FPX_DeleteFPXWideStr(&(transform.lastModifier));
1002       // This string has to be customized by the user in some ways...
1003       FPX_WideStrcpy(&(transform.creatingApplication),"Reference Implementation");
1004     }
1005   }
1006   // Write the values back in the file
1007   if (status == FPX_OK)
1008     status = SetTransformPropertySet (&transform);
1009   // Release the memory allocated (if any...)
1010   FPX_DeleteFPXLongArray (&(transform.lockedProperties));
1011   FPX_DeleteFPXWideStr   (&(transform.transformTitle));
1012   FPX_DeleteFPXWideStr   (&(transform.lastModifier));
1013   FPX_DeleteFPXWideStr   (&(transform.creatingApplication));
1014   FPX_DeleteFPXLongArray (&(transform.inputDataObjects));
1015   FPX_DeleteFPXLongArray (&(transform.outputDataObjects));
1016 
1017   return status;
1018 }
1019 
1020 
1021 //  ----------------------------------------------------------------------------
SaveOperationPropertySet()1022 FPXStatus PFlashPixImageView::SaveOperationPropertySet()
1023 {
1024   FPXStatus status = FPX_OK;
1025 
1026   // Declare a local record and initialize it with default values
1027   FPXOperation operation;
1028   InitOperationPropertySet (&operation);
1029 
1030   // Read the values already written in the file
1031   status = GetOperationPropertySet (&operation);
1032 
1033   // There is absolutly nothing to be updated here in Baseline.
1034 
1035   // Write the values back in the file
1036   if (status == FPX_OK)
1037     status = SetOperationPropertySet (&operation);
1038 
1039   return status;
1040 }
1041 
1042 
1043 //  ----------------------------------------------------------------------------
SaveExtensionListPropertySet()1044 FPXStatus PFlashPixImageView::SaveExtensionListPropertySet()
1045 {
1046   return FPX_OK;
1047 }
1048 
1049 
1050 //  ----------------------------------------------------------------------------
InitGlobalInfoPropertySet(FPXGlobalInfo * theGlobalInfo)1051 void PFlashPixImageView::InitGlobalInfoPropertySet(FPXGlobalInfo* theGlobalInfo)
1052 {
1053   // None of the optionnal property is made mandatory in the Reference Implementation
1054   theGlobalInfo->lockedPropertiesIsValid    = FALSE;
1055   theGlobalInfo->transformedImageTitleIsValid = FALSE;
1056   theGlobalInfo->lastModifierIsValid      = FALSE;
1057 
1058   // Initialize the arrays
1059   InitFPXLongArray (&(theGlobalInfo->lockedProperties));
1060   InitFPXWideStr   (&(theGlobalInfo->transformedImageTitle));
1061   InitFPXWideStr   (&(theGlobalInfo->lastModifier));
1062 
1063   // Default is the number of the source image
1064   FPX_AllocFPXLongArray(&(theGlobalInfo->visibleOutputs) ,1);
1065   *(theGlobalInfo->visibleOutputs.ptr)  = 1;
1066 
1067   // Maximum index used by default
1068   theGlobalInfo->maxImageIndex     = 1; // 2 images (source and result)
1069   theGlobalInfo->maxTransformIndex = 0; // 1 transformation
1070   theGlobalInfo->maxOperatorIndex  = 0; // 1 operation
1071 }
1072 
1073 
1074 //  ----------------------------------------------------------------------------
InitSourcePropertySet(FPXImageDescription * theImageDesc)1075 void PFlashPixImageView::InitSourcePropertySet(FPXImageDescription* theImageDesc)
1076 {
1077   CLSID clsImageDesID;          // Generate a unique ID (what for?)
1078   GenGuid(&clsImageDesID);
1079   theImageDesc->dataObjectID  = clsImageDesID;
1080 
1081   // None of the optionnal property is made mandatory in the Reference Implementation
1082   theImageDesc->lockedPropertiesIsValid     = FALSE;
1083   theImageDesc->dataObjectTitleIsValid    = FALSE;
1084   theImageDesc->lastModifierIsValid       = FALSE;
1085   theImageDesc->revisionNumberIsValid     = FALSE;
1086   theImageDesc->creationDateIsValid       = FALSE;
1087   theImageDesc->modificationDateIsValid     = FALSE;
1088   theImageDesc->creatingApplicationIsValid  = FALSE;
1089 
1090   // Initialize the arrays
1091   InitFPXLongArray (&(theImageDesc->lockedProperties));
1092   InitFPXWideStr   (&(theImageDesc->dataObjectTitle));
1093   InitFPXWideStr   (&(theImageDesc->lastModifier));
1094   InitFPXWideStr   (&(theImageDesc->creatingApplication));
1095 
1096   // The default status is no cached result (useless...), so:
1097   // The source image is there and you cannot purge it...
1098   theImageDesc->status.existenceData    = FPX_DATA_CACHED;
1099   theImageDesc->status.permission     = FPX_DATA_NOT_PURGEABLE;
1100 
1101   // Always 0, according to the spec (see par. VIII.1.1)
1102   theImageDesc->creator = 0;
1103 
1104   // Must be the same as the operationNumber in the default transform property set
1105   FPX_AllocFPXLongArray(&(theImageDesc->users) ,1);
1106   *(theImageDesc->users.ptr)  = 1;
1107 
1108   // Get the pixels dimensions of the source image
1109   theImageDesc->heightIsValid = TRUE;
1110   theImageDesc->widthIsValid  = TRUE;
1111   int w = 0;
1112   int h = 0;
1113   if (image)
1114     image->GetDimensions (&w, &h);
1115   theImageDesc->height = h;
1116   theImageDesc->width  = w;
1117 }
1118 
1119 
1120 //  ----------------------------------------------------------------------------
InitResultPropertySet(FPXImageDescription * theImageDesc)1121 void PFlashPixImageView::InitResultPropertySet(FPXImageDescription* theImageDesc)
1122 {
1123   CLSID clsImageDesID;          // Generate a unique ID (what for?)
1124   GenGuid(&clsImageDesID);
1125   theImageDesc->dataObjectID  = clsImageDesID;
1126 
1127   // None of the optionnal property is made mandatory in the Reference Implementation
1128   theImageDesc->lockedPropertiesIsValid     = FALSE;
1129   theImageDesc->dataObjectTitleIsValid    = FALSE;
1130   theImageDesc->lastModifierIsValid       = FALSE;
1131   theImageDesc->revisionNumberIsValid     = FALSE;
1132   theImageDesc->creationDateIsValid       = FALSE;
1133   theImageDesc->modificationDateIsValid     = FALSE;
1134   theImageDesc->creatingApplicationIsValid  = FALSE;
1135 
1136   // Initialize the arrays
1137   InitFPXLongArray (&(theImageDesc->lockedProperties));
1138   InitFPXWideStr   (&(theImageDesc->dataObjectTitle));
1139   InitFPXWideStr   (&(theImageDesc->lastModifier));
1140   InitFPXWideStr   (&(theImageDesc->creatingApplication));
1141 
1142   // The default status is no cached result (useless...), so:
1143   // The result image is not there and you can purge it (well... sort of... it's not there...)
1144   theImageDesc->status.existenceData    = FPX_DATA_NOT_CACHED;
1145   theImageDesc->status.permission     = FPX_DATA_PURGEABLE;
1146 
1147   // Must the same as the operationNumber in the default transform property set
1148   theImageDesc->creator = 1;
1149 
1150   // No user for the result
1151   InitFPXLongArray (&(theImageDesc->users));
1152 
1153   // No cached image so no size
1154   theImageDesc->heightIsValid = FALSE;
1155   theImageDesc->widthIsValid  = FALSE;
1156   theImageDesc->height    = 0;
1157   theImageDesc->width     = 0;
1158 }
1159 
1160 
1161 //  ----------------------------------------------------------------------------
InitTransformPropertySet(FPXTransform * theTransform)1162 void PFlashPixImageView::InitTransformPropertySet(FPXTransform* theTransform)
1163 {
1164   CLSID clsTransformID;               // Generate a unique ID (what for?)
1165   GenGuid(&clsTransformID);
1166   CLSID clsOperationID = ID_Transform;        // Always this value in Baseline
1167   theTransform->transformNodeID  = clsTransformID;
1168   theTransform->operationClassID = clsOperationID;
1169 
1170   // None of the optionnal property is made mandatory in the Reference Implementation
1171   theTransform->lockedPropertiesIsValid     = FALSE;
1172   theTransform->transformTitleIsValid     = FALSE;
1173   theTransform->lastModifierIsValid       = FALSE;
1174   theTransform->revisionNumberIsValid     = FALSE;
1175   theTransform->creationDateIsValid       = FALSE;
1176   theTransform->modificationDateIsValid     = FALSE;
1177   theTransform->creatingApplicationIsValid  = FALSE;
1178 
1179   // Initialize the arrays
1180   InitFPXLongArray (&(theTransform->lockedProperties));
1181   InitFPXWideStr   (&(theTransform->transformTitle));
1182   InitFPXWideStr   (&(theTransform->lastModifier));
1183   InitFPXWideStr   (&(theTransform->creatingApplication));
1184 
1185   // Use the default numbers (see spec VIII.2.1)
1186   FPX_AllocFPXLongArray(&(theTransform->inputDataObjects) ,1);
1187   FPX_AllocFPXLongArray(&(theTransform->outputDataObjects),1);
1188   *(theTransform->inputDataObjects.ptr) = 1;
1189   *(theTransform->outputDataObjects.ptr)  = 2;
1190   theTransform->operationNumber     = 1;
1191 }
1192 
1193 
1194 //  ----------------------------------------------------------------------------
InitOperationPropertySet(FPXOperation * theOperation)1195 void PFlashPixImageView::InitOperationPropertySet(FPXOperation* theOperation)
1196 {
1197   CLSID clsID = ID_Transform;       // Always this value in Baseline
1198   theOperation->operationID = clsID;
1199 }
1200 
1201 
1202 //  ----------------------------------------------------------------------------
InitExtensionListPropertySet(FPXExtensionDescription *)1203 void PFlashPixImageView::InitExtensionListPropertySet(FPXExtensionDescription* /*theExtension*/)
1204 {
1205   // Not implemented yet...
1206 }
1207 
1208 
1209 //  ------------------------------------------------------------------------------------
1210 //  Basic FPX Image View Properties Access
1211 //  Set and Get property sets functions: one day, these functions will be made public and
1212 //  provided to the user through some calls in the Reference Implementation API...
1213 //  ------------------------------------------------------------------------------------
SetGlobalInfoPropertySet(FPXGlobalInfo * theGlobalInfo)1214 FPXStatus PFlashPixImageView::SetGlobalInfoPropertySet(FPXGlobalInfo* theGlobalInfo)
1215 {
1216   FPXStatus err = FPX_OK;
1217 
1218   if (filePtr) {
1219     OLEProperty* aProp;
1220 
1221     if (theGlobalInfo->lockedPropertiesIsValid)
1222       if (filePtr->SetGlobalInfoProperty (PID_LockedPropertyList, TYP_LockedPropertyList, &aProp))
1223         *aProp = (FPXLongArray)(theGlobalInfo->lockedProperties);
1224 
1225     if (theGlobalInfo->transformedImageTitleIsValid)
1226       if (filePtr->SetGlobalInfoProperty (PID_Title, TYP_Title, &aProp))
1227         *aProp = (FPXWideStr)(theGlobalInfo->transformedImageTitle);
1228 
1229     if (theGlobalInfo->lastModifierIsValid)
1230       if (filePtr->SetGlobalInfoProperty (PID_LastModifier, TYP_LastModifier, &aProp))
1231         *aProp = (FPXWideStr)(theGlobalInfo->lastModifier);
1232 
1233     if (filePtr->SetGlobalInfoProperty (PID_VisibleOutputs, TYP_VisibleOutputs, &aProp))
1234       *aProp = (FPXLongArray)(theGlobalInfo->visibleOutputs);
1235 
1236     if (filePtr->SetGlobalInfoProperty (PID_MaxImageIndex, TYP_MaxImageIndex, &aProp))
1237       *aProp = (int32_t)(theGlobalInfo->maxImageIndex);
1238 
1239     if (filePtr->SetGlobalInfoProperty (PID_MaxTransfoIndex, TYP_MaxTransfoIndex, &aProp))
1240       *aProp = (int32_t)(theGlobalInfo->maxTransformIndex);
1241 
1242     if (filePtr->SetGlobalInfoProperty (PID_MaxOperatorIndex, TYP_MaxOperatorIndex, &aProp))
1243       *aProp = (int32_t)(theGlobalInfo->maxOperatorIndex);
1244 
1245     filePtr->Commit();
1246   } else
1247     err = FPX_NOT_A_VIEW;
1248 
1249   return err;
1250 }
1251 
1252 
1253 //  ----------------------------------------------------------------------------
GetGlobalInfoPropertySet(FPXGlobalInfo * theGlobalInfo)1254 FPXStatus PFlashPixImageView::GetGlobalInfoPropertySet(FPXGlobalInfo* theGlobalInfo)
1255 {
1256   FPXStatus err = FPX_OK;
1257 
1258   if (filePtr) {
1259     OLEProperty* aProp;
1260 
1261     if (filePtr->GetGlobalInfoProperty (PID_LockedPropertyList, &aProp)) {
1262       theGlobalInfo->lockedProperties = (FPXLongArray)(*aProp);
1263       theGlobalInfo->lockedPropertiesIsValid = TRUE;
1264     } else
1265       theGlobalInfo->lockedPropertiesIsValid = FALSE;
1266 
1267     if (filePtr->GetGlobalInfoProperty (PID_Title, &aProp)) {
1268       theGlobalInfo->transformedImageTitle = (FPXWideStr)(*aProp);
1269       theGlobalInfo->transformedImageTitleIsValid = TRUE;
1270     } else
1271       theGlobalInfo->transformedImageTitleIsValid = FALSE;
1272 
1273     if (filePtr->GetGlobalInfoProperty (PID_LastModifier, &aProp)) {
1274       theGlobalInfo->lastModifier = (FPXWideStr)(*aProp);
1275       theGlobalInfo->lastModifierIsValid = TRUE;
1276     } else
1277       theGlobalInfo->lastModifierIsValid = FALSE;
1278 
1279     if (filePtr->GetGlobalInfoProperty (PID_VisibleOutputs, &aProp))
1280       theGlobalInfo->visibleOutputs = (FPXLongArray)(*aProp);
1281 
1282     if (filePtr->GetGlobalInfoProperty (PID_MaxImageIndex, &aProp))
1283       theGlobalInfo->maxImageIndex = (int32_t)(*aProp);
1284 
1285     if (filePtr->GetGlobalInfoProperty (PID_MaxTransfoIndex, &aProp))
1286       theGlobalInfo->maxTransformIndex = (int32_t)(*aProp);
1287 
1288     if (filePtr->GetGlobalInfoProperty (PID_MaxOperatorIndex, &aProp))
1289       theGlobalInfo->maxOperatorIndex = (int32_t)(*aProp);
1290   } else
1291     err = FPX_NOT_A_VIEW;
1292 
1293   return err;
1294 }
1295 
1296 
1297 //  ----------------------------------------------------------------------------
SetSourcePropertySet(FPXImageDescription * theSourceDescription)1298 FPXStatus PFlashPixImageView::SetSourcePropertySet(FPXImageDescription* theSourceDescription)
1299 {
1300   FPXStatus err = FPX_OK;
1301 
1302   if (filePtr) {
1303     OLEProperty* aProp;
1304 
1305     if (filePtr->SetSourceDescProperty (PID_ImageID, TYP_ImageID, &aProp))
1306       *aProp = (CLSID *)&(theSourceDescription->dataObjectID);
1307 
1308     if (theSourceDescription->lockedPropertiesIsValid)
1309       if (filePtr->SetSourceDescProperty (PID_LockedPropertyList, TYP_LockedPropertyList, &aProp))
1310         *aProp = (FPXLongArray)(theSourceDescription->lockedProperties);
1311 
1312     if (theSourceDescription->dataObjectTitleIsValid)
1313       if (filePtr->SetSourceDescProperty (PID_Title, TYP_Title, &aProp))
1314         *aProp = (FPXWideStr)(theSourceDescription->dataObjectTitle);
1315 
1316     if (theSourceDescription->lastModifierIsValid)
1317       if (filePtr->SetSourceDescProperty (PID_LastModifier, TYP_LastModifier, &aProp))
1318         *aProp = (FPXWideStr)(theSourceDescription->lastModifier);
1319 
1320     if (theSourceDescription->revisionNumberIsValid)
1321       if (filePtr->SetSourceDescProperty (PID_RevisionNumber, TYP_RevisionNumber, &aProp))
1322         *aProp = (int32_t)(theSourceDescription->revisionNumber);
1323 
1324     if (theSourceDescription->creationDateIsValid)
1325       if (filePtr->SetSourceDescProperty (PID_CreationTime, TYP_CreationTime, &aProp))
1326         *aProp = *(FILETIME *)&(theSourceDescription->creationDate);
1327 
1328     if (theSourceDescription->modificationDateIsValid)
1329       if (filePtr->SetSourceDescProperty (PID_ModificationTime, TYP_ModificationTime, &aProp))
1330         *aProp = *(FILETIME *)&(theSourceDescription->modificationDate);
1331 
1332     if (theSourceDescription->creatingApplicationIsValid)
1333       if (filePtr->SetSourceDescProperty (PID_CreatingApplication, TYP_CreatingApplication, &aProp))
1334         *aProp = (FPXWideStr)(theSourceDescription->creatingApplication);
1335 
1336     // PLEASE WINDOWS TESTER: the following line may be little endian/big endian dependent...
1337     int32_t longStatus = (theSourceDescription->status.existenceData << 16) | theSourceDescription->status.permission;
1338     if (filePtr->SetSourceDescProperty (PID_Status, TYP_Status, &aProp))
1339       *aProp = (int32_t)(longStatus);
1340 
1341     if (filePtr->SetSourceDescProperty (PID_Creator, TYP_Creator, &aProp))
1342       *aProp = (int32_t)(theSourceDescription->creator);
1343 
1344 
1345     if (filePtr->SetSourceDescProperty (PID_Users, TYP_Users, &aProp))
1346       *aProp = (FPXLongArray)(theSourceDescription->users);
1347 
1348     if (theSourceDescription->heightIsValid)
1349       if (filePtr->SetSourceDescProperty (PID_CachedImageHeight, TYP_CachedImageHeight, &aProp))
1350         *aProp = (int32_t)(theSourceDescription->height);
1351 
1352     if (theSourceDescription->widthIsValid)
1353       if (filePtr->SetSourceDescProperty (PID_CachedImageWidth, TYP_CachedImageWidth, &aProp))
1354         *aProp = (int32_t)(theSourceDescription->width);
1355 
1356     filePtr->Commit();
1357   } else
1358 
1359     err = FPX_NOT_A_VIEW;
1360 
1361   return err;
1362 }
1363 
1364 
1365 //  ----------------------------------------------------------------------------
GetSourcePropertySet(FPXImageDescription * theSourceDescription)1366 FPXStatus PFlashPixImageView::GetSourcePropertySet(FPXImageDescription* theSourceDescription)
1367 {
1368   FPXStatus err = FPX_OK;
1369 
1370   if (filePtr) {
1371     OLEProperty* aProp;
1372 
1373     if (filePtr->GetSourceDescProperty (PID_ImageID, &aProp))
1374       theSourceDescription->dataObjectID = *(CLSID*)(*aProp);
1375 
1376     if (filePtr->GetSourceDescProperty (PID_LockedPropertyList, &aProp)) {
1377       theSourceDescription->lockedProperties = (FPXLongArray)(*aProp);
1378       theSourceDescription->lockedPropertiesIsValid = TRUE;
1379     } else
1380       theSourceDescription->lockedPropertiesIsValid = FALSE;
1381 
1382     if (filePtr->GetSourceDescProperty (PID_Title, &aProp)) {
1383       theSourceDescription->dataObjectTitle = (FPXWideStr)(*aProp);
1384       theSourceDescription->dataObjectTitleIsValid = TRUE;
1385     } else
1386       theSourceDescription->dataObjectTitleIsValid = FALSE;
1387 
1388     if (filePtr->GetSourceDescProperty (PID_LastModifier, &aProp)) {
1389       theSourceDescription->lastModifier = (FPXWideStr)(*aProp);
1390       theSourceDescription->lastModifierIsValid = TRUE;
1391     } else
1392       theSourceDescription->lastModifierIsValid = FALSE;
1393 
1394     if (filePtr->GetSourceDescProperty (PID_RevisionNumber, &aProp)) {
1395       theSourceDescription->revisionNumber = (int32_t)(*aProp);
1396       theSourceDescription->revisionNumberIsValid = TRUE;
1397     } else
1398       theSourceDescription->revisionNumberIsValid = FALSE;
1399 
1400     if (filePtr->GetSourceDescProperty (PID_CreationTime, &aProp)) {
1401       theSourceDescription->creationDate = *(FPXfiletime *)&(*aProp);
1402       theSourceDescription->creationDateIsValid = TRUE;
1403     } else
1404       theSourceDescription->creationDateIsValid = FALSE;
1405 
1406     if (filePtr->GetSourceDescProperty (PID_ModificationTime, &aProp)) {
1407       theSourceDescription->modificationDate = *(FPXfiletime *)&(*aProp);
1408       theSourceDescription->modificationDateIsValid = TRUE;
1409     } else
1410       theSourceDescription->modificationDateIsValid = FALSE;
1411 
1412     if (filePtr->GetSourceDescProperty (PID_CreatingApplication, &aProp)) {
1413       theSourceDescription->creatingApplication = (FPXWideStr)(*aProp);
1414       theSourceDescription->creatingApplicationIsValid = TRUE;
1415     } else
1416       theSourceDescription->creatingApplicationIsValid = FALSE;
1417 
1418     if (filePtr->GetSourceDescProperty (PID_Status, &aProp)) {
1419       int32_t longStatus = (int32_t)(*aProp);
1420       // PLEASE WINDOWS TESTER: the following line may be little endian/big endian dependent...
1421       theSourceDescription->status.existenceData = (FPXImageExistence)((longStatus) >> 16);
1422       theSourceDescription->status.permission    = (FPXImagePermission)((longStatus) & 0xFFFF);
1423     }
1424 
1425     if (filePtr->GetSourceDescProperty (PID_Creator, &aProp))
1426       theSourceDescription->creator = (int32_t)(*aProp);
1427 
1428     if (filePtr->GetSourceDescProperty (PID_Users, &aProp))
1429       theSourceDescription->users = (FPXLongArray)(*aProp);
1430 
1431     if (filePtr->GetSourceDescProperty (PID_CachedImageHeight, &aProp)) {
1432       theSourceDescription->height = (int32_t)(*aProp);
1433       theSourceDescription->heightIsValid = TRUE;
1434     } else
1435       theSourceDescription->heightIsValid = FALSE;
1436 
1437     if (filePtr->GetSourceDescProperty (PID_CachedImageWidth, &aProp)) {
1438       theSourceDescription->width = (int32_t)(*aProp);
1439       theSourceDescription->widthIsValid = TRUE;
1440     } else
1441       theSourceDescription->widthIsValid = FALSE;
1442   } else
1443     err = FPX_NOT_A_VIEW;
1444 
1445   return err;
1446 }
1447 
1448 
1449 //  ----------------------------------------------------------------------------
SetResultPropertySet(FPXImageDescription * theResultDescription)1450 FPXStatus PFlashPixImageView::SetResultPropertySet(FPXImageDescription* theResultDescription)
1451 {
1452   FPXStatus err = FPX_OK;
1453 
1454   if (filePtr) {
1455     OLEProperty* aProp;
1456 
1457     if (filePtr->SetResultDescProperty (PID_ImageID, TYP_ImageID, &aProp))
1458       *aProp = (CLSID *)&(theResultDescription->dataObjectID);
1459 
1460     if (theResultDescription->lockedPropertiesIsValid)
1461       if (filePtr->SetResultDescProperty (PID_LockedPropertyList, TYP_LockedPropertyList, &aProp))
1462         *aProp = (FPXLongArray)(theResultDescription->lockedProperties);
1463 
1464     if (theResultDescription->dataObjectTitleIsValid)
1465       if (filePtr->SetResultDescProperty (PID_Title, TYP_Title, &aProp))
1466         *aProp = (FPXWideStr)(theResultDescription->dataObjectTitle);
1467 
1468     if (theResultDescription->lastModifierIsValid)
1469       if (filePtr->SetResultDescProperty (PID_LastModifier, TYP_LastModifier, &aProp))
1470         *aProp = (FPXWideStr)(theResultDescription->lastModifier);
1471 
1472     if (theResultDescription->revisionNumberIsValid)
1473       if (filePtr->SetResultDescProperty (PID_RevisionNumber, TYP_RevisionNumber, &aProp))
1474         *aProp = (int32_t)(theResultDescription->revisionNumber);
1475 
1476     if (theResultDescription->creationDateIsValid)
1477       if (filePtr->SetResultDescProperty (PID_CreationTime, TYP_CreationTime, &aProp))
1478         *aProp = *(FILETIME *)&(theResultDescription->creationDate);
1479 
1480     if (theResultDescription->modificationDateIsValid)
1481       if (filePtr->SetResultDescProperty (PID_ModificationTime, TYP_ModificationTime, &aProp))
1482         *aProp = *(FILETIME *)&(theResultDescription->modificationDate);
1483 
1484     if (theResultDescription->creatingApplicationIsValid)
1485       if (filePtr->SetResultDescProperty (PID_CreatingApplication, TYP_CreatingApplication, &aProp))
1486         *aProp = (FPXWideStr)(theResultDescription->creatingApplication);
1487 
1488     // PLEASE WINDOWS TESTER: the following line may be little endian/big endian dependent...
1489     int32_t longStatus = (theResultDescription->status.existenceData << 16) | theResultDescription->status.permission;
1490     if (filePtr->SetResultDescProperty (PID_Status, TYP_Status, &aProp))
1491       *aProp = (int32_t)(longStatus);
1492 
1493     if (filePtr->SetResultDescProperty (PID_Creator, TYP_Creator, &aProp))
1494       *aProp = (int32_t)(theResultDescription->creator);
1495 
1496     if (filePtr->SetResultDescProperty (PID_Users, TYP_Users, &aProp))
1497       *aProp = (FPXLongArray)(theResultDescription->users);
1498 
1499     if (theResultDescription->heightIsValid)
1500       if (filePtr->SetResultDescProperty (PID_CachedImageHeight, TYP_CachedImageHeight, &aProp))
1501         *aProp = (int32_t)(theResultDescription->height);
1502 
1503     if (theResultDescription->widthIsValid)
1504       if (filePtr->SetResultDescProperty (PID_CachedImageWidth, TYP_CachedImageWidth, &aProp))
1505         *aProp = (int32_t)(theResultDescription->width);
1506 
1507     filePtr->Commit();
1508   } else
1509     err = FPX_NOT_A_VIEW;
1510 
1511   return err;
1512 }
1513 
1514 
1515 //  ----------------------------------------------------------------------------
GetResultPropertySet(FPXImageDescription * theResultDescription)1516 FPXStatus PFlashPixImageView::GetResultPropertySet(FPXImageDescription* theResultDescription)
1517 {
1518   FPXStatus err = FPX_OK;
1519 
1520   if (filePtr) {
1521     OLEProperty* aProp;
1522 
1523     if (filePtr->GetResultDescProperty (PID_ImageID, &aProp))
1524       theResultDescription->dataObjectID = *(CLSID*)(*aProp);
1525 
1526     if (filePtr->GetResultDescProperty (PID_LockedPropertyList, &aProp)) {
1527       theResultDescription->lockedProperties = (FPXLongArray)(*aProp);
1528       theResultDescription->lockedPropertiesIsValid = TRUE;
1529     } else
1530       theResultDescription->lockedPropertiesIsValid = FALSE;
1531 
1532     if (filePtr->GetResultDescProperty (PID_Title, &aProp)) {
1533       theResultDescription->dataObjectTitle = (FPXWideStr)(*aProp);
1534       theResultDescription->dataObjectTitleIsValid = TRUE;
1535     } else
1536       theResultDescription->dataObjectTitleIsValid = FALSE;
1537 
1538     if (filePtr->GetResultDescProperty (PID_LastModifier, &aProp)) {
1539       theResultDescription->lastModifier = (FPXWideStr)(*aProp);
1540       theResultDescription->lastModifierIsValid = TRUE;
1541     } else
1542       theResultDescription->lastModifierIsValid = FALSE;
1543 
1544     if (filePtr->GetResultDescProperty (PID_RevisionNumber, &aProp)) {
1545       theResultDescription->revisionNumber = (int32_t)(*aProp);
1546       theResultDescription->revisionNumberIsValid = TRUE;
1547     } else
1548       theResultDescription->revisionNumberIsValid = FALSE;
1549 
1550     if (filePtr->GetResultDescProperty (PID_CreationTime, &aProp)) {
1551       theResultDescription->creationDate = *(FPXfiletime *)&(*aProp);
1552       theResultDescription->creationDateIsValid = TRUE;
1553     } else
1554       theResultDescription->creationDateIsValid = FALSE;
1555 
1556     if (filePtr->GetResultDescProperty (PID_ModificationTime, &aProp)) {
1557       theResultDescription->modificationDate = *(FPXfiletime *)&(*aProp);
1558       theResultDescription->modificationDateIsValid = TRUE;
1559     } else
1560       theResultDescription->modificationDateIsValid = FALSE;
1561 
1562     if (filePtr->GetResultDescProperty (PID_CreatingApplication, &aProp)) {
1563       theResultDescription->creatingApplication = (FPXWideStr)(*aProp);
1564       theResultDescription->creatingApplicationIsValid = TRUE;
1565     } else
1566       theResultDescription->creatingApplicationIsValid = FALSE;
1567 
1568     if (filePtr->GetResultDescProperty (PID_Status, &aProp)) {
1569       int32_t longStatus = (int32_t)(*aProp);
1570       // PLEASE WINDOWS TESTER: the following line may be little endian/big endian dependent...
1571       theResultDescription->status.existenceData = (FPXImageExistence)((longStatus) >> 16);
1572       theResultDescription->status.permission    = (FPXImagePermission)((longStatus) & 0xFFFF);
1573     }
1574 
1575     if (filePtr->GetResultDescProperty (PID_Creator, &aProp))
1576       theResultDescription->creator = (int32_t)(*aProp);
1577 
1578     if (filePtr->GetResultDescProperty (PID_Users, &aProp))
1579       theResultDescription->users = (FPXLongArray)(*aProp);
1580 
1581     if (filePtr->GetResultDescProperty (PID_CachedImageHeight, &aProp)) {
1582       theResultDescription->height = (int32_t)(*aProp);
1583       theResultDescription->heightIsValid = TRUE;
1584     } else
1585       theResultDescription->heightIsValid = FALSE;
1586 
1587     if (filePtr->GetResultDescProperty (PID_CachedImageWidth, &aProp)) {
1588       theResultDescription->width = (int32_t)(*aProp);
1589       theResultDescription->widthIsValid = TRUE;
1590     } else
1591       theResultDescription->widthIsValid = FALSE;
1592   } else
1593     err = FPX_NOT_A_VIEW;
1594 
1595   return err;
1596 }
1597 
1598 
1599 //  ----------------------------------------------------------------------------
SetTransformPropertySet(FPXTransform * theTransform)1600 FPXStatus PFlashPixImageView::SetTransformPropertySet(FPXTransform* theTransform)
1601 {
1602   FPXStatus err = FPX_OK;
1603 
1604   if (filePtr) {
1605     OLEProperty* aProp;
1606 
1607     if (filePtr->SetTransformProperty (PID_TransformNodeID, TYP_TransformNodeID, &aProp))
1608       *aProp = (CLSID *)&(theTransform->transformNodeID);
1609 
1610     if (filePtr->SetTransformProperty (PID_OperationClassID, TYP_OperationClassID, &aProp))
1611       *aProp = (CLSID *)&(theTransform->operationClassID);
1612 
1613     if (theTransform->lockedPropertiesIsValid)
1614       if (filePtr->SetTransformProperty (PID_LockedPropertyList, TYP_LockedPropertyList, &aProp))
1615         *aProp = (FPXLongArray)(theTransform->lockedProperties);
1616 
1617     if (theTransform->transformTitleIsValid)
1618       if (filePtr->SetTransformProperty (PID_Title, TYP_Title, &aProp))
1619         *aProp = (FPXWideStr)(theTransform->transformTitle);
1620 
1621     if (theTransform->lastModifierIsValid)
1622       if (filePtr->SetTransformProperty (PID_LastModifier, TYP_LastModifier, &aProp))
1623         *aProp = (FPXWideStr)(theTransform->lastModifier);
1624 
1625     if (theTransform->revisionNumberIsValid)
1626       if (filePtr->SetTransformProperty (PID_RevisionNumber, TYP_RevisionNumber, &aProp))
1627         *aProp = (int32_t)(theTransform->revisionNumber);
1628 
1629     if (theTransform->creationDateIsValid)
1630       if (filePtr->SetTransformProperty (PID_CreationTime, TYP_CreationTime, &aProp))
1631         *aProp = *(FILETIME *)&(theTransform->creationDate);
1632 
1633     if (theTransform->modificationDateIsValid)
1634       if (filePtr->SetTransformProperty (PID_ModificationTime, TYP_ModificationTime, &aProp))
1635         *aProp = *(FILETIME *)&(theTransform->modificationDate);
1636 
1637     if (theTransform->creatingApplicationIsValid)
1638       if (filePtr->SetTransformProperty (PID_CreatingApplication, TYP_CreatingApplication, &aProp))
1639         *aProp = (FPXWideStr)(theTransform->creatingApplication);
1640 
1641     if (filePtr->SetTransformProperty (PID_InputObjectList, TYP_InputObjectList, &aProp))
1642       *aProp = (FPXLongArray)(theTransform->inputDataObjects);
1643 
1644     if (filePtr->SetTransformProperty (PID_OutputObjectList, TYP_OutputObjectList, &aProp))
1645       *aProp = (FPXLongArray)(theTransform->outputDataObjects);
1646 
1647     if (filePtr->SetTransformProperty (PID_OperationNumber, TYP_OperationNumber, &aProp))
1648       *aProp = (int32_t)(theTransform->operationNumber);
1649 
1650     filePtr->Commit();
1651   } else
1652     err = FPX_NOT_A_VIEW;
1653 
1654   return err;
1655 }
1656 
1657 
1658 
1659 //  ----------------------------------------------------------------------------
GetTransformPropertySet(FPXTransform * theTransform)1660 FPXStatus PFlashPixImageView::GetTransformPropertySet(FPXTransform* theTransform)
1661 {
1662   FPXStatus err = FPX_OK;
1663 
1664 
1665   if (filePtr) {
1666     OLEProperty* aProp;
1667 
1668     if (filePtr->GetTransformProperty (PID_TransformNodeID, &aProp))
1669       theTransform->transformNodeID = *(CLSID*)(*aProp);
1670 
1671     if (filePtr->GetTransformProperty (PID_OperationClassID, &aProp))
1672       theTransform->operationClassID = *(CLSID*)(*aProp);
1673 
1674     if (filePtr->GetTransformProperty (PID_LockedPropertyList, &aProp)) {
1675       theTransform->lockedProperties = (FPXLongArray)(*aProp);
1676       theTransform->lockedPropertiesIsValid = TRUE;
1677     } else
1678       theTransform->lockedPropertiesIsValid = FALSE;
1679 
1680     if (filePtr->GetTransformProperty (PID_Title, &aProp)) {
1681       theTransform->transformTitle = (FPXWideStr)(*aProp);
1682       theTransform->transformTitleIsValid = TRUE;
1683     } else
1684       theTransform->transformTitleIsValid = FALSE;
1685 
1686     if (filePtr->GetTransformProperty (PID_LastModifier, &aProp)) {
1687       theTransform->lastModifier = (FPXWideStr)(*aProp);
1688       theTransform->lastModifierIsValid = TRUE;
1689     } else
1690       theTransform->lastModifierIsValid = FALSE;
1691 
1692     if (filePtr->GetTransformProperty (PID_RevisionNumber, &aProp)) {
1693       theTransform->revisionNumber = (int32_t)(*aProp);
1694       theTransform->revisionNumberIsValid = TRUE;
1695     } else
1696       theTransform->revisionNumberIsValid = FALSE;
1697 
1698     if (filePtr->GetTransformProperty (PID_CreationTime, &aProp)) {
1699       theTransform->creationDate = *(FPXfiletime *)&(*aProp);
1700       theTransform->creationDateIsValid = TRUE;
1701     } else
1702       theTransform->creationDateIsValid = FALSE;
1703 
1704     if (filePtr->GetTransformProperty (PID_ModificationTime, &aProp)) {
1705       theTransform->modificationDate = *(FPXfiletime *)&(*aProp);
1706       theTransform->modificationDateIsValid = TRUE;
1707     } else
1708       theTransform->modificationDateIsValid = FALSE;
1709 
1710     if (filePtr->GetTransformProperty (PID_CreatingApplication, &aProp)) {
1711       theTransform->creatingApplication = (FPXWideStr)(*aProp);
1712       theTransform->creatingApplicationIsValid = TRUE;
1713     } else
1714       theTransform->creatingApplicationIsValid = FALSE;
1715 
1716     if (filePtr->GetTransformProperty (PID_InputObjectList, &aProp))
1717       theTransform->inputDataObjects = (FPXLongArray)(*aProp);
1718 
1719     if (filePtr->GetTransformProperty (PID_OutputObjectList, &aProp))
1720       theTransform->outputDataObjects = (FPXLongArray)(*aProp);
1721 
1722     if (filePtr->GetTransformProperty (PID_OperationNumber, &aProp))
1723       theTransform->operationNumber = (int32_t)(*aProp);
1724   } else
1725     err = FPX_NOT_A_VIEW;
1726 
1727   return err;
1728 }
1729 
1730 
1731 //  ------------------------------------------------------------------------------------
SetOperationPropertySet(FPXOperation * theOperation)1732 FPXStatus PFlashPixImageView::SetOperationPropertySet(FPXOperation* theOperation)
1733 {
1734   FPXStatus err = FPX_OK;
1735 
1736 
1737   if (filePtr) {
1738     OLEProperty* aProp;
1739 
1740     if (filePtr->SetOperationProperty (PID_OperationID, TYP_OperationID, &aProp))
1741       *aProp = (CLSID *)&(theOperation->operationID);
1742 
1743     filePtr->Commit();
1744   } else
1745     err = FPX_NOT_A_VIEW;
1746 
1747   return err;
1748 }
1749 
1750 
1751 //  ------------------------------------------------------------------------------------
GetOperationPropertySet(FPXOperation * theOperation)1752 FPXStatus PFlashPixImageView::GetOperationPropertySet(FPXOperation* theOperation)
1753 {
1754   FPXStatus err = FPX_OK;
1755 
1756 
1757   if (filePtr) {
1758     OLEProperty* aProp;
1759 
1760     if (filePtr->GetOperationProperty (PID_OperationID, &aProp))
1761       theOperation->operationID = *(CLSID*)(*aProp);
1762   } else
1763     err = FPX_NOT_A_VIEW;
1764 
1765   return err;
1766 }
1767 
1768 
1769 
1770 //  ------------------------------------------------------------------------------------
SetExtensionListPropertySet(FPXExtensionDescription *,char *)1771 FPXStatus PFlashPixImageView::SetExtensionListPropertySet(FPXExtensionDescription* /*theExtension*/,
1772                                                           char* /*extensionName*/)
1773 {
1774   return FPX_UNIMPLEMENTED_FUNCTION;
1775 }
1776 
1777 
1778 //  ------------------------------------------------------------------------------------
GetExtensionListPropertySet(FPXExtensionDescription *,char *)1779 FPXStatus PFlashPixImageView::GetExtensionListPropertySet(FPXExtensionDescription* /*theExtension*/,
1780                                                           char* /*extensionName*/)
1781 {
1782   return FPX_UNIMPLEMENTED_FUNCTION;
1783 }
1784 
1785 
1786 //  ------------------------------------------------------------------------------------
1787 //  Baseline Viewing Transform Properties: get the currently used properties
1788 //  ------------------------------------------------------------------------------------
1789 
1790 
1791 // Region Of Interest
1792 
SetImageROI(FPXROI * theROI)1793 FPXStatus PFlashPixImageView::SetImageROI (FPXROI* theROI)
1794 {
1795   if (theROI) {
1796 
1797     // Set the new ROI/crop values
1798     if( SetImageCrop (theROI->left, theROI->top,
1799       theROI->left + theROI->width, theROI->top + theROI->height))
1800         return FPX_BAD_COORDINATES;
1801 
1802     // Copy the parameter into the internal structure
1803 
1804     regionOfInterest      = *theROI;
1805     transformsHaveBeenEdited  = TRUE;
1806     hasRegionOfInterest     = TRUE;
1807 
1808   }
1809   return FPX_OK;
1810 }
1811 
1812 
1813 //  ------------------------------------------------------------------------------------
GetImageROI(FPXROI * theROI)1814 FPXStatus PFlashPixImageView::GetImageROI (FPXROI* theROI)
1815 {
1816   // Copy the internal structure into the parameter
1817   *theROI = regionOfInterest;
1818 
1819   return FPX_OK;
1820 }
1821 
1822 
1823 //  ------------------------------------------------------------------------------------
1824 // Filtering
SetImageFilteringValue(FPXFilteringValue * theFiltering)1825 FPXStatus PFlashPixImageView::SetImageFilteringValue (FPXFilteringValue* theFiltering)
1826 {
1827   if (theFiltering) {
1828     // Copy the parameter into the internal structure
1829     filtering = *theFiltering;
1830     // transformsHaveBeenEdited = TRUE;
1831     hasFiltering            = TRUE;
1832 
1833     // Update the filtering data of the parent object
1834     SetFiltering (*theFiltering);
1835   }
1836 
1837   return FPX_OK;
1838 }
1839 
1840 
1841 //  ------------------------------------------------------------------------------------
GetImageFilteringValue(FPXFilteringValue * theFiltering)1842 FPXStatus PFlashPixImageView::GetImageFilteringValue (FPXFilteringValue* theFiltering)
1843 {
1844   // Copy the internal structure into the parameter
1845   *theFiltering = filtering;
1846 
1847   return FPX_OK;
1848 }
1849 
1850 
1851 //  ------------------------------------------------------------------------------------
1852 // Spatial Orientation
SetImageAffineMatrix(FPXAffineMatrix * theAffineMatrix)1853 FPXStatus PFlashPixImageView::SetImageAffineMatrix (FPXAffineMatrix* theAffineMatrix)
1854 {
1855   if (theAffineMatrix) {
1856     // Copy the parameter into the internal structure
1857     affineMatrix = *theAffineMatrix;
1858     // transformsHaveBeenEdited = TRUE;
1859     hasAffineMatrix         = TRUE;
1860 
1861     // Update the positionning data of the parent object
1862     // The transformation is limited to the Baseline case, i.e., 2D affine transformation  (see Appendix A, par. A.3.2)
1863     TransfoPerspective normPos (affineMatrix.a11, affineMatrix.a21, // 2D scale, rotation and skewing
1864                    affineMatrix.a12, affineMatrix.a22,
1865                    affineMatrix.a14, affineMatrix.a24,  // Translation
1866                    affineMatrix.a31, affineMatrix.a32); // Perspective
1867     TransfoPerspective translat ((float)1.0, (float)0.0,(float) 0.0,(float) 1.0, -regionOfInterest.left, -regionOfInterest.top);
1868     position = normPos * translat;
1869   }
1870 
1871   return FPX_OK;
1872 }
1873 
1874 
1875 //  ------------------------------------------------------------------------------------
GetImageAffineMatrix(FPXAffineMatrix * theAffineMatrix)1876 FPXStatus PFlashPixImageView::GetImageAffineMatrix (FPXAffineMatrix*  theAffineMatrix)
1877 {
1878   // Copy the internal structure into the parameter
1879   *theAffineMatrix = affineMatrix;
1880 
1881   return FPX_OK;
1882 }
1883 
1884 
1885 //  ------------------------------------------------------------------------------------
1886 // Result Aspect Ratio
SetImageResultAspectRatio(FPXResultAspectRatio * theAspectRatio)1887 FPXStatus PFlashPixImageView::SetImageResultAspectRatio (FPXResultAspectRatio* theAspectRatio)
1888 {
1889   if (theAspectRatio) {
1890     // Copy the parameter into the internal structure
1891     aspectRatio = *theAspectRatio;
1892     transformsHaveBeenEdited  = TRUE;
1893     hasAspectRatio          = TRUE;
1894 
1895     // CAUTION: after such a call, the aspect ratio is never recomputed automatically bu the Toolkit
1896     // We use only the dimension set by the user from now.
1897     resizeFinalDimensions = FALSE;
1898 
1899     // Update the resulting dimensions of the parent object
1900     finalWidth = aspectRatio * finalHeight;
1901   }
1902 
1903   return FPX_OK;
1904 }
1905 
1906 
1907 //  ------------------------------------------------------------------------------------
GetImageResultAspectRatio(FPXResultAspectRatio * theAspectRatio)1908 FPXStatus PFlashPixImageView::GetImageResultAspectRatio (FPXResultAspectRatio* theAspectRatio)
1909 {
1910   // Copy the internal structure into the parameter
1911   *theAspectRatio = aspectRatio;
1912 
1913   return FPX_OK;
1914 }
1915 
1916 
1917 //  ------------------------------------------------------------------------------------
1918 // ColorTwist Matrix
SetImageColorTwistMatrix(FPXColorTwistMatrix * theColorTwistMatrix)1919 FPXStatus PFlashPixImageView::SetImageColorTwistMatrix (FPXColorTwistMatrix* theColorTwistMatrix)
1920 {
1921   if (theColorTwistMatrix) {
1922     // Copy the parameter into the internal structure
1923     colorTwistMatrix = *theColorTwistMatrix;
1924     // transformsHaveBeenEdited = TRUE;
1925     hasColorTwistMatrix       = TRUE;
1926 
1927     // Update the color twist data of the parent object
1928     PColorTwist twistMatrix (*theColorTwistMatrix);
1929 
1930     SetColorTwist (&twistMatrix);
1931   }
1932   return FPX_OK;
1933 }
1934 
1935 
1936 //  ------------------------------------------------------------------------------------
GetImageColorTwistMatrix(FPXColorTwistMatrix * theColorTwistMatrix)1937 FPXStatus PFlashPixImageView::GetImageColorTwistMatrix (FPXColorTwistMatrix* theColorTwistMatrix)
1938 {
1939   // Copy the internal structure into the parameter
1940   *theColorTwistMatrix = colorTwistMatrix;
1941 
1942   return FPX_OK;
1943 }
1944 
1945 
1946 //  ------------------------------------------------------------------------------------
1947 // Contrast Adjustement
SetImageContrastAdjustment(FPXContrastAdjustment * theContrastAdjustment)1948 FPXStatus PFlashPixImageView::SetImageContrastAdjustment (FPXContrastAdjustment* theContrastAdjustment)
1949 {
1950   if (theContrastAdjustment) {
1951     // Copy the parameter into the internal structure
1952     contrastAdjustment = *theContrastAdjustment;
1953     // transformsHaveBeenEdited = TRUE;
1954     hasContrastAdjustment       = TRUE;
1955 
1956     // Update the contrast data of the parent object
1957     SetContrast (*theContrastAdjustment);
1958   }
1959 
1960   return FPX_OK;
1961 }
1962 
1963 
1964 //  ------------------------------------------------------------------------------------
GetImageContrastAdjustment(FPXContrastAdjustment * theContrastAdjustment)1965 FPXStatus PFlashPixImageView::GetImageContrastAdjustment (FPXContrastAdjustment* theContrastAdjustment)
1966 {
1967   // Copy the internal structure into the parameter
1968   *theContrastAdjustment = contrastAdjustment;
1969 
1970   return FPX_OK;
1971 }
1972 
1973 
1974 //  ------------------------------------------------------------------------------------
1975 //  Baseline Viewing Transform Properties: load and save from the file
1976 //  ------------------------------------------------------------------------------------
1977 
InitTransformProperties()1978 void PFlashPixImageView::InitTransformProperties ()
1979 {
1980   // Geometric parameters
1981   float i0, j0, i1, j1;
1982   GetOutlineRectangle (&i0, &j0, &i1, &j1);
1983 
1984   aspectRatio = (i1 - i0)/(j1 - j0);
1985 
1986   regionOfInterest.left   = (float)0.0;
1987   regionOfInterest.top    = (float)0.0;
1988   regionOfInterest.width  = aspectRatio;
1989   regionOfInterest.height = (float)1.0;
1990 
1991   affineMatrix.a11 =(float) 1.0; affineMatrix.a12 = (float)0.0; affineMatrix.a13 =(float) 0.0; affineMatrix.a14 =(float) 0.0;
1992   affineMatrix.a21 = (float)0.0; affineMatrix.a22 = (float)1.0; affineMatrix.a23 = (float)0.0; affineMatrix.a24 = (float)0.0;
1993   affineMatrix.a31 = (float)0.0; affineMatrix.a32 = (float)0.0; affineMatrix.a33 = (float)1.0; affineMatrix.a34 = (float)0.0;
1994   affineMatrix.a41 = (float)0.0; affineMatrix.a42 = (float)0.0; affineMatrix.a43 =(float) 0.0; affineMatrix.a44 = (float)1.0;
1995 
1996   // Display parameters
1997   filtering = (float)0.0;
1998   contrastAdjustment = (float)1.0;
1999 
2000   colorTwistMatrix.byy  = (float)1.0; colorTwistMatrix.byc1  = (float)0.0; colorTwistMatrix.byc2  = (float)0.0; colorTwistMatrix.dummy1_zero = (float)0.0;
2001   colorTwistMatrix.bc1y = (float)0.0; colorTwistMatrix.bc1c1 = (float)1.0; colorTwistMatrix.bc1c2 = (float)0.0; colorTwistMatrix.dummy2_zero = (float)0.0;
2002   colorTwistMatrix.bc2y = (float)0.0; colorTwistMatrix.bc2c1 = (float)0.0; colorTwistMatrix.bc2c2 = (float)1.0; colorTwistMatrix.dummy3_zero = (float)0.0;
2003   colorTwistMatrix.dummy4_zero = (float)0.0; colorTwistMatrix.dummy5_zero =(float) 0.0; colorTwistMatrix.dummy6_zero = (float)0.0; colorTwistMatrix.dummy7_one = (float)1.0;
2004 
2005   // By default, none of these parameters have to be taken into account when saving
2006   hasRegionOfInterest   = FALSE;
2007   hasAffineMatrix     = FALSE;
2008   hasAspectRatio      = FALSE;
2009   hasFiltering      = FALSE;
2010   hasColorTwistMatrix   = FALSE;
2011   hasContrastAdjustment = FALSE;
2012 }
2013 
2014 
2015 //  ------------------------------------------------------------------------------------
2016 // Region Of Interest
SaveImageROI()2017 FPXStatus PFlashPixImageView::SaveImageROI ()
2018 {
2019   FPXStatus error = FPX_OK;
2020 
2021 
2022   if (!filePtr)
2023     // We don't create a FPX Image View at that level if it doesn't exist
2024     error = FPX_NOT_A_VIEW;
2025   else if (hasRegionOfInterest  && transformsHaveBeenEdited) {
2026     OLEProperty* aProp;
2027 
2028     if(readOnlyFile)
2029       return FPX_FILE_WRITE_ERROR;
2030     // Create an intermediate FPXRealArray pointing to the FPXROI structure
2031 
2032     FPXRealArray mat;
2033 
2034     mat.length = sizeof(FPXROI)/sizeof(float);
2035     mat.ptr    = (float*)(&regionOfInterest);
2036     assert (mat.length == 4);
2037 
2038     // Set the property
2039     if (filePtr->SetTransformProperty (PID_RectOfInterest, TYP_RectOfInterest, &aProp))
2040     {
2041       *aProp = (FPXRealArray)(mat);
2042       // transformsHaveBeenEdited = TRUE;
2043     }
2044     else
2045       error = FPX_FILE_WRITE_ERROR;
2046 
2047     // Write it on disk
2048     filePtr->Commit();
2049   }
2050 
2051   return error;
2052 }
2053 
2054 
2055 //  ------------------------------------------------------------------------------------
LoadImageROI()2056 FPXStatus PFlashPixImageView::LoadImageROI ()
2057 {
2058   FPXStatus error = FPX_OK;
2059 
2060   if (!filePtr)
2061     // We don't create a FPX Image View at that level if it doesn't exist
2062     error = FPX_NOT_A_VIEW;
2063   else {
2064     OLEProperty* aProp;
2065     // Create an intermediate FPXRealArray to store the property
2066     FPXRealArray mat;
2067 
2068     if (filePtr->GetTransformProperty (PID_RectOfInterest, &aProp)) {
2069 
2070       mat = (FPXRealArray)(*aProp);
2071       assert (mat.length == 4);
2072 
2073       // Transfert the FPXRealArray values into the FPXROI structure
2074       BlockMove(mat.ptr,&regionOfInterest,sizeof(FPXROI));
2075       hasRegionOfInterest = TRUE;
2076 
2077       // Resize bogus ROI... (too common to be avoided... unfortunately...)
2078       if ((regionOfInterest.left  > aspectRatio) || (regionOfInterest.top    > 1.0) ||
2079         (regionOfInterest.width > aspectRatio) || (regionOfInterest.height > 1.0)) {
2080 
2081         if ((regionOfInterest.width > originWidth) || (regionOfInterest.height > originHeight)) {
2082           // The crop is certainly given in high res pixels...
2083           regionOfInterest.left   /= (float)(image->height);
2084           regionOfInterest.top    /= (float)(image->height);
2085           regionOfInterest.width  /= (float)(image->height);
2086           regionOfInterest.height /= (float)(image->height);
2087         } else {
2088           // The crop is certainly given in the default size
2089           regionOfInterest.left   /= originHeight;
2090           regionOfInterest.top    /= originHeight;
2091           regionOfInterest.width  /= originHeight;
2092           regionOfInterest.height /= originHeight;
2093         }
2094       }
2095     } else
2096       error = FPX_FILE_READ_ERROR;
2097   }
2098 
2099   return error;
2100 }
2101 
2102 
2103 //  ------------------------------------------------------------------------------------
2104 // Filtering
SaveImageFilteringValue()2105 FPXStatus PFlashPixImageView::SaveImageFilteringValue ()
2106 {
2107   FPXStatus error = FPX_OK;
2108   Boolean status = TRUE;
2109 
2110   if (!filePtr)
2111     // We don't create a FPX Image View at that level if it doesn't exist
2112     error = FPX_NOT_A_VIEW;
2113   else if (hasFiltering) {
2114     // check to see if read only
2115     if(readOnlyFile)
2116       return FPX_FILE_WRITE_ERROR;
2117 
2118     OLEProperty* aProp;
2119     // Set the property
2120     if (filePtr->SetTransformProperty (PID_Filtering, TYP_Filtering, &aProp))
2121     {
2122       transformsHaveBeenEdited  = TRUE;
2123       *aProp = (float)(filtering);
2124     }
2125     else
2126     {
2127       error = FPX_FILE_WRITE_ERROR;
2128       return error;
2129     }
2130 
2131     // Write it on disk
2132     status = filePtr->Commit();
2133     if(status == FALSE)
2134       error = filePtr->getStatus();
2135   }
2136 
2137   return error;
2138 }
2139 
2140 
2141 //  ------------------------------------------------------------------------------------
LoadImageFilteringValue()2142 FPXStatus PFlashPixImageView::LoadImageFilteringValue ()
2143 {
2144   FPXStatus error = FPX_OK;
2145 
2146   if (!filePtr)
2147     // We don't create a FPX Image View at that level if it doesn't exist
2148     error = FPX_NOT_A_VIEW;
2149   else {
2150     OLEProperty* aProp;
2151     if (filePtr->GetTransformProperty (PID_Filtering, &aProp)) {
2152       filtering = (float)(*aProp);
2153       hasFiltering = TRUE;
2154     } else
2155       error = FPX_FILE_READ_ERROR;
2156   }
2157   return error;
2158 }
2159 
2160 
2161 //  ------------------------------------------------------------------------------------
2162 // Spatial Orientation
SaveImageAffineMatrix()2163 FPXStatus PFlashPixImageView::SaveImageAffineMatrix ()
2164 
2165 {
2166 
2167   FPXStatus error = FPX_OK;
2168 
2169   if (!filePtr)
2170     // We don't create a FPX Image View at that level if it doesn't exist
2171     error = FPX_NOT_A_VIEW;
2172 
2173   else if (hasAffineMatrix) {
2174     OLEProperty* aProp;
2175 
2176     if(readOnlyFile)
2177       return FPX_FILE_WRITE_ERROR;
2178 
2179     // Create an intermediate FPXRealArray pointing to the FPXAffineMatrix
2180     FPXRealArray mat;
2181     mat.length = sizeof(FPXAffineMatrix)/sizeof(float);
2182     mat.ptr    = (float*)(&affineMatrix);
2183     assert (mat.length == 16);
2184 
2185     // Set the property
2186 
2187     if (filePtr->SetTransformProperty (PID_SpatialOrientation, TYP_SpatialOrientation, &aProp))
2188     {
2189       *aProp = (FPXRealArray)(mat);
2190       transformsHaveBeenEdited  = TRUE;
2191     }
2192     else
2193       error = FPX_FILE_WRITE_ERROR;
2194 
2195     // Write it on disk
2196     filePtr->Commit();
2197   }
2198 
2199   return error;
2200 }
2201 
2202 
2203 //  ------------------------------------------------------------------------------------
LoadImageAffineMatrix()2204 FPXStatus PFlashPixImageView::LoadImageAffineMatrix ()
2205 {
2206   FPXStatus error = FPX_OK;
2207 
2208   if (!filePtr)
2209     // We don't create a FPX Image View at that level if it doesn't exist
2210     error = FPX_NOT_A_VIEW;
2211   else {
2212     OLEProperty* aProp;
2213     // Create an intermediate FPXRealArray to store the property
2214     FPXRealArray mat;
2215     if (filePtr->GetTransformProperty (PID_SpatialOrientation, &aProp)) {
2216       mat = (FPXRealArray)(*aProp);
2217       assert (mat.length == 16);
2218       // Transfert the FPXRealArray values into the FPXAffineMatrix structure
2219       BlockMove(mat.ptr,&affineMatrix,sizeof(FPXAffineMatrix));
2220       hasAffineMatrix = TRUE;
2221     } else
2222       error = FPX_FILE_READ_ERROR;
2223   }
2224 
2225   return error;
2226 }
2227 
2228 
2229 //  ------------------------------------------------------------------------------------
2230 // Result Aspect Ratio
SaveImageResultAspectRatio()2231 FPXStatus PFlashPixImageView::SaveImageResultAspectRatio ()
2232 {
2233   FPXStatus error = FPX_OK;
2234   if (!filePtr)
2235     // We don't create a FPX Image View at that level if it doesn't exist
2236     error = FPX_NOT_A_VIEW;
2237   else if (hasAspectRatio  && transformsHaveBeenEdited && !resizeFinalDimensions) {
2238     // CAUTION: this property must be saved only if the user sets it, otherwise, it should
2239     // be left free to move along with the position matrix.
2240     OLEProperty* aProp;
2241 
2242     if(readOnlyFile)
2243       return FPX_FILE_WRITE_ERROR;
2244 
2245     // Set the property
2246     if (filePtr->SetTransformProperty (PID_ResultAspectRatio, TYP_ResultAspectRatio, &aProp))
2247     {
2248       *aProp = (float)(aspectRatio);
2249       // transformsHaveBeenEdited = TRUE;
2250     }
2251     else
2252     {
2253       error = FPX_FILE_WRITE_ERROR;
2254       return error;
2255     }
2256     // Write it on disk
2257     filePtr->Commit();
2258 
2259   }
2260 
2261   return error;
2262 }
2263 
2264 
2265 //  ------------------------------------------------------------------------------------
LoadImageResultAspectRatio()2266 FPXStatus PFlashPixImageView::LoadImageResultAspectRatio ()
2267 {
2268   FPXStatus error = FPX_OK;
2269 
2270   if (!filePtr)
2271     // We don't create a FPX Image View at that level if it doesn't exist
2272     error = FPX_NOT_A_VIEW;
2273   else {
2274     OLEProperty* aProp;
2275     if (filePtr->GetTransformProperty (PID_ResultAspectRatio, &aProp)) {
2276       aspectRatio = (float)(*aProp);
2277       // CAUTION: if this property has been specified by the user, the result image will not
2278       // be automatically resized by the Toolkit. We'll use the final crop specified by the user.
2279       resizeFinalDimensions = FALSE;
2280       hasAspectRatio      = TRUE;
2281     } else
2282       error = FPX_FILE_READ_ERROR;
2283   }
2284 
2285   return error;
2286 }
2287 
2288 
2289 //  ------------------------------------------------------------------------------------
2290 // ColorTwist Matrix
SaveImageColorTwistMatrix()2291 FPXStatus PFlashPixImageView::SaveImageColorTwistMatrix ()
2292 {
2293   FPXStatus error = FPX_OK;
2294 
2295   if (!filePtr)
2296     // We don't create a FPX Image View at that level if it doesn't exist
2297     error = FPX_NOT_A_VIEW;
2298   else if (hasColorTwistMatrix) {
2299     OLEProperty* aProp;
2300 
2301     if(readOnlyFile)
2302       return FPX_FILE_WRITE_ERROR;
2303 
2304     // Create an intermediate FPXRealArray pointing to the FPXAffineMatrix
2305     FPXRealArray mat;
2306     mat.length = sizeof(FPXAffineMatrix)/sizeof(float);
2307     mat.ptr    = (float*)(&colorTwistMatrix);
2308     assert (mat.length == 16);
2309     // Set the property
2310 
2311     if (filePtr->SetTransformProperty (PID_ColortwistMatrix, TYP_ColortwistMatrix, &aProp))
2312     {
2313       *aProp = (FPXRealArray)(mat);
2314       transformsHaveBeenEdited  = TRUE;
2315     }
2316     else
2317       error = FPX_FILE_WRITE_ERROR;
2318 
2319     // Write it on disk
2320     filePtr->Commit();
2321   }
2322 
2323   return error;
2324 }
2325 
2326 
2327 //  ------------------------------------------------------------------------------------
LoadImageColorTwistMatrix()2328 FPXStatus PFlashPixImageView::LoadImageColorTwistMatrix ()
2329 {
2330   FPXStatus error = FPX_OK;
2331 
2332   //Initialize to identity
2333   colorTwistMatrix.byy  = (float)1.0; colorTwistMatrix.byc1  = (float)0.0; colorTwistMatrix.byc2  = (float)0.0; colorTwistMatrix.dummy1_zero = (float)0.0;
2334 
2335   colorTwistMatrix.bc1y = (float)0.0; colorTwistMatrix.bc1c1 = (float)1.0; colorTwistMatrix.bc1c2 = (float)0.0; colorTwistMatrix.dummy2_zero = (float)0.0;
2336 
2337   colorTwistMatrix.bc2y = (float)0.0; colorTwistMatrix.bc2c1 = (float)0.0; colorTwistMatrix.bc2c2 = (float)1.0; colorTwistMatrix.dummy3_zero = (float)0.0;
2338 
2339   colorTwistMatrix.dummy4_zero = (float)0.0; colorTwistMatrix.dummy5_zero =(float) 0.0; colorTwistMatrix.dummy6_zero = (float)0.0; colorTwistMatrix.dummy7_one = (float)1.0;
2340 
2341   if (!filePtr)
2342     // We don't create a FPX Image View at that level if it doesn't exist
2343     error = FPX_NOT_A_VIEW;
2344   else {
2345     OLEProperty* aProp;
2346     // Create an intermediate FPXRealArray to store the property
2347     FPXRealArray mat;
2348     if (filePtr->GetTransformProperty (PID_ColortwistMatrix, &aProp)) {
2349       mat = (FPXRealArray)(*aProp);
2350       assert (mat.length == 16);
2351       // Transfert the FPXRealArray values into the FPXAffineMatrix structure
2352       BlockMove(mat.ptr,&colorTwistMatrix,sizeof(FPXColorTwistMatrix));
2353       hasColorTwistMatrix = TRUE;
2354     } else
2355       error = FPX_FILE_READ_ERROR;
2356   }
2357   return error;
2358 }
2359 
2360 
2361 //  ------------------------------------------------------------------------------------
2362 // Contrast Adjustement
SaveImageContrastAdjustment()2363 FPXStatus PFlashPixImageView::SaveImageContrastAdjustment ()
2364 {
2365   FPXStatus error = FPX_OK;
2366 
2367   if (!filePtr)
2368     // We don't create a FPX Image View at that level if it doesn't exist
2369     error = FPX_NOT_A_VIEW;
2370   else if (hasContrastAdjustment) {
2371     OLEProperty* aProp;
2372     if(readOnlyFile)
2373       return FPX_FILE_WRITE_ERROR;
2374 
2375     // Set the property
2376     if (filePtr->SetTransformProperty (PID_ContrastAdjust, TYP_ContrastAdjust, &aProp))
2377     {
2378       *aProp = (float)(contrastAdjustment);
2379       transformsHaveBeenEdited  = TRUE;
2380     }
2381     else
2382       error = FPX_FILE_WRITE_ERROR;
2383 
2384     // Write it on disk
2385     filePtr->Commit();
2386   }
2387 
2388   return error;
2389 }
2390 
2391 
2392 //  ------------------------------------------------------------------------------------
LoadImageContrastAdjustment()2393 FPXStatus PFlashPixImageView::LoadImageContrastAdjustment ()
2394 {
2395   FPXStatus error = FPX_OK;
2396 
2397   if (!filePtr)
2398     // We don't create a FPX Image View at that level if it doesn't exist
2399     error = FPX_NOT_A_VIEW;
2400   else {
2401     OLEProperty* aProp;
2402     if (filePtr->GetTransformProperty (PID_ContrastAdjust, &aProp)) {
2403       contrastAdjustment = (float)(*aProp);
2404       hasContrastAdjustment = TRUE;
2405     } else
2406       error = FPX_FILE_READ_ERROR;
2407   }
2408 
2409   return error;
2410 }
2411