javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/graphics/graphicsfactory.cpp
changeset 80 d6dafc5d983f
parent 57 59b3b4473dc8
equal deleted inserted replaced
78:71ad690e91f5 80:d6dafc5d983f
    11 
    11 
    12 #include "graphics.h"
    12 #include "graphics.h"
    13 #include "bufferimpl.h"
    13 #include "bufferimpl.h"
    14 #include "graphicscontextimpl.h"
    14 #include "graphicscontextimpl.h"
    15 #include "pixmap.h"
    15 #include "pixmap.h"
       
    16 #include "imageimpl.h"
    16 #include "imageloaderimpl.h"
    17 #include "imageloaderimpl.h"
    17 #include "imagedataimpl.h"
    18 #include "imagedataimpl.h"
    18 #include "palettedataimpl.h"
    19 #include "palettedataimpl.h"
    19 #include "gfxlog.h"
    20 #include "gfxlog.h"
    20 
    21 
    52     GFX_LOG_FUNC_CALL();
    53     GFX_LOG_FUNC_CALL();
    53     GraphicsContextImpl* gc = new GraphicsContextImpl();
    54     GraphicsContextImpl* gc = new GraphicsContextImpl();
    54     return static_cast<GraphicsContext*>(gc);
    55     return static_cast<GraphicsContext*>(gc);
    55 }
    56 }
    56 
    57 
    57 /*static*/ Image* GraphicsFactory::createImage(int aWidth, int aHeight, int aFillColor)
    58 /*static*/ Image* GraphicsFactory::createImage(int aWidth, int aHeight, int aFillColor, TImageType aType)
    58 {
    59 {
    59     GFX_LOG_FUNC_CALL();
    60     GFX_LOG_FUNC_CALL();
    60     Pixmap* pixmap = new Pixmap();
    61     if(aType == EImage)
    61     pixmap->createBySize(aWidth, aHeight, aFillColor ,EFormatNone /*format decided by framework*/);
    62         {
    62     return static_cast<Image*>(pixmap);
    63         ImageImpl* image = new ImageImpl();
       
    64         // create ARGB32 image
       
    65         image->createBySize(aWidth, aHeight, aFillColor, EFormatARGB32); 
       
    66         return static_cast<Image*>(image);
       
    67         }
       
    68     else if(aType == EPixmap)
       
    69         {
       
    70         Pixmap* pixmap = new Pixmap();
       
    71         pixmap->createBySize(aWidth, aHeight, aFillColor ,EFormatNone /*format decided by framework*/);
       
    72         return static_cast<Image*>(pixmap);
       
    73         }
       
    74     return NULL;
    63 }
    75 }
    64 
    76 
    65 /*static*/ Image* GraphicsFactory::createImage(Image* aImage, int aX, int aY, int aWidth, int aHeight)
    77 /*static*/ Image* GraphicsFactory::createImage(Image* aImage, int aX, int aY, int aWidth, int aHeight)
    66 {
    78 {
    67     GFX_LOG_FUNC_CALL();
    79     GFX_LOG_FUNC_CALL();
    68     Pixmap* pixmap = new Pixmap();
    80     if(aImage->type() == EImage)
    69     pixmap->createFromImage(aImage, aX, aY, aWidth, aHeight);
    81         {
    70     return static_cast<Image*>(pixmap);
    82         ImageImpl* image = new ImageImpl();
    71 }
    83         image->createFromImage(aImage, aX, aY, aWidth, aHeight); 
    72 
    84         return static_cast<Image*>(image);    
    73 /*static*/ Image* GraphicsFactory::createImage(const QImage& aImage)
    85         }
    74 {
    86     else if(aImage->type() == EPixmap)
    75     GFX_LOG_FUNC_CALL();
    87         {
    76     Pixmap* pixmap = new Pixmap();
    88         Pixmap* pixmap = new Pixmap();
    77     pixmap->createFromQImage(aImage);
    89         pixmap->createFromImage(aImage, aX, aY, aWidth, aHeight);
    78     return static_cast<Image*>(pixmap);
    90         return static_cast<Image*>(pixmap);       
    79 }
    91         }
    80 
    92     return NULL;
    81 /*static*/ Image* GraphicsFactory::createImage(const QPixmap& aPixmap)
    93 }
    82 {
    94 
    83     GFX_LOG_FUNC_CALL();
    95 /*static*/ Image* GraphicsFactory::createImage(Image* aImage, int aX, int aY, int aWidth, 
    84     Pixmap* pixmap = new Pixmap();
    96                                                   int aHeight, TImageType aTypeOfCopy)
    85     pixmap->createFromQPixmap(aPixmap);
    97 {
    86     return static_cast<Image*>(pixmap);
    98     GFX_LOG_FUNC_CALL();
    87 }
    99     if(aTypeOfCopy == EImage)
    88 
   100         {
    89 /*static*/ Image* GraphicsFactory::createImage(int* aRgbData, int aWidth, int aHeight, bool aHasAlpha)
   101         ImageImpl* image = new ImageImpl();
    90 {
   102         image->createFromImage(aImage, aX, aY, aWidth, aHeight); 
    91     Pixmap* pixmap = new Pixmap();
   103         return static_cast<Image*>(image);    
    92     pixmap->createFromRGB(aRgbData, aWidth, aHeight, aHasAlpha);
   104         }
    93     return static_cast<Image*>(pixmap);
   105     else if(aTypeOfCopy == EPixmap)
    94 }
   106         {
    95 
   107         Pixmap* pixmap = new Pixmap();
    96 /*static*/ ImageLoader* GraphicsFactory::createImageLoader()
   108         pixmap->createFromImage(aImage, aX, aY, aWidth, aHeight);
    97 {
   109         return static_cast<Image*>(pixmap);       
    98     GFX_LOG_FUNC_CALL();
   110         }
    99     ImageloaderImpl* loader = new ImageloaderImpl();
   111     return NULL;
       
   112 }
       
   113 
       
   114 /*static*/ Image* GraphicsFactory::createImage(const QImage& aImage, TImageType aType)
       
   115 {
       
   116     GFX_LOG_FUNC_CALL();
       
   117     if(aType == EImage)
       
   118          {
       
   119          ImageImpl* image = new ImageImpl();
       
   120          // create ARGB32 image
       
   121          image->createFromQImage(aImage);
       
   122          return static_cast<Image*>(image);
       
   123          }
       
   124      else if(aType == EPixmap)
       
   125          {
       
   126          Pixmap* pixmap = new Pixmap();
       
   127          pixmap->createFromQImage(aImage);
       
   128          return static_cast<Image*>(pixmap);
       
   129          }
       
   130     return NULL;
       
   131 }
       
   132 
       
   133 /*static*/ Image* GraphicsFactory::createImage(const QPixmap& aPixmap, TImageType aType)
       
   134 {
       
   135     GFX_LOG_FUNC_CALL();
       
   136     if(aType == EImage)
       
   137          {
       
   138          ImageImpl* image = new ImageImpl();
       
   139          // create ARGB32 image
       
   140          image->createFromQPixmap(aPixmap);
       
   141          return static_cast<Image*>(image);
       
   142          }
       
   143      else if(aType == EPixmap)
       
   144          {
       
   145          Pixmap* pixmap = new Pixmap();
       
   146          pixmap->createFromQPixmap(aPixmap);
       
   147          return static_cast<Image*>(pixmap);
       
   148          }
       
   149     return NULL;
       
   150 }
       
   151 
       
   152 /*static*/ Image* GraphicsFactory::createImage(int* aRgbData, int aWidth, int aHeight, bool aHasAlpha, TImageType aType)
       
   153 {
       
   154     GFX_LOG_FUNC_CALL();
       
   155     if(aType == EImage)
       
   156         {
       
   157         ImageImpl* image = new ImageImpl();
       
   158         image->createFromRGB(aRgbData, aWidth, aHeight, aHasAlpha); 
       
   159         return static_cast<Image*>(image);    
       
   160         }
       
   161     else if(aType == EPixmap)
       
   162         {
       
   163         Pixmap* pixmap = new Pixmap();
       
   164         pixmap->createFromRGB(aRgbData, aWidth, aHeight, aHasAlpha);
       
   165         return static_cast<Image*>(pixmap);       
       
   166         }
       
   167     return NULL; 
       
   168 }
       
   169 
       
   170 /*static*/ ImageLoader* GraphicsFactory::createImageLoader(TImageType aType)
       
   171 {
       
   172     GFX_LOG_FUNC_CALL();
       
   173     ImageloaderImpl* loader = new ImageloaderImpl(aType);
   100     return static_cast<ImageLoader*>(loader);
   174     return static_cast<ImageLoader*>(loader);
   101 }
   175 }
   102 
   176 
   103 /*static*/ Image* GraphicsFactory::createImage(ImageDataWrapper* aImageDataPtr)
   177 /*static*/ Image* GraphicsFactory::createImage(ImageDataWrapper* aImageDataPtr, TImageType aType)
   104 {
   178 {
   105     GFX_LOG_FUNC_CALL();
   179     GFX_LOG_FUNC_CALL();
   106     Pixmap* pixmap = new Pixmap();
   180     
   107     pixmap->createFromImageData(aImageDataPtr);
   181     if(aType == EImage)
   108     return static_cast<Image*>(pixmap);
   182          {
       
   183          ImageImpl* image = new ImageImpl();
       
   184          image->createFromImageData(aImageDataPtr); 
       
   185          return static_cast<Image*>(image);    
       
   186          }
       
   187     else if(aType == EPixmap)
       
   188          {
       
   189          Pixmap* pixmap = new Pixmap();
       
   190          pixmap->createFromImageData(aImageDataPtr);
       
   191          return static_cast<Image*>(pixmap);       
       
   192          }
       
   193     return NULL;
   109 }
   194 }
   110 
   195 
   111 /*static*/ ImageDataWrapper* GraphicsFactory::createImageData(Image* aImage)
   196 /*static*/ ImageDataWrapper* GraphicsFactory::createImageData(Image* aImage)
   112 {
   197 {
   113     GFX_LOG_FUNC_CALL();
   198     GFX_LOG_FUNC_CALL();