javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/graphics/qt/imagebase.h
changeset 80 d6dafc5d983f
equal deleted inserted replaced
78:71ad690e91f5 80:d6dafc5d983f
       
     1 /*******************************************************************************
       
     2  * Copyright (c) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3  * All rights reserved. This program and the accompanying materials
       
     4  * are made available under the terms of the Eclipse Public License v1.0
       
     5  * which accompanies this distribution, and is available at
       
     6  * http://www.eclipse.org/legal/epl-v10.html
       
     7  *
       
     8  * Contributors:
       
     9  *     Nokia Corporation - initial API and implementation
       
    10  *******************************************************************************/
       
    11 
       
    12 #ifndef IMAGEBASE_H_
       
    13 #define IMAGEBASE_H_
       
    14 
       
    15 #include "graphics.h"
       
    16 #include <QImage>
       
    17 #include <QTransform>
       
    18 
       
    19 namespace Java { namespace GFX {
       
    20 
       
    21 class ImageBase: public Image
       
    22     {
       
    23 public:
       
    24     ImageBase(); 
       
    25     virtual ~ImageBase();
       
    26     
       
    27     /**
       
    28      * from Image
       
    29      * @see Image
       
    30      */
       
    31     virtual void createBySize(int aWidth, int aHeight, int aFillColor, TImageFormat aFormat) = 0;
       
    32     virtual void createFromQImage(const QImage& aImage) = 0;
       
    33     virtual void createFromQPixmap(const QPixmap& aPixmap) = 0;
       
    34     virtual void createFromImage(Image* aImage, int aX, int aY, int aWidth, int aHeight) = 0;
       
    35     virtual void createFromImageData(ImageDataWrapper* aData) = 0;
       
    36     virtual void createFromRGB(int* aRgbdata, int aWidth, int aHeight, bool aHasAlpha) = 0;
       
    37     virtual void dispose() = 0;
       
    38     virtual QPaintDevice* getBindable() = 0;
       
    39     virtual TImageFormat getFormat() = 0;
       
    40     virtual int getHeight() = 0;
       
    41     virtual const QImage* getConstImage() = 0;
       
    42     virtual QImage* getImage() = 0;
       
    43     virtual const QPixmap* getConstPixmap() = 0;
       
    44     virtual QPixmap* getPixmap() = 0;
       
    45     virtual void getRgb(int* aRgbdata, int aOffset, int aScanlength, int aX, int aY, int aWidth, int aHeight) = 0;
       
    46     virtual void getRgb(char* aRgbdata, char* aTransparencyMask,int aOffset, int aScanlength, int aX, int aY, int aWidth, int aHeight, int aFormat) = 0;
       
    47     virtual void getRgb(short* aRgbdata, int aOffset, int aScanlength, int aX, int aY, int aWidth, int aHeight, int aFormat) = 0;
       
    48     virtual int getWidth() = 0;
       
    49     virtual const QImage toConstImage() = 0;
       
    50     virtual QImage toImage() = 0;
       
    51     virtual QPixmap toPixmap() = 0;
       
    52     virtual void transform(TTransform aTransform) = 0;
       
    53     virtual TImageType type() = 0;
       
    54     virtual int getAlpha();
       
    55     virtual bool hasMask();
       
    56     virtual bool hasAlphaChannel() = 0;
       
    57     
       
    58 protected:
       
    59     /**
       
    60      * Writes RGB to given int type data array.
       
    61      */
       
    62     void doGetRgb(QImage& image, int* aRgbdata, int aOffset, int aScanlength, int aX, int aY, 
       
    63                   int aWidth, int aHeight);
       
    64     
       
    65     /**
       
    66      * Writes RGB to given char type data array.
       
    67      */
       
    68     void doGetRgb(QImage& image, char* aRgbdata, char* aTransparencyMask,int aOffset, int aScanlength, 
       
    69                    int aX, int aY, int aWidth, int aHeight, int aFormat);
       
    70     
       
    71     /**
       
    72      * Writes RGB to given short type data array.
       
    73      */ 
       
    74     void doGetRgb(QImage& image, short* aRgbdata, int aOffset, int aScanlength, int aX, int aY, 
       
    75                   int aWidth, int aHeight, int aFormat);
       
    76     
       
    77     /**
       
    78      * Creates transform matrix for given transformation.
       
    79      * @param aTransform the transform type to be created
       
    80      */
       
    81     QTransform generateTransformMatrix(TTransform aTransform);
       
    82     
       
    83     /**
       
    84      * Processes image data and creates QImage with properties
       
    85      * defined in the image data.
       
    86      * 
       
    87      * @param aData Image data to be processed
       
    88      */
       
    89     QImage imageDataToQImage(ImageDataWrapper* aData);
       
    90     
       
    91     /**
       
    92      * Maps given QImage based image format to those defined in TImageFormat.
       
    93      * @param qtImageFormat the image format in Qt defitions
       
    94      * @return format in internal type
       
    95      */
       
    96     TImageFormat mapQtFormatToInternal(QImage::Format qtImageFormat);
       
    97     
       
    98     /**
       
    99      * Maps given internal (TImageFormat) image format to Qt format.
       
   100      * @param internalImageFormat the image format in internal type
       
   101      * @return format in Qt type
       
   102      */
       
   103     QImage::Format mapInternalFormatToQt(TImageFormat internalImageFormat);
       
   104     
       
   105     /**
       
   106      * Level of alpha
       
   107      */
       
   108     int      mAlpha;
       
   109     
       
   110     /**
       
   111      * Mask flag
       
   112      */
       
   113     bool     mHasMask;
       
   114     
       
   115     
       
   116     };
       
   117 
       
   118 } // namespace GFX
       
   119 } // namespace Java
       
   120 
       
   121 #endif /* IMAGEBASE_H_ */