|
1 // Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifndef BMPCODEC_H |
|
17 #define BMPCODEC_H |
|
18 |
|
19 #include <icl/imageprocessor.h> |
|
20 #include <icl/imagecodec.h> |
|
21 #include "BMPConvert.h" |
|
22 |
|
23 /** |
|
24 @file |
|
25 @internalComponent |
|
26 */ |
|
27 |
|
28 // Read codecs |
|
29 class CBmpDecoder; |
|
30 class CBmpReadCodec : public CImageProcessorReadCodec |
|
31 { |
|
32 public: |
|
33 |
|
34 // From CImageReadCodec |
|
35 TFrameState ProcessFrameL(TBufPtr8& aSrc); |
|
36 virtual void InitFrameL(TFrameInfo& aFrameInfo, CFrameImageData& aFrameImageData, TBool aDisableErrorDiffusion, CFbsBitmap& aDestination, CFbsBitmap* aDestinationMask); |
|
37 virtual void InitFrameHeader(TFrameInfo& aFrameInfo, CFrameImageData& aFrameData); |
|
38 virtual TFrameState ProcessFrameHeaderL(TBufPtr8& aData); |
|
39 protected: |
|
40 |
|
41 class TCompDecodeInfo |
|
42 { |
|
43 public: |
|
44 TUint iMask; |
|
45 TInt iRightShiftValue; |
|
46 TInt iLeftShiftValue; |
|
47 }; |
|
48 enum |
|
49 { |
|
50 KRedCompIdx = 0, |
|
51 KGreenCompIdx = 1, |
|
52 KBlueCompIdx = 2 |
|
53 }; |
|
54 |
|
55 CBmpReadCodec(const TSize& aBmpSize, const TRgb* aPalette); |
|
56 ~CBmpReadCodec(); |
|
57 virtual void DoProcessL() = 0; |
|
58 virtual void DoNewFrameL(); |
|
59 void WritePixels(TInt aNumPixels, TBool aUpdatePos = ETrue); |
|
60 protected: |
|
61 TSize iOriginalSize; |
|
62 TSize iFrameSize; |
|
63 const TRgb* iPalette; // Not owned |
|
64 const TUint8* iDataPtr; // Not owned |
|
65 const TUint8* iDataPtrLimit; // Not owned |
|
66 TInt iBytesExpected; |
|
67 TInt iBytesProcessed; |
|
68 TFrameInfo* iFrameInfo; // Not owned |
|
69 }; |
|
70 |
|
71 class CBmp1BppReadCodec : public CBmpReadCodec |
|
72 { |
|
73 public: |
|
74 |
|
75 static CBmp1BppReadCodec* NewL(const TSize& aBmpSize, const TRgb* aPalette); |
|
76 |
|
77 |
|
78 //From CBmpReadCodec |
|
79 virtual void DoProcessL(); |
|
80 virtual void DoNewFrameL(); |
|
81 private: |
|
82 |
|
83 CBmp1BppReadCodec(const TSize& aBmpSize, const TRgb* aPalette); |
|
84 |
|
85 TRgb iEntry0; |
|
86 TRgb iEntry1; |
|
87 }; |
|
88 |
|
89 class CBmpNoComp4BppReadCodec : public CBmpReadCodec |
|
90 { |
|
91 public: |
|
92 |
|
93 static CBmpNoComp4BppReadCodec* NewL(const TSize& aBmpSize, const TRgb* aPalette); |
|
94 |
|
95 //From CBmpReadCodec |
|
96 virtual void DoNewFrameL(); |
|
97 virtual void DoProcessL(); |
|
98 |
|
99 private: |
|
100 CBmpNoComp4BppReadCodec(const TSize& aBmpSize, const TRgb* aPalette); |
|
101 }; |
|
102 |
|
103 class CBmpRLE4ReadCodec : public CBmpReadCodec |
|
104 { |
|
105 public: |
|
106 |
|
107 static CBmpRLE4ReadCodec* NewL(const TSize& aBmpSize, const TRgb* aPalette); |
|
108 |
|
109 //From CBmpReadCodec |
|
110 virtual void DoNewFrameL(); |
|
111 virtual void DoProcessL(); |
|
112 private: |
|
113 CBmpRLE4ReadCodec(const TSize& aBmpSize, const TRgb* aPalette); |
|
114 |
|
115 void WriteRun(TUint8 aValue, TInt aNumPixels); |
|
116 void WriteData(TInt aNumPixels); |
|
117 }; |
|
118 |
|
119 class CBmpNoComp8BppReadCodec : public CBmpReadCodec |
|
120 { |
|
121 public: |
|
122 |
|
123 static CBmpNoComp8BppReadCodec* NewL(const TSize& aBmpSize, const TRgb* aPalette); |
|
124 |
|
125 //From CBmpReadCodec |
|
126 virtual void DoNewFrameL(); |
|
127 virtual void DoProcessL(); |
|
128 |
|
129 private: |
|
130 CBmpNoComp8BppReadCodec(const TSize& aBmpSize, const TRgb* aPalette); |
|
131 |
|
132 }; |
|
133 |
|
134 class CBmpRLE8ReadCodec : public CBmpReadCodec |
|
135 { |
|
136 public: |
|
137 |
|
138 static CBmpRLE8ReadCodec* NewL(const TSize& aBmpSize, const TRgb* aPalette); |
|
139 |
|
140 //From CBmpReadCodec |
|
141 virtual void DoNewFrameL(); |
|
142 virtual void DoProcessL(); |
|
143 private: |
|
144 CBmpRLE8ReadCodec(const TSize& aBmpSize, const TRgb* aPalette); |
|
145 void WriteRun(TUint8 aValue, TInt aNumPixels); |
|
146 void WriteData(TInt aNumPixels); |
|
147 }; |
|
148 |
|
149 /** |
|
150 codec which can handle "bit field" compressed bitmaps |
|
151 */ |
|
152 class CBmpBiRgbReadCodec : public CBmpReadCodec |
|
153 { |
|
154 public: |
|
155 |
|
156 static CBmpBiRgbReadCodec* NewL(const TSize& aBmpSize, TInt aPixelSize, const TRgb* aPalette); |
|
157 |
|
158 //From CBmpReadCodec |
|
159 virtual void DoProcessL(); |
|
160 virtual void DoNewFrameL(); |
|
161 |
|
162 protected: |
|
163 enum |
|
164 { |
|
165 KMaxComps = KBlueCompIdx + 1 // RGB |
|
166 }; |
|
167 |
|
168 CBmpBiRgbReadCodec(const TSize& aBmpSize, TInt aPixelSize, const TRgb* aPalette); |
|
169 |
|
170 void ConstructL(); |
|
171 |
|
172 const TInt iPixelSize; // pixel size in bytes |
|
173 |
|
174 TInt iTotalByteWidth; // line byte width with possible padding |
|
175 TInt iPixelByteWidth; // line byte width without possible padding |
|
176 TInt iPaddingByteWidth; // padding value |
|
177 TInt iBytePos; // current byte position |
|
178 TCompDecodeInfo iCompInfo[KMaxComps]; // color comps "decompression" parameters |
|
179 }; |
|
180 |
|
181 class CBmp24BppReadCodec : public CBmpReadCodec |
|
182 { |
|
183 public: |
|
184 |
|
185 static CBmp24BppReadCodec* NewL(const TSize& aBmpSize); |
|
186 |
|
187 //From CBmpReadCodec |
|
188 virtual void DoProcessL(); |
|
189 virtual void DoNewFrameL(); |
|
190 private: |
|
191 CBmp24BppReadCodec(const TSize& aBmpSize); |
|
192 |
|
193 TInt iTotalByteWidth; |
|
194 TInt iPixelByteWidth; |
|
195 TInt iPaddingByteWidth; |
|
196 TInt iBytePos; |
|
197 }; |
|
198 |
|
199 class CBmp32BppReadCodec : public CBmpReadCodec |
|
200 { |
|
201 public: |
|
202 |
|
203 static CBmp32BppReadCodec* NewL(const TSize& aBmpSize); |
|
204 |
|
205 //From CBmpReadCodec |
|
206 virtual void DoProcessL(); |
|
207 virtual void DoNewFrameL(); |
|
208 private: |
|
209 CBmp32BppReadCodec(const TSize& aBmpSize); |
|
210 |
|
211 TInt iTotalByteWidth; |
|
212 TInt iPixelByteWidth; |
|
213 TInt iPaddingByteWidth; |
|
214 TInt iBytePos; |
|
215 }; |
|
216 |
|
217 // Write codecs |
|
218 class CBmpWriteCodec : public CImageWriteCodec |
|
219 { |
|
220 public: |
|
221 // from CImageWriteCodec |
|
222 virtual void InitFrameL(TBufPtr8& aDst, const CFbsBitmap& aSource); |
|
223 protected: |
|
224 |
|
225 virtual TFrameState ProcessFrameL(TBufPtr8& aDst); |
|
226 virtual void DoProcessL(const CFbsBitmap& aFrame) = 0; |
|
227 virtual TInt PaddingBytes() = 0; |
|
228 protected: |
|
229 TRect iSourceRect; |
|
230 TPoint iPos; |
|
231 TUint8* iDestPtr; |
|
232 TUint8* iDestPtrLimit; |
|
233 TInt iPaddingBytes; |
|
234 TInt iBytesToWrite; |
|
235 }; |
|
236 |
|
237 class CBmp1BppWriteCodec : public CBmpWriteCodec |
|
238 { |
|
239 public: |
|
240 |
|
241 static CBmp1BppWriteCodec* NewL(void); |
|
242 |
|
243 //from CBmpWriteCodec |
|
244 virtual void DoProcessL(const CFbsBitmap& aFrame); |
|
245 virtual TInt PaddingBytes(); |
|
246 }; |
|
247 |
|
248 class CBmp4BppWriteCodec : public CBmpWriteCodec |
|
249 { |
|
250 public: |
|
251 static CBmp4BppWriteCodec* NewL(void); |
|
252 |
|
253 //from CBmpWriteCodec |
|
254 virtual void DoProcessL(const CFbsBitmap& aFrame); |
|
255 virtual TInt PaddingBytes(); |
|
256 }; |
|
257 |
|
258 class CBmp8BppWriteCodec : public CBmpWriteCodec |
|
259 { |
|
260 public: |
|
261 static CBmp8BppWriteCodec* NewL(void); |
|
262 |
|
263 //from CBmpWriteCodec |
|
264 virtual void DoProcessL(const CFbsBitmap& aFrame); |
|
265 virtual TInt PaddingBytes(); |
|
266 }; |
|
267 |
|
268 class CBmp24BppWriteCodec : public CBmpWriteCodec |
|
269 { |
|
270 public: |
|
271 static CBmp24BppWriteCodec* NewL(void); |
|
272 |
|
273 //from CBmpWriteCodec |
|
274 virtual void DoProcessL(const CFbsBitmap& aFrame); |
|
275 virtual TInt PaddingBytes(); |
|
276 }; |
|
277 |
|
278 #endif // BMPCODEC_H |
|
279 |