|
1 /* |
|
2 * Copyright (c) 2006-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: 4 bits for red, green and blue component in a pixel. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "TMID444Format.h" |
|
21 |
|
22 |
|
23 inline TUint16 ConvertInternalInline444(const TMIDInternalARGB& aInternal) |
|
24 { |
|
25 // no transparency, so alpha is 0 |
|
26 return (TUint16)(((aInternal.iR & KFourLeftBits) << KMIDShift4Bits) + |
|
27 (aInternal.iG & KFourLeftBits) + |
|
28 ((aInternal.iB & KFourLeftBits) >> KMIDShift4Bits)); |
|
29 } |
|
30 |
|
31 inline void ConvertInline444(TMIDInternalARGB& aResult, TUint32 aColor) |
|
32 { |
|
33 aResult.iA = KAlphaFullOpaque; |
|
34 aResult.iR = KNativeColors[(aColor & K444RMax) >> KMIDShift8Bits ]; |
|
35 aResult.iG = KNativeColors[(aColor & K444GMax) >> KMIDShift4Bits ]; |
|
36 aResult.iB = KNativeColors[(aColor & K444BMax)]; |
|
37 } |
|
38 |
|
39 void TMID444Format::InitializeL(const TMIDBitmapParameters& aParameters) |
|
40 { |
|
41 TMIDFormatConverter::InitializeL(aParameters); |
|
42 iOffset += iTransformer.iPoint.iX + iTransformer.iPoint.iY * iScanlength; |
|
43 iBitmap = (TUint16*)aParameters.iPixels; |
|
44 } |
|
45 |
|
46 TUint32 TMID444Format::ConvertInternal(const TMIDInternalARGB& aInternal) |
|
47 { |
|
48 return ConvertInternalInline444(aInternal); |
|
49 } |
|
50 |
|
51 void TMID444Format::Convert(TMIDInternalARGB& aResult, TUint32 aColor) const |
|
52 { |
|
53 ConvertInline444(aResult, aColor); |
|
54 } |
|
55 |
|
56 void TMID444Format::GetPixel(TMIDInternalARGB& aResult) const |
|
57 { |
|
58 ConvertInline444(aResult, iBitmap[ iOffset ]); // CSI: 2 Wrong index means implementation error # |
|
59 } |
|
60 |
|
61 TUint8 TMID444Format::GetAlpha() const |
|
62 { |
|
63 // we need only last 8 bits since it is either white or black |
|
64 return (TUint8)(((TUint16*)iAlphaBitmap)[ iOffset ] & KMIDEightRightBits); // CSI: 2 Wrong index means implementation error # |
|
65 } |
|
66 |
|
67 void TMID444Format::PlotPixel(const TMIDInternalARGB& aInternal) |
|
68 { |
|
69 iBitmap[ iOffset ] = ConvertInternalInline444(aInternal); // CSI: 2 Wrong index means implementation error # |
|
70 } |
|
71 |
|
72 |
|
73 TBool TMID444Format::CheckSize(TInt aPixelSize, TInt aLastDrawnPixelOffset) |
|
74 { |
|
75 return((aLastDrawnPixelOffset * KBytesInPixel444) <= aPixelSize); |
|
76 } |
|
77 |