|
1 /* |
|
2 * Copyright (c) 2009 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: GSServer is responsible for initializing the TV |
|
15 * driver during the boot and always when the cable is connected. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "tvstandbyfigure.h" |
|
22 #include "TVOutStandbyFigure.mbg" |
|
23 #include <e32std.h> |
|
24 #include <fbs.h> |
|
25 #include <f32file.h> |
|
26 #include <bitdev.h> |
|
27 #include <gdi.h> |
|
28 //#include <r_display.h> |
|
29 |
|
30 // EXTERNAL DATA STRUCTURES |
|
31 |
|
32 // EXTERNAL FUNCTION PROTOTYPES |
|
33 |
|
34 // CONSTANTS |
|
35 |
|
36 // MACROS |
|
37 |
|
38 // LOCAL CONSTANTS AND MACROS |
|
39 |
|
40 // MODULE DATA STRUCTURES |
|
41 |
|
42 // LOCAL FUNCTION PROTOTYPES |
|
43 |
|
44 // FORWARD DECLARATIONS |
|
45 |
|
46 // ============================= LOCAL FUNCTIONS =============================== |
|
47 |
|
48 // ============================ MEMBER FUNCTIONS =============================== |
|
49 |
|
50 // ----------------------------------------------------------------------------- |
|
51 // CTvStandbyFigure::CTvStandbyFigure |
|
52 // Empty default constructor. |
|
53 // ----------------------------------------------------------------------------- |
|
54 // |
|
55 CTvStandbyFigure::CTvStandbyFigure() |
|
56 { |
|
57 } |
|
58 |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // CTvStandbyFigure::ConstructL |
|
62 // Open the needed sessions, load the original bitmap and draw over it. |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 void CTvStandbyFigure::ConstructL( |
|
66 const TDesC& aFilename, |
|
67 TInt aImageNumber ) |
|
68 { |
|
69 // Setup the font and bitmap server and open session to it |
|
70 User::LeaveIfError( FbsStartup() ); |
|
71 User::LeaveIfError( RFbsSession::Connect() ); |
|
72 |
|
73 // Create and load a bitmap from the given file, then draw the text over it |
|
74 iBitmap = new (ELeave) CFbsBitmap(); |
|
75 TInt err = iBitmap->Load( aFilename, aImageNumber ); |
|
76 User::LeaveIfError( err ); |
|
77 } |
|
78 |
|
79 |
|
80 // ----------------------------------------------------------------------------- |
|
81 // CTvStandbyFigure::NewLC |
|
82 // Two-phased constructor. |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 CTvStandbyFigure* CTvStandbyFigure::NewLC( |
|
86 const TDesC& aFilename, |
|
87 TInt aImageNumber ) |
|
88 { |
|
89 CTvStandbyFigure* self = new (ELeave) CTvStandbyFigure(); |
|
90 CleanupStack::PushL( self ); |
|
91 self->ConstructL( aFilename, aImageNumber ); |
|
92 return self; |
|
93 } |
|
94 |
|
95 |
|
96 // ----------------------------------------------------------------------------- |
|
97 // CTvStandbyFigure::NewL |
|
98 // Two-phased constructor. |
|
99 // ----------------------------------------------------------------------------- |
|
100 // |
|
101 CTvStandbyFigure* CTvStandbyFigure::NewL( |
|
102 const TDesC& aFilename, |
|
103 TInt aImageNumber ) |
|
104 { |
|
105 CTvStandbyFigure* self = CTvStandbyFigure::NewLC( |
|
106 aFilename, |
|
107 aImageNumber ); |
|
108 CleanupStack::Pop( self ); |
|
109 return self; |
|
110 } |
|
111 |
|
112 |
|
113 // ----------------------------------------------------------------------------- |
|
114 // CTvStandbyFigure::NewL |
|
115 // Release the bitmap and close the session. |
|
116 // ----------------------------------------------------------------------------- |
|
117 // |
|
118 CTvStandbyFigure::~CTvStandbyFigure() |
|
119 { |
|
120 if ( iBitmap ) |
|
121 { |
|
122 iBitmap->Reset(); |
|
123 delete iBitmap; |
|
124 RFbsSession::Disconnect(); |
|
125 } |
|
126 } |
|
127 |
|
128 |
|
129 // ----------------------------------------------------------------------------- |
|
130 // CTvStandbyFigure::RgbConvertL |
|
131 // Convert bitmap to RGB565. |
|
132 // ----------------------------------------------------------------------------- |
|
133 // |
|
134 TUint16* CTvStandbyFigure::RgbConvertL() |
|
135 { |
|
136 TSize drawingSize( iBitmap->SizeInPixels() ); |
|
137 TInt pixels = drawingSize.iWidth * drawingSize.iHeight; |
|
138 TUint16* RGB565Data = new(ELeave) TUint16[pixels]; |
|
139 CleanupStack::PushL(RGB565Data); |
|
140 |
|
141 //This is needed to lock the bitmap object before |
|
142 //manipulating the object using TBitmapUtil object |
|
143 iBitmap->LockHeapLC(); |
|
144 TBitmapUtil bitmapUtil( iBitmap ); |
|
145 bitmapUtil.Begin( TPoint( 0, 0 ) ); |
|
146 |
|
147 for (TInt y = 0; y < drawingSize.iHeight; ++y) |
|
148 { |
|
149 bitmapUtil.SetPos( TPoint( 0, y ) ); |
|
150 for (TInt x = 0; x < drawingSize.iWidth; ++x) |
|
151 { |
|
152 TUint32 pixelValue = bitmapUtil.GetPixel(); |
|
153 TUint r = (pixelValue >> 16) & 0xff; |
|
154 TUint g = (pixelValue >> 8) & 0xff; |
|
155 TUint b = pixelValue & 0xff; |
|
156 RGB565Data[x + y * drawingSize.iWidth] = |
|
157 (( r >> 3) << 11) + |
|
158 (( g >> 2) << 5) + |
|
159 (b >> 3); |
|
160 bitmapUtil.IncXPos(); |
|
161 } |
|
162 } |
|
163 |
|
164 bitmapUtil.End(); |
|
165 |
|
166 CleanupStack::PopAndDestroy(); // bitmapUtil |
|
167 CleanupStack::Pop(RGB565Data); |
|
168 return RGB565Data; |
|
169 } |
|
170 |
|
171 |
|
172 // ----------------------------------------------------------------------------- |
|
173 // CTvStandbyFigure::GetFigureSize |
|
174 // ----------------------------------------------------------------------------- |
|
175 // |
|
176 void CTvStandbyFigure::GetFigureSize( TSize& aSize ) |
|
177 { |
|
178 aSize = iBitmap->SizeInPixels(); |
|
179 } |
|
180 |
|
181 // End of File |