|
1 /* |
|
2 * Copyright (c) 2010 Ixonos Plc. |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the "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 * Ixonos Plc |
|
14 * |
|
15 * Description: |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef __CFilterCartoon_H__ |
|
21 #define __CFilterCartoon_H__ |
|
22 |
|
23 #include <e32base.h> |
|
24 #include "MImageFilter.h" |
|
25 |
|
26 typedef RArray<TUint32> RPalette; |
|
27 |
|
28 // Class: Octree node |
|
29 //============================================================================= |
|
30 class CNode : public CBase |
|
31 { |
|
32 |
|
33 public: |
|
34 |
|
35 CNode(); |
|
36 virtual ~CNode(); |
|
37 |
|
38 public: |
|
39 /// If ETrue, has no leaves |
|
40 TBool iIsLeaf; |
|
41 /// Number of pixels represented by this leaf |
|
42 TInt iPixels; |
|
43 /// Sum of red components |
|
44 TInt iRedSum; |
|
45 /// Sum of green components |
|
46 TInt iGreenSum; |
|
47 /// Sum of blue components |
|
48 TInt iBlueSum; |
|
49 /// Children |
|
50 CNode * iChild[8]; |
|
51 /// Next reducible node |
|
52 CNode * iNext; |
|
53 }; |
|
54 |
|
55 // Class: Octree |
|
56 //============================================================================= |
|
57 class COTreeQuant : public CBase |
|
58 { |
|
59 |
|
60 public: |
|
61 |
|
62 COTreeQuant(); |
|
63 virtual ~COTreeQuant(); |
|
64 |
|
65 void AddColorL (TUint32 aRgb); |
|
66 TInt GetColorCount() const; |
|
67 void GetColorTable (); |
|
68 void ReduceTree (); |
|
69 |
|
70 public: |
|
71 |
|
72 /// Amount of leaves |
|
73 TInt iLeaves; |
|
74 /// Tree struct |
|
75 CNode * iTree; |
|
76 /// Reducible nodes |
|
77 CNode * iReducibleNodes[9]; |
|
78 /// Palette |
|
79 RPalette iPalette; |
|
80 |
|
81 private: |
|
82 |
|
83 void DoAddColorL (CNode ** aNode, TUint32 aRgb, TInt aLevel); |
|
84 void GetPaletteColors (const CNode & aNode); |
|
85 |
|
86 }; |
|
87 |
|
88 // Class: Cartoon filter |
|
89 //============================================================================= |
|
90 class CFilterCartoon |
|
91 : public CBase |
|
92 , public MImageFilter |
|
93 { |
|
94 public: |
|
95 IMPORT_C static TInt Create(); |
|
96 virtual ~CFilterCartoon(); |
|
97 |
|
98 public: // MImageFilter |
|
99 virtual TRect Rect(); |
|
100 virtual TReal Scale(); |
|
101 virtual TSize ViewPortSize(); |
|
102 virtual TBlock * GetBlockL ( const TRect & aRect ); |
|
103 virtual void SetParent ( MImageFilter * aParent ); |
|
104 virtual void SetChild ( MImageFilter * aChild ); |
|
105 virtual TInt CmdL( const TDesC16& aCmd ); |
|
106 virtual const char* Type(); |
|
107 |
|
108 private: |
|
109 static CFilterCartoon* NewL(); |
|
110 CFilterCartoon(); |
|
111 void ConstructL(); |
|
112 void CreateOctreePaletteL(); |
|
113 |
|
114 private: // data |
|
115 |
|
116 TInt* i16BitIndLut; |
|
117 TUint32* iRGB; |
|
118 TInt iCount; |
|
119 }; |
|
120 |
|
121 #endif |