|
1 // Copyright (c) 2004-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 #include "ExifEncoder.h" |
|
17 #include "ExifTagDescriptions.h" |
|
18 #include "ExifTagHelper.h" |
|
19 |
|
20 CExifEncoder* CExifEncoder::NewL(TBool aEncodeThumbnail) |
|
21 { |
|
22 CExifEncoder* self = new (ELeave) CExifEncoder(aEncodeThumbnail); |
|
23 CleanupStack::PushL(self); |
|
24 self->ConstructL(); |
|
25 CleanupStack::Pop(self); |
|
26 return self; |
|
27 } |
|
28 |
|
29 CExifEncoder::CExifEncoder(TBool aEncodeThumbnail) |
|
30 { |
|
31 iEncodeThumbnail = aEncodeThumbnail; |
|
32 } |
|
33 |
|
34 CExifEncoder::~CExifEncoder() |
|
35 { |
|
36 delete iExifData; |
|
37 } |
|
38 void CExifEncoder::SetIfd1L() |
|
39 { |
|
40 User::LeaveIfError(KErrNotSupported); |
|
41 } |
|
42 |
|
43 TInt CExifEncoder::GetParam8(TUint /*aTag*/, TUint /*aIfd*/, HBufC8*& /*aParam*/) const |
|
44 { |
|
45 return KErrNotSupported; |
|
46 } |
|
47 |
|
48 TInt CExifEncoder::GetParam16(TUint /*aTag*/, TUint /*aIfd*/, HBufC16*& /*aParam*/) const |
|
49 { |
|
50 return KErrNotSupported; |
|
51 } |
|
52 |
|
53 TInt CExifEncoder::GetIntegerParam(TUint /*aTag*/, TUint /*aIfd*/, TInt& /*aParam*/) const |
|
54 { |
|
55 return KErrNotSupported; |
|
56 } |
|
57 |
|
58 TInt CExifEncoder::GetRationalParam(TUint /*aTag*/, TUint /*aIfd*/, TInt& /*aNumerator*/, TInt& /*aDenominator*/) const |
|
59 { |
|
60 return KErrNotSupported; |
|
61 } |
|
62 |
|
63 TInt CExifEncoder::GetShortParam(TUint /*aTag*/, TUint /*aIfd*/, TUint16& /*aParam*/) const |
|
64 { |
|
65 return KErrNotSupported; |
|
66 } |
|
67 |
|
68 TInt CExifEncoder::GetIntegerArrayParam(TUint /*aTag*/, TUint /*aIfd*/, CArrayFix<TInt>& /*aParam*/) const |
|
69 { |
|
70 return KErrNotSupported; |
|
71 } |
|
72 |
|
73 TInt CExifEncoder::GetShortArrayParam(TUint /*aTag*/, TUint /*aIfd*/, CArrayFix<TUint16>& /*aParam*/) const |
|
74 { |
|
75 return KErrNotSupported; |
|
76 } |
|
77 |
|
78 TInt CExifEncoder::GetRationalArrayParam(TUint /*aTag*/, TUint /*aIfd*/, CArrayFix<TRational>& /*aParam*/) const |
|
79 { |
|
80 return KErrNotSupported; |
|
81 } |
|
82 |
|
83 |
|
84 void CExifEncoder::ConstructL() |
|
85 { |
|
86 InitializeIfdsL(EFalse,ETrue); |
|
87 } |
|
88 |
|
89 void CExifEncoder::SetEnableThumbnailL(TBool aEnable) |
|
90 { |
|
91 if (aEnable == iEncodeThumbnail) |
|
92 { |
|
93 return; |
|
94 } |
|
95 if (aEnable) |
|
96 { |
|
97 CIfd1* ifd = CIfd1::NewLC(); |
|
98 iIfds.AppendL(ifd); |
|
99 CleanupStack::Pop(ifd); |
|
100 } |
|
101 else |
|
102 { |
|
103 int index; |
|
104 if (FindIfdIndex(EFirst, index)) |
|
105 { |
|
106 delete iIfds[index]; |
|
107 iIfds.Remove(index); |
|
108 } |
|
109 } |
|
110 iEncodeThumbnail = aEnable; |
|
111 } |
|
112 |
|
113 // Creates the Exif Header proper, i.e. by pulling together all the appropriate data held in the IFD's. |
|
114 TPtrC8 CExifEncoder::CreateExifHeaderL() |
|
115 { |
|
116 if(iExifData != NULL) |
|
117 { |
|
118 delete iExifData; |
|
119 iExifData = NULL; |
|
120 } |
|
121 |
|
122 |
|
123 iExifData = CreateExifHeaderBaseL(); |
|
124 |
|
125 return TPtrC8(iExifData->Ptr(), iExifData->Length()); |
|
126 } |
|
127 |
|
128 |
|
129 TInt CExifEncoder::ThumbnailLengthOffset() |
|
130 { |
|
131 if(!iEncodeThumbnail) |
|
132 { |
|
133 return KErrNotSupported; |
|
134 } |
|
135 TUint offset = 0; |
|
136 TInt err = GetThumbnailLengthOffsetBase(offset); |
|
137 if (err!=KErrNone) |
|
138 { |
|
139 return err; |
|
140 } |
|
141 |
|
142 return offset; |
|
143 } |
|
144 |
|
145 TInt CExifEncoder::ExifLengthOffset() |
|
146 { |
|
147 return KOffsetToApp1Size; |
|
148 } |