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