1 // ----------------------------------------------------------------------------
2 // MODULE : BufferDesc
3 // LANGUAGE : C++
4 // CREATOR : Philippe BOSSUT
5 // CREAT. DATE : Monday, March 25, 1996
6 // DESCRIPTION :
7 // COMMENTS : Color Space and Pixel Buffer Handling:
8 // This class will handle all possibilities of color interface
9 // and interleaving between the Toolkit and the application.
10 //
11 // The idea is that in Baseline, every channels is 8 bits (1 byte) depth, so there
12 // is no need for very fancy buffer handling. Then, there is nothing with more
13 // than 4 channels, so 32 bits pixels are enough. So, the idea is to handle
14 // everything in a long for every color space and to take advantage of all 32 bits
15 // functionnalities to move pixels around. I know, that's overkill for monochrome
16 // but this shouldn't be a very common case. Last but not least, the buffer
17 // containing the data is supposed to be contiguous, so, you just have to give
18 // the address of a buffer and its width and height to update all the required
19 // pointers in the FPXImageDesc.
20 //
21 // SCCSID : @(#)buffdesc.h 1.3 13:22:25 06 Jan 1997
22 // ----------------------------------------------------------------------------
23 // Copyright (c) 1999 Digital Imaging Group, Inc.
24 // For conditions of distribution and use, see copyright notice
25 // in Flashpix.h
26 // ----------------------------------------------------------------------------
27 #ifndef BufferDesc_h
28 #define BufferDesc_h
29 #ifndef Commun_h
30 #include "common.h"
31 #endif
32 // ----------------------------------------------------------------------------
33
34 // Includes
35 // --------
36
37 #ifndef SystemIVUE_h
38 #include "ri_sys.h"
39 #endif
40
41 // Constants
42 // ---------
43
44 // Types Declarations
45 // ------------------
46
47 // Avoid to include FPXBaselineIO.h
48 struct FPXImageDesc;
49 struct FPXColorspace;
50
51 // Types Definitions
52 // -----------------
53
54 // Classes Declarations
55 // --------------------
56
57 // Classes Definitions
58 // -------------------
59
60 class FPXBufferDesc : public PToolkitObject {
61
62 public:
63 FPXBufferDesc (unsigned char* theBuffer, long theWidth, long theHeight, FPXBaselineColorSpace colorSpace = SPACE_32_BITS_RGB);
64 FPXBufferDesc (long theColor, long theWidth, long theHeight, FPXBaselineColorSpace colorSpace = SPACE_32_BITS_RGB);
65 FPXBufferDesc (FPXImageDesc* desc, long theWidth, long theHeight, unsigned char *theBuffer = NULL);
66 ~FPXBufferDesc ();
67
68 Pixel* Get32BitsBuffer();
69 FPXImageDesc* GetFPXdesc();
70 FPXBaselineColorSpace GetBaselineColorSpace();
71
72 void UpdateDescriptor();
73 void UpdateBuffer();
74
75 private:
76
77 void InitImageDesc(FPXBaselineColorSpace colorSpace);
78
79 FPXBaselineColorSpace colorSpaceType;
80 long width;
81 long height;
82
83 unsigned char* buffer;
84 Boolean localBuffer;
85 Boolean useInternalBuffer;
86
87 FPXImageDesc* FPXdesc;
88 Boolean localDesc;
89 };
90
91 // 'inline' Functions
92 // ------------------
93
Get32BitsBuffer()94 inline Pixel* FPXBufferDesc::Get32BitsBuffer()
95 {
96 return (Pixel*)(buffer);
97 }
98
GetFPXdesc()99 inline FPXImageDesc* FPXBufferDesc::GetFPXdesc()
100 {
101 return FPXdesc;
102 }
103
GetBaselineColorSpace()104 inline FPXBaselineColorSpace FPXBufferDesc::GetBaselineColorSpace()
105 {
106 return colorSpaceType;
107 }
108
109 // 'extern' Functions
110 // ------------------
111
112 FPXBaselineColorSpace AnalyseFPXColorSpace (FPXColorspace& colorSpace);
113 void CreateFPXColorSpace (FPXBaselineColorSpace baseSpace, FPXColorspace* colorSpace);
114 Boolean IsAlphaBaseline(FPXBaselineColorSpace baseSpace);
115 long GetAlphaOffsetBaseline(FPXBaselineColorSpace baseSpace);
116 long GetNbChannel(FPXBaselineColorSpace baseSpace);
117
118 void ExtractFPXColorSpaceFromFPXImageDesc(FPXImageDesc& desc, FPXColorspace* colorSpace);
119 Boolean IsA32bitsBufferDescriptor(FPXImageDesc& desc, long width);
120 Boolean IsASupportedDescriptor(FPXImageDesc& desc, long width);
121
122 // Check to see if all pixels in a tile are same and return the pixel value
123 Boolean IsTileAllSamePixel(Pixel *entireTile, short width, short height, Pixel* singleColorPixel);
124
125 void ConvertPixelBuffer(unsigned char* buffer, long size, FPXBaselineColorSpace source, FPXBaselineColorSpace destination);
126 void ConvertRGBtoYCC(unsigned char* buffer, long size);
127 void ConvertYCCtoRGB(unsigned char* buffer, long size, Boolean useAlpha);
128 // 'extern' Variables
129 // ------------------
130
131 // ----------------------------------------------------------------------------
132 #endif // BufferDesc_h
133 // ----------------------------------------------------------------------------
134