author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 13 Oct 2010 14:23:59 +0300 | |
branch | RCL_3 |
changeset 83 | 26b2b12093af |
parent 66 | 2455ef1f5bbc |
permissions | -rw-r--r-- |
66 | 1 |
/******************************************************************************* |
2 |
* Copyright (c) 2005, 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 |
* All rights reserved. This program and the accompanying materials |
|
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
|
5 |
* which accompanies this distribution, and is available at |
|
6 |
* http://www.eclipse.org/legal/epl-v10.html |
|
7 |
* |
|
8 |
* Contributors: |
|
9 |
* Nokia Corporation - S60 implementation |
|
10 |
*******************************************************************************/ |
|
11 |
||
12 |
||
13 |
#ifndef SWTIMAGEDATALOADER_H |
|
14 |
#define SWTIMAGEDATALOADER_H |
|
15 |
||
16 |
||
17 |
#include "eswtgraphics.h" |
|
18 |
||
19 |
||
20 |
class CImageDecoder; |
|
21 |
class CImageEncoder; |
|
22 |
class TFrameInfo; |
|
23 |
||
24 |
||
25 |
/** |
|
26 |
* CSwtImageDataLoader |
|
27 |
* Class used to encode and decode images (PNG, GIF, JPG). |
|
28 |
* @lib eswt |
|
29 |
*/ |
|
30 |
NONSHARABLE_CLASS(CSwtImageDataLoader) |
|
31 |
: public CActive |
|
32 |
, public MSwtImageDataLoader |
|
33 |
{ |
|
34 |
// Own methods |
|
35 |
public: |
|
36 |
||
37 |
/** |
|
38 |
* Two phase constructor. |
|
39 |
* Create the native object in charge of load and save image from/to a stream or a file. |
|
40 |
*/ |
|
41 |
static CSwtImageDataLoader* NewL(); |
|
42 |
||
43 |
// From MSwtImageDataLoader |
|
44 |
public: |
|
45 |
void EncodeImageToFileL(MSwtImageData& aImageData, |
|
46 |
TInt aFormat, const TDesC& aDestination); |
|
47 |
HBufC8* EncodeImageToStreamL(MSwtImageData& aImageData, TInt aFormat); |
|
48 |
void DecodeImageL(const TDesC& aFileName); |
|
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
49 |
void DecodeWholeImageFromBufferL(const TDesC8& aBuf); |
66 | 50 |
CSwtImageDataArray* GetImageData(); |
51 |
void Dispose(); |
|
52 |
TInt GetLogicalScreenHeight(); |
|
53 |
TInt GetLogicalScreenWidth(); |
|
54 |
||
55 |
// Own methods |
|
56 |
private: |
|
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
57 |
void DecodeFrameL(TInt aIndexOfFrame); //starting |
66 | 58 |
|
59 |
protected: |
|
60 |
/** |
|
61 |
* Destructor. |
|
62 |
*/ |
|
63 |
~CSwtImageDataLoader(); |
|
64 |
||
65 |
private: |
|
66 |
CSwtImageDataLoader(); |
|
67 |
void ConstructL(); |
|
68 |
void SetImageDataL(MSwtImageData& aImageData); |
|
69 |
||
70 |
/** |
|
71 |
* Extract the ImageData from the members bitmap. |
|
72 |
*/ |
|
73 |
void ExtractImagedataL(); |
|
74 |
||
75 |
/** |
|
76 |
* Build the mask bitmap if needed. |
|
77 |
*/ |
|
78 |
void SetMaskL(const TFrameInfo& aInfo); |
|
79 |
||
80 |
/** |
|
81 |
* Ensure that the bitmap resources are freed before |
|
82 |
* reusing the decoder (for multi frame image). |
|
83 |
*/ |
|
84 |
void FreeBitmaps(); |
|
85 |
||
86 |
/** |
|
87 |
* Free buffers. |
|
88 |
*/ |
|
89 |
void FreeBuffers(); |
|
90 |
||
91 |
/** |
|
92 |
* Set the logical values for height or width equal to |
|
93 |
* the values of the greatest frame (for height or width). |
|
94 |
*/ |
|
95 |
void SetLogicalScreenValues(const TFrameInfo& aInfo); |
|
96 |
||
97 |
/** |
|
98 |
* Set the x and y coordinates of the image in the current frame. |
|
99 |
*/ |
|
100 |
void SetFrameInfosL(const TFrameInfo& aInfo); |
|
101 |
||
102 |
/** |
|
103 |
* Leaves if a leave happens. Transforms the leave's code into one expected by eSWT. |
|
104 |
* A leave code that is not handled in the function causes |
|
105 |
* the leave to be performed with the unchanged leave code. |
|
106 |
* @param aLeaveCode : the leave code to convert(if equal to KerrNone : do not leave) |
|
107 |
*/ |
|
108 |
void LeaveIfErrorFromICLDecoderL(TInt aLeaveCode) const; |
|
109 |
||
110 |
||
111 |
/** |
|
112 |
* Leaves if a leave happens. Transforms the leave's code into one expected by eSWT. |
|
113 |
* A leave code that is not handled in the function causes |
|
114 |
* the leave to be performed with the unchanged leave code. |
|
115 |
* @param aLeaveCode : the leave code to convert(if equal to KerrNone : do not leave) |
|
116 |
*/ |
|
117 |
void LeaveIfErrorFromICLEncoderL(TInt aLeaveCode) const; |
|
118 |
||
119 |
/** |
|
120 |
* Verify the file pointed by destination can be created and does not already exists. |
|
121 |
* @param aDestination : The file that is checked |
|
122 |
* @param aFs : a RFs object. |
|
123 |
*/ |
|
124 |
void CheckDestinationL(const TDesC& aDestination, const RFs& aFs) const; |
|
125 |
||
126 |
const TDesC8& GetMimeType(TSwtImageType aFormat) const; |
|
127 |
||
128 |
// From CActive |
|
129 |
void RunL(); |
|
130 |
void DoCancel(); |
|
131 |
TInt RunError(TInt aError); |
|
132 |
||
133 |
private: |
|
134 |
CFbsBitmap* iMask; // The possible mask of the image |
|
135 |
CFbsBitmap* iBitmap; // The image bitmap (without its mask) |
|
136 |
MSwtImageData::TInfo iInfo; |
|
137 |
TSize iLogicalScreenValues; // LogicalScreenHeight and Width |
|
138 |
TPoint iImageCoordinates; // The coordinates of the frame within the screen in pixels. |
|
139 |
TInt iDelay; // The delay time of a gif |
|
140 |
TSwtGifDisposal iDisposal; // The disposal method of a gif image |
|
141 |
CImageDecoder* iDecoder; // Current decoder. Is a member to be persistent in order to be used asynchronously |
|
142 |
MSwtImageData* iImageData; // The imageData built when the conversion is finished |
|
143 |
CSwtImageDataArray* iImageDataArray; // The imageData array built step by step depending on how many images are stored in the image file/stream |
|
144 |
TInt iNextFrameToDecode; // The next frame we will decode |
|
145 |
HBufC8* iBuffer; // The data to decode when loading or the data encoded when saving |
|
146 |
TBool iStartDecodingAnother;// ETrue if a frame has just been decoded and ready to decode another frame. |
|
147 |
TPtr8 iDesc; // The descriptor furnished to the Convert function |
|
148 |
TInt iResult; // The code returned to the caller. |
|
149 |
TBool iWholeImageAtOnce; // ETrue when decoding whole image in one shot |
|
150 |
CImageEncoder* iEncoder; // Current encoder. Is a member to be persistent in order to be used asynchronously |
|
151 |
CActiveScheduler* iActiveScheduler; // Installed active scheduler. |
|
152 |
RFs iFs; // File server session. |
|
153 |
TBool iIsGif; |
|
154 |
TRequestStatus* iImageStatus; |
|
155 |
}; |
|
156 |
||
157 |
||
158 |
#endif // SWTIMAGEDATALOADER_H |