1 //  ----------------------------------------------------------------------------
2 //  MODULE    : PResolutionFlashPix
3 //  LANGUAGE  : C++
4 //  CREATOR   : Philippe BOSSUT
5 //  CREAT. DATE : Wednesday, March 20, 1996
6 //  DESCRIPTION :
7 //  COMMENTS  :
8 //  SCCSID      : @(#)pres_fpx.h  1.1 11:59:25 18 Dec 1996
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   #ifndef PResolutionFlashPix_h
15   #define PResolutionFlashPix_h
16   #ifndef Commun_h
17     #include  "common.h"
18   #endif
19 //  ----------------------------------------------------------------------------
20 
21 //  Includes
22 //  --------
23 
24 #ifndef PResolutionLevel_h
25   #include  "pr_level.h"
26 #endif
27 #ifndef BufferDesc_h
28   #include  "buffdesc.h"
29 #endif
30 #ifndef FPXBaselineIO_h
31   #include "fpxlibio.h"
32 #endif
33 
34 //  Constants
35 //  ---------
36 
37 //  Types Declarations
38 //  ------------------
39 
40 //  Types Definitions
41 //  -----------------
42 
43 //  Classes Declarations
44 //  --------------------
45 
46   class OLEStorage;     // to not include OLEStorage
47   class OLEHeaderStream;    // to not include OLEHeaderStream.h
48 
49   class PResolutionFlashPix;
50   class PHierarchicalImage;
51 
52 //  Classes Definitions
53 //  -------------------
54 
55   // Resolution class. A resolution is composed of several tiles of pixels.
56   // Each resolution points to the next which size is 1/4.
57 
58   class PResolutionFlashPix : public PResolutionLevel {
59 
60     friend class PHierarchicalImage;
61     friend class PFileFlashPixIO;
62     friend class PTile;
63     friend class PTileFlashPix;
64 
65   public:
66         // Constructors and destructor :
67 
68                  // Create resolution and next resolution in write mode
69                  PResolutionFlashPix (PHierarchicalImage* father, int width, int height, int* quelImage);
70                  // Create resolution and next resolution in read mode
71                  PResolutionFlashPix (PHierarchicalImage* father, int* offset, int id);
72 
73         virtual     ~PResolutionFlashPix();
74 
75         // Public interface: File specific implementation of a FlashPix Resolution Level:
76         // ---------------------------------------------------------------------------
77 
78         // Writing tools:
79         virtual FPXStatus WriteLine (Pixel* pix, short plan = -1);
80         virtual FPXStatus WriteRectangle (int x0, int y0, int x1, int y1, Pixel* pix, short plan = -1);
81             FPXStatus   FlushModifiedTiles ( );
82 
83         // Reading pixels tools:
84         virtual FPXStatus   ReadRectangle (int x0, int y0, int x1, int y1, Pixel* pix);
85         virtual FPXStatus ReadSampledRectangle(int x0, int y0,int x1, int y1, Pixel* map, short pixelsPerLine, int mapWidth, int mapHeight, Boolean showAlphaChannel = false, float ratio = 0.0);
86         virtual FPXStatus Read (int* px, int* py, Pixel* table);
87         virtual FPXStatus ReadInterpolated (int* px, int* py, Pixel* table);
88         virtual FPXStatus ReadMean (int xi, int yi, Pixel& pixel);
89         virtual FPXStatus ReadMeanInterpolated (int xi, int yi, Pixel& pixel);
90 
91         // Get information tools
92         virtual FPXStatus GetHistogram (int* alpha, int* red, int* green, int* blue, int* brightness, const CorrectLut* correctLut = NULL);
93         virtual Boolean   IsOnTheBorder (int xi, int yi);
94         virtual FPXStatus SearchPixelTopLeftCorner(int* x1, int* y1, float ratio);
95         virtual FPXStatus GetResolutionSizeInfo (int* width, int* height, int* nbTilesWidth, int* nbTilesHeight);
96 
97         // Raw data read and write functions
98             FPXStatus ReadRawTile (unsigned int whichTile,
99                        FPXCompressionOption*  compressOption,
100                        unsigned char*     compressQuality,
101                        long*          compressSubtype,
102                        unsigned int*     dataLength,
103                        void**         data);
104             FPXStatus WriteRawTile (unsigned int whichTile,
105                         FPXCompressionOption  compressOption,
106                         unsigned char     compressQuality,
107                         long          compressSubtype,
108                         unsigned int     dataLength,
109                         void*         data);
110         // FlashPix File management:
111         // ----------------------
112             FPXStatus SetResolutionDescription();           // Create the Section associated to a resolution in the Image Content Property Set
113             FPXStatus GetResolutionDescription();           // Get the Section associated to a resolution in the Image Content Property Set
114       FPXBaselineColorSpace   GetBaselineSpace();
115 
116         OLEHeaderStream* GetSubStreamData();
117         OLEHeaderStream* GetSubStreamHdr();
118   protected:
119         // Protected interface: Implementation of a Resolution Level:
120         // ----------------------------------------------------------
121 
122         // Subimages management
123         virtual FPXStatus AllocTilesArray ();
124 
125         // Reading tools:
126         virtual FPXStatus Read ();    // Read the resolution specific information
127         virtual FPXStatus ReadInARectangle(Pixel* bufferOut, short pixelsPerLine, short width, short height,
128                          const CorrectLut* correctLut = NULL, Boolean useAlphaChannel = false, const CombinMat* combinaisonMatrix = NULL);
129 
130         // Writing tools:
131         virtual FPXStatus Write ();   // Write the resolution specific information
132         virtual FPXStatus Convolution (int x, int y, Pixel* pix, int width, int height);
133         virtual FPXStatus DecimateLevel ();
134 
135   private:
136             FPXStatus   ReadHeaderStream   ();
137             FPXStatus   CreateHeaderStream ();
138             FPXStatus   UpdateHeaderStream ();
139 
140             void    Init();         // Init data with default values (called by constructors)
141 
142         FPXColorspace colorSpace;       // Color space structure of this resolution
143         short     nbChannels;       // Number of channels (1 to 4 in Baseline)
144     FPXBaselineColorSpace   baseSpace;        // Easy to use color space description
145         Boolean     isICCprofile;     // true if there is an ICC profile for this subimage
146         short     ICCprofile;       // Reference to an ICC profile (if any)
147 
148         FPXCompressionOption  compression;  // Compression mode used in this image file
149         long      compressionSubtype;   // Special compression info
150         unsigned char qualityFactor;      // Quality factor
151         unsigned char compressTableGroup;   // compression table id
152         unsigned char*  jpegHeader;       // JPEG header
153         unsigned int headerSize;       // JPEG header length
154 
155         OLEStorage*    subStorage;      // sub-image storage
156         OLEHeaderStream* subStreamHdr;      // sub-image stream containing the header
157         OLEHeaderStream* subStreamData;     // sub-image stream containing the blocks
158   };
159 
160 //  'inline' Functions
161 //  ------------------
162 
GetSubStreamData()163 inline OLEHeaderStream * PResolutionFlashPix::GetSubStreamData()
164 {
165   return subStreamData;
166 }
167 
GetSubStreamHdr()168 inline OLEHeaderStream * PResolutionFlashPix::GetSubStreamHdr()
169 {
170   return subStreamHdr;
171 }
172 
GetBaselineSpace()173 inline FPXBaselineColorSpace PResolutionFlashPix::GetBaselineSpace()
174 {
175   return baseSpace;
176 }
177 
178 //  'extern' Functions
179 //  ------------------
180 
181 //  'extern' Variables
182 //  ------------------
183 
184 //  ----------------------------------------------------------------------------
185   #endif // PResolutionFlashPix_h
186 //  ----------------------------------------------------------------------------
187