1 // ----------------------------------------------------------------------------
2 // MODULE : PResolutionLevel
3 // LANGUAGE : C
4 // CREATOR : Philippe BOSSUT
5 // CREAT. DATE : Wednesday, March 13, 1996
6 // DESCRIPTION :
7 // COMMENTS :
8 // SCCSID : @(#)pr_level.h 1.1 11:46:42 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 PResolutionLevel_h
15 #define PResolutionLevel_h
16 #ifndef Commun_h
17 #include "common.h"
18 #endif
19 // ----------------------------------------------------------------------------
20
21 // Includes
22 // --------
23
24 #ifndef SystemIVUE_h
25 #include "ri_sys.h"
26 #endif
27
28 #ifndef CombinMat_h
29 #include "matrix.h"
30 #endif
31
32 #ifndef FPXBaselineIO_h
33 #include "fpxlibio.h"
34 #endif
35
36 // to avoid include CorrectLut.h
37 struct CorrectLut;
38
39 // Constants
40 // ---------
41
42 // Types Declarations
43 // ------------------
44
45 // Types Definitions
46 // -----------------
47
48 // Classes Declarations
49 // --------------------
50
51 class PHierarchicalImage;
52 class PFileIVUEIO;
53 class PFileFlashPixIO;
54 class PResolutionLevel;
55 class PTile;
56 class PTileIVUE;
57 class PTileFlashPix;
58
59 // Classes Definitions
60 // -------------------
61
62 // Resolution Level class. A resolution level is composed of several tiles of pixels.
63 // Each resolution level points to the next resolution level which resolution is 1/2.
64
65 class PResolutionLevel : public PToolkitObject {
66
67 friend class PHierarchicalImage;
68 friend class PFileIVUEIO;
69 friend class PFileFlashPixIO;
70 friend class PTile;
71 friend class PTileIVUE;
72 friend class PTileFlashPix;
73
74 public:
75 // Constructors and destructor :
76
77 // Create resolution and next resolution in write mode
78 PResolutionLevel (PHierarchicalImage* father, int width, int height, int* quelImage);
79 // Create resolution and next resolution in read mode
80 PResolutionLevel (PHierarchicalImage* father, int* offset, int id);
81
82 virtual ~PResolutionLevel();
83
84 // Public interface: File specific implementation of a Resolution Level:
85 // ---------------------------------------------------------------------
86 // These methods must be derived in most of the cases
87
88 // Writing tools:
89 virtual FPXStatus WriteLine (Pixel* pix, short plan = -1);
90 virtual FPXStatus WriteRectangle (int x0, int y0, int x1, int y1, Pixel* pix, short plan = -1);
91
92 // Reading pixels tools:
93 virtual FPXStatus ReadRectangle (int x0, int y0, int x1, int y1, Pixel* pix);
94 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);
95 virtual FPXStatus Read (int* px, int* py, Pixel* table);
96 virtual FPXStatus ReadInterpolated (int* px, int* py, Pixel* table);
97 virtual FPXStatus ReadMean (int xi, int yi, Pixel& pixel);
98 virtual FPXStatus ReadMeanInterpolated (int xi, int yi, Pixel& pixel);
99
100 // Get information tools
101 virtual FPXStatus GetHistogram (int* alpha, int* red, int* green, int* blue, int* brightness, const CorrectLut* correctLut = NULL);
102 virtual FPXStatus InverseAlpha(); // Inverse alpha channel in all opened tiles
103 virtual Boolean IsOnTheBorder (int xi, int yi);
104 virtual FPXStatus SearchPixelTopLeftCorner(int* x1, int* y1, float ratio);
105 virtual FPXStatus GetResolutionSizeInfo (int* width, int* height, int* nbTilesWidth, int* nbTilesHeight);
106 virtual Boolean HasBeenUsed ();
107
108 protected:
109 // Protected interface: Methods used by the derived classes to customize the behavior of a Resolution Level:
110 // ---------------------------------------------------------------------------------------------------------
111
112 // Subimages management
113 virtual void InitWhenCreate();
114 virtual void InitWhenReading();
115 FPXStatus Allocation ();
116 virtual FPXStatus AllocTilesArray ();
117 FPXStatus CloseSubImage ();
118
119 // Reading tools:
120 virtual FPXStatus Read (); // Read the resolution specific information
121 virtual FPXStatus ReadInARectangle(Pixel* bufferOut, short pixelsPerLine, short width, short height,
122 const CorrectLut* correctLut = NULL, Boolean useAlphaChannel = false, const CombinMat* combinaisonMatrix = NULL);
123
124 // Writing tools:
125 virtual FPXStatus Write (); // Write the resolution specific information
126 virtual FPXStatus Convolution (int x, int y, Pixel* pix, int width, int height);
127 virtual FPXStatus FlushModifiedTiles ();
128 virtual FPXStatus DecimateLevel ();
129
130 // Error management:
131 long Status();
132
133 protected:
134 // Data of the PResolutionLevel object
135 // -----------------------------------
136
137 PHierarchicalImage* fatherFile; // Pointer to the father FileIVUEIO
138 int posFic; // Position in the file
139 int32 identifier; // Sub-Image identifier (i.e. sub image number)
140
141 short nbTilesH; // Height of the sub-image in tiles
142 short nbTilesW; // Width of the sub-image in tiles
143 int realHeight; // Height of the sub-image in pixels
144 int realWidth; // Width of the sub-image in pixels
145 PTile* tiles; // Tiles list
146
147 Boolean isAlpha; // true if there is an alpha channel
148 Boolean premultiplied; // true if the data are premultiplied by the alpha
149 unsigned char alphaOffset; // position of the alpha channel in a 32 bits pixel
150
151 int currentLine; // Current line number
152 long imageStatus;
153
154 PResolutionLevel* next; // Point to the next sub-image
155 PResolutionLevel* Previous(); // Get the pointer to the previous sub-image
156 };
157
158
159
160 // 'inline' Functions
161 // ------------------
162
WriteLine(Pixel * pix,short plan)163 inline FPXStatus PResolutionLevel::WriteLine (Pixel* pix, short plan)
164
165 {
166 FPXStatus status;
167
168 status = WriteRectangle (0, currentLine, realWidth - 1, currentLine, pix, plan);
169 if (!status) currentLine++;
170 return status;
171 }
172
Status()173 inline long PResolutionLevel::Status()
174
175 {
176 return imageStatus;
177 }
178
179 // 'extern' Functions
180 // ------------------
181
182 // 'extern' Variables
183 // ------------------
184
185 // ----------------------------------------------------------------------------
186 #endif // PResolutionLevel_h
187 // ----------------------------------------------------------------------------
188