|
1 /* |
|
2 * Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * Class CPbk2ImageManager implementation classes. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef CPBK2IMAGEWRITERBASE_H |
|
21 #define CPBK2IMAGEWRITERBASE_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 #include "CPbk2ImageManagerImpl.h" |
|
26 #include "MPbk2ImageReaderObserver.h" |
|
27 |
|
28 // FORWARD DECLARATIONS |
|
29 class CImageEncoder; |
|
30 class CBitmapScaler; |
|
31 class MPbk2ImageData; |
|
32 //class TPbkImageLoadParameters; |
|
33 |
|
34 // CLASS DECLARATION |
|
35 |
|
36 /** |
|
37 * Implementation base class for image writers. |
|
38 */ |
|
39 NONSHARABLE_CLASS(CPbk2ImageWriterBase) : |
|
40 public CActive, |
|
41 public MPbk2ImageWriter, |
|
42 public MPbk2ImageReaderObserver |
|
43 { |
|
44 protected: // interface |
|
45 /** |
|
46 * Constructor. |
|
47 * @param aObserver thumbnail set observer |
|
48 */ |
|
49 CPbk2ImageWriterBase(MPbk2ImageSetObserver& aObserver); |
|
50 |
|
51 /** |
|
52 * Second phase constructor. |
|
53 */ |
|
54 void ConstructL(); |
|
55 |
|
56 /** |
|
57 * Destructor. Cancels any previously executing read operation and |
|
58 * destroys this object. |
|
59 */ |
|
60 ~CPbk2ImageWriterBase(); |
|
61 |
|
62 private: // Abstract interface for derived classes |
|
63 /** |
|
64 * Creates an image writer for the thumbnail image to store. |
|
65 * |
|
66 * @return New image writer object. Caller takes ownership of the |
|
67 * returned object. |
|
68 */ |
|
69 virtual CImageEncoder* CreateImageWriterL() =0; |
|
70 |
|
71 /** |
|
72 * Stores image in aImageData as the thumbnail image. |
|
73 * |
|
74 * @param aImageData Images data |
|
75 */ |
|
76 virtual void StoreImageL(const MPbk2ImageData& aImageData) =0; |
|
77 |
|
78 /** |
|
79 * Stores image created with writer returned by CreateImageWriterL(). |
|
80 * @param aImageWriter image writer |
|
81 */ |
|
82 virtual void StoreImageL(CImageEncoder& aImageWriter) =0; |
|
83 |
|
84 /** |
|
85 * Returns the image size |
|
86 * @return Image size |
|
87 */ |
|
88 virtual TSize ImageSize() const = 0; |
|
89 |
|
90 public: // from MPbkThumbnailWriter |
|
91 void StartWriteL(const CFbsBitmap& aBitmap); |
|
92 void StartWriteL(const TDesC8& aBuffer); |
|
93 void StartWriteL(const TDesC& aFileName); |
|
94 void CancelWrite(); |
|
95 |
|
96 private: // from MPbkImageReaderObserver |
|
97 void ImageReadComplete(CPbk2ImageReader& aReader, CFbsBitmap* aBitmap); |
|
98 void ImageReadFailed(CPbk2ImageReader& aReader, TInt aError); |
|
99 void ImageOpenComplete(CPbk2ImageReader& aReader); |
|
100 |
|
101 protected: // From CActive |
|
102 void DoCancel(); |
|
103 |
|
104 private: // From CActive |
|
105 void RunL(); |
|
106 TInt RunError(TInt aError); |
|
107 |
|
108 private: // Implementation |
|
109 void NextState(); |
|
110 void ExecuteStateL(); |
|
111 void CheckFormatAndSizeL(); |
|
112 void ScaleBitmapL(); |
|
113 void CreateImageL(); |
|
114 void ConvertToJpegL(); |
|
115 void StoreImageL(); |
|
116 void Complete(); |
|
117 static TInt Complete(TAny* aSelf); |
|
118 void SetupReaderParams(TPbk2ImageManagerParams& aParams); |
|
119 |
|
120 private: // data members |
|
121 /// Ref: observer |
|
122 MPbk2ImageSetObserver& iObserver; |
|
123 /// Own: current state |
|
124 TInt iState; |
|
125 /// Own: image reader |
|
126 CPbk2ImageReader* iImageReader; |
|
127 /// Own: input image data |
|
128 MPbk2ImageData* iImageData; |
|
129 /// Own: bitmap to store |
|
130 CFbsBitmap* iBitmap; |
|
131 /// Own: bitmap scaler |
|
132 CBitmapScaler* iBitmapScaler; |
|
133 /// Own: image writer |
|
134 CImageEncoder* iImageEncoder; |
|
135 }; |
|
136 |
|
137 #endif // CPBK2IMAGEWRITERBASE_H |
|
138 |
|
139 // End of File |