|
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 <f32file.h> |
|
17 #include "exiftransform.h" |
|
18 |
|
19 #include "ImageUtils.h" |
|
20 #include "ExifTagHelper.h" |
|
21 #include "ExifGeneralConsts.h" |
|
22 #include "ifdgeneral.h" |
|
23 #include "ExifTagDescriptions.h" |
|
24 |
|
25 /*static*/ |
|
26 CExifTransform* CExifTransform::NewL(const TUint8* aData, const TUint aApp1Size) |
|
27 { |
|
28 CExifTransform* self = new (ELeave) CExifTransform(); |
|
29 CleanupStack::PushL(self); |
|
30 self->ConstructL(aData, aApp1Size); |
|
31 CleanupStack::Pop(self); |
|
32 return self; |
|
33 } |
|
34 |
|
35 |
|
36 CExifTransform::CExifTransform() |
|
37 { |
|
38 } |
|
39 |
|
40 |
|
41 void CExifTransform::ConstructL(const TUint8* aData, const TUint aApp1Size) |
|
42 { |
|
43 if(aData) |
|
44 { |
|
45 TUint8* dataPtr = const_cast<TUint8*>(aData); |
|
46 InitializeIfdsL(dataPtr, aApp1Size); |
|
47 } |
|
48 else |
|
49 { |
|
50 InitializeIfdsL(ETrue, EFalse); |
|
51 } |
|
52 } |
|
53 |
|
54 |
|
55 CExifTransform::~CExifTransform() |
|
56 { |
|
57 } |
|
58 |
|
59 void CExifTransform::SetIfd1L() |
|
60 { |
|
61 TUint offsetToFirstIfd = 0; |
|
62 |
|
63 CIfdGeneral* ifd0 = GetIfd(EZeroth); |
|
64 ASSERT(ifd0); |
|
65 |
|
66 User::LeaveIfError(ifd0->GetOffsetToFirstIfd(offsetToFirstIfd)); |
|
67 |
|
68 if (CheckExifOffset(offsetToFirstIfd) != KErrNone) |
|
69 { |
|
70 offsetToFirstIfd = 0; |
|
71 } |
|
72 |
|
73 CIfd1* ifd1 = CIfd1::NewLC(offsetToFirstIfd, offsetToFirstIfd ? iBase : NULL, iIntel, iExifDataLength); |
|
74 iIfds.AppendL(ifd1); |
|
75 CleanupStack::Pop(ifd1); |
|
76 |
|
77 if (offsetToFirstIfd) |
|
78 { |
|
79 SetThumbnailDataBaseL(ifd1, ETrue); |
|
80 } |
|
81 } |
|
82 |
|
83 TInt CExifTransform::CreateExifChunk(HBufC8*& aExifChunk) |
|
84 { |
|
85 TRAPD(err, CreateExifHeaderL(aExifChunk)); |
|
86 return err; |
|
87 } |
|
88 |
|
89 // Creates the Exif Header proper, i.e. by pulling together all the appropriate data held in the IFD's. |
|
90 void CExifTransform::CreateExifHeaderL(HBufC8*& aBuffer) |
|
91 { |
|
92 if(aBuffer != NULL) |
|
93 { |
|
94 delete aBuffer; |
|
95 aBuffer=NULL; |
|
96 } |
|
97 |
|
98 if(!GetJpegThumbnailData()) |
|
99 { |
|
100 // we have to remove all the thumbnail data |
|
101 RemoveThumbnailData(); |
|
102 } |
|
103 |
|
104 aBuffer = CreateExifHeaderBaseL(); |
|
105 } |
|
106 |
|
107 void CExifTransform::CheckUpdateMandatoryTagsL() |
|
108 { |
|
109 CIfdGeneral* ifd = NULL; |
|
110 for (TInt i = 0; i < iIfds.Count(); i++) |
|
111 { |
|
112 ifd = iIfds[i]; |
|
113 ifd->CheckMandatoryEntriesL(); |
|
114 } |
|
115 } |
|
116 |
|
117 TBool CExifTransform::CheckImageSizeTags() |
|
118 { |
|
119 CExifIfd* exifIfd = static_cast<CExifIfd*> (GetIfd(EExifSub)); |
|
120 if (exifIfd) |
|
121 { |
|
122 return exifIfd->CheckImageSizeTags(); |
|
123 } |
|
124 return EFalse; |
|
125 } |
|
126 |
|
127 void CExifTransform::UpdateImageSizeTagsL(const TSize& aSize) |
|
128 { |
|
129 CExifIfd* exifIfd = static_cast<CExifIfd*> (GetIfd(EExifSub)); |
|
130 if (exifIfd) |
|
131 { |
|
132 exifIfd->UpdateImageSizeTagsL(aSize); |
|
133 } |
|
134 } |