|
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 __TIFFCONVERT_H__ |
|
17 #define __TIFFCONVERT_H__ |
|
18 |
|
19 #include "icl/ImagePlugin.h" |
|
20 #include "TIFFCodec.h" |
|
21 |
|
22 // Constants. |
|
23 const TInt KTiffHeaderSize = 8; |
|
24 const TInt KTiffSignatureLength = 4; |
|
25 |
|
26 // Helper classes. |
|
27 // Class to read little/big endian values. |
|
28 enum TTiffEndianness |
|
29 { |
|
30 ETiffLittleEndian = 0, |
|
31 ETiffBigEndian = 1 |
|
32 }; |
|
33 |
|
34 class TTiffValueReader |
|
35 { |
|
36 public: |
|
37 inline TTiffValueReader(TTiffEndianness aEndianness = ETiffLittleEndian); |
|
38 |
|
39 TUint32 ReadUint32(const TUint8* aPtr) const; |
|
40 inline TInt32 ReadInt32(const TUint8* aPtr) const; |
|
41 TUint16 ReadUint16(const TUint8* aPtr) const; |
|
42 inline TInt16 ReadInt16(const TUint8* aPtr) const; |
|
43 public: |
|
44 TTiffEndianness iEndianness; |
|
45 }; |
|
46 |
|
47 // Format info |
|
48 class TTiffFormatInfo |
|
49 { |
|
50 public: |
|
51 TTiffEndianness iEndianness; |
|
52 TInt iFirstIfd; |
|
53 TUint32 iSignature; |
|
54 }; |
|
55 |
|
56 // Decoder. |
|
57 class CTiffReadCodec; |
|
58 class CTiffDecoder : public CImageDecoderPlugin |
|
59 { |
|
60 private: |
|
61 enum TTiffSubType |
|
62 { |
|
63 ETiffUnknownSubType, ETiffLittleEndianSubType, ETiffBigEndianSubType |
|
64 }; |
|
65 enum TTiffFormatType |
|
66 { |
|
67 EFormatGroup3Fax1D = 0, // values must co-incide with .rss image_format[] |
|
68 EFormatGroup3Fax2D, |
|
69 EFormatGroup4Fax, |
|
70 EFormatUnknown |
|
71 }; |
|
72 |
|
73 public: |
|
74 static CTiffDecoder* NewL(); |
|
75 static CTiffDecoder* NewLittleEndianL(); |
|
76 static CTiffDecoder* NewBigEndianL(); |
|
77 ~CTiffDecoder(); |
|
78 |
|
79 // from CImageDecoder |
|
80 void ImageType(TInt aFrameNumber, TUid& aImageType, TUid& aImageSubType) const; |
|
81 CFrameInfoStrings* FrameInfoStringsL(RFs& aFs, TInt aFrameNumber); |
|
82 TInt CurrentFilePosition(); |
|
83 |
|
84 protected: |
|
85 void Cleanup(); |
|
86 private: |
|
87 CTiffDecoder(TTiffSubType aTiffSubType); |
|
88 void ReadFormatL(); |
|
89 void ScanDataL(); |
|
90 |
|
91 private: |
|
92 TTiffFormatInfo iFormatInfo; |
|
93 TTiffSubType iTiffSubType; |
|
94 }; |
|
95 |
|
96 // Inlines |
|
97 inline TTiffValueReader::TTiffValueReader(TTiffEndianness aEndianness) |
|
98 : iEndianness(aEndianness) |
|
99 { |
|
100 } |
|
101 |
|
102 inline TInt32 TTiffValueReader::ReadInt32(const TUint8* aPtr) const |
|
103 { |
|
104 return TInt32(ReadUint32(aPtr)); |
|
105 } |
|
106 |
|
107 inline TInt16 TTiffValueReader::ReadInt16(const TUint8* aPtr) const |
|
108 { |
|
109 return TInt16(ReadUint16(aPtr)); |
|
110 } |
|
111 |
|
112 #endif // __TIFFCONVERT_H__ |