javauis/lcdui_akn/javalcdui/inc.nokialcdui/TMIDFormatConverter.h
branchRCL_3
changeset 19 04becd199f91
equal deleted inserted replaced
16:f5050f1da672 19:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 2006 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:  Abstract base class for format converters.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef TMIDFORMATCONVERTER_H
       
    21 #define TMIDFORMATCONVERTER_H
       
    22 
       
    23 // INCLUDES
       
    24 #include <gdi.h> //TDisplayMode
       
    25 #include "TMIDInternalARGB.h"
       
    26 #include "TMIDBitmapParameters.h"
       
    27 #include "TMIDTransformer.h"
       
    28 #include "nativecolors.h"
       
    29 
       
    30 // CONSTANTS
       
    31 const TInt KErrIllegalArgumentException = -11;
       
    32 const TInt KErrArrayIndexOutOfBoundsException = -12;
       
    33 
       
    34 //  CLASS DEFINITION
       
    35 /**
       
    36  * Abstract base class for format converters.
       
    37  *
       
    38  */
       
    39 NONSHARABLE_CLASS(TMIDFormatConverter)
       
    40 {
       
    41 public: // Constructor
       
    42     TMIDFormatConverter();
       
    43 
       
    44 public: //  initialization
       
    45     virtual void InitializeL(const TMIDBitmapParameters& aParameters);
       
    46 
       
    47 public: // abstract methods
       
    48     // Convert from internal to int
       
    49     virtual TUint32 ConvertInternal(const TMIDInternalARGB& aInternal) = 0;
       
    50 
       
    51     // Convert from int to internal
       
    52     virtual void Convert(TMIDInternalARGB& aResult, TUint32) const = 0;
       
    53 
       
    54     // Get pixel from current position
       
    55     virtual void GetPixel(TMIDInternalARGB& aResult) const = 0;
       
    56 
       
    57     // Get alpha which is in same format as bitmap
       
    58     virtual TUint8 GetAlpha() const = 0;
       
    59 
       
    60     // Get pixel using alpha bitmap
       
    61     virtual void GetPixelWithAlpha(TMIDInternalARGB& aResult) const;
       
    62 
       
    63     // Plot pixel to current position
       
    64     virtual void PlotPixel(const TMIDInternalARGB& aInternal) = 0;
       
    65 
       
    66     // Get pixel using alpha bitmap
       
    67     virtual void PlotPixelWithAlpha(const TMIDInternalARGB& aInternal);
       
    68 
       
    69     // Checks is alpha calculation needed
       
    70     virtual TBool IsAlpha();
       
    71 
       
    72     // Set bitmap
       
    73     virtual void SetBitmap(TUint32* aBitmap) = 0;
       
    74 
       
    75     // Get bitmap
       
    76     virtual TUint32* Bitmap() = 0;
       
    77 
       
    78 public: // new methods
       
    79     // Advance position in x-axis, returns EFalse if advancing is in the end
       
    80     inline TBool AdvanceX();
       
    81 
       
    82     // Advance position in y-axis, returns EFalse if advancing is in the end
       
    83     inline TBool AdvanceY();
       
    84 
       
    85     // set alpha bitmap
       
    86     void SetAlpha(TUint32* aAlphaBitmap, const TDisplayMode& aAlphaMode)
       
    87     {
       
    88         iAlphaBitmap = aAlphaBitmap;
       
    89         iAlphaMode = aAlphaMode;
       
    90     }
       
    91 
       
    92 protected: // abstract methods
       
    93     // checks how many pixels is occupied and is last pixel in that limit
       
    94     virtual TBool CheckSize(TInt aPixelSize, TInt aLastDrawnPixelOffset) = 0;
       
    95 
       
    96 protected: // new methods
       
    97     void CalculateAlpha(TMIDInternalARGB& aTargetColor,
       
    98                         const TMIDInternalARGB& aBelowColor);
       
    99 public:
       
   100     TInt iOffset;
       
   101     TRect iBitmapRect;
       
   102 
       
   103 protected: // data
       
   104     TMIDTransformer iTransformer;
       
   105     TInt iScanlength;
       
   106     TInt iAlphaScanLength; // in 32 bit words
       
   107     TInt iAnchor;
       
   108     TUint32* iAlphaBitmap;
       
   109     TDisplayMode iAlphaMode;
       
   110     TBool iTransparency;
       
   111 };
       
   112 
       
   113 inline TBool TMIDFormatConverter::AdvanceX()
       
   114 {
       
   115     iOffset += iTransformer.iXMove.iX;
       
   116     return ETrue;
       
   117 }
       
   118 
       
   119 inline TBool TMIDFormatConverter::AdvanceY()
       
   120 {
       
   121     iOffset += iTransformer.iYMove.iX;
       
   122     return ETrue;
       
   123 }
       
   124 
       
   125 #endif // TMIDFORMATCONVERTER_H