javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/graphics/graphics.h
changeset 80 d6dafc5d983f
parent 57 59b3b4473dc8
child 87 1627c337e51e
equal deleted inserted replaced
78:71ad690e91f5 80:d6dafc5d983f
    75 /**
    75 /**
    76  * Native image types
    76  * Native image types
    77  */
    77  */
    78 enum TImageType
    78 enum TImageType
    79 {
    79 {
    80     ENone    = -1,
    80     ENone    = -1,  // Type not defined
    81     EImage    = 0,
    81     EImage   = 0,   // QImage
    82     EPixmap    = 1
    82     EPixmap  = 1    // QPixmap
    83 };
    83 };
    84 
    84 
    85 /**
    85 /**
    86  * Image transforms
    86  * Image transforms
    87  */
    87  */
    96     ETransMirrorRot180      = 106,
    96     ETransMirrorRot180      = 106,
    97     ETransMirrorRot270      = 107,
    97     ETransMirrorRot270      = 107,
    98     ETransFlipHorizontal    = 108,
    98     ETransFlipHorizontal    = 108,
    99     ETransFlipVertical      = 109
    99     ETransFlipVertical      = 109
   100 };
   100 };
       
   101 
       
   102 /**
       
   103  * Supported reflections.
       
   104  */
       
   105 enum TReflection
       
   106 {
       
   107     /**
       
   108      * Identity transformation.
       
   109      */
       
   110     EReflectNone = 0,
       
   111     /**
       
   112      * Vertical reflection (in horizontal line through region center).
       
   113      */
       
   114     EReflectVert = 1,
       
   115     /**
       
   116      * Horizontal reflection (in vertical line through region center).
       
   117      */
       
   118     EReflectHorz = 2,
       
   119     /**
       
   120      * Reflection in diagonal line from top left corner to bottom right corner
       
   121      */
       
   122     EReflectDiag = 4
       
   123 }; 
       
   124 
       
   125 /**
       
   126  * Supported transformation are all combinations of the supported reflections.
       
   127  * Note that two reflections make a rotation, so that this list includes pure
       
   128  * rotations by multiples of 90 degrees.
       
   129  */
       
   130 enum TTransformType
       
   131 {
       
   132     ETransNoneType          = EReflectNone,
       
   133     ETransMirrorRot180Type  = EReflectVert,
       
   134     ETransMirrorType        = EReflectHorz,
       
   135     ETransRot180Type        = EReflectVert | EReflectHorz,
       
   136     ETransMirrorRot270Type  = EReflectDiag,
       
   137     ETransRot90Type         = EReflectVert | EReflectDiag,
       
   138     ETransRot270Type        = EReflectHorz | EReflectDiag,
       
   139     ETransMirrorRot90Type   = EReflectVert | EReflectHorz|EReflectDiag
       
   140 };
       
   141 
   101 
   142 
   102 /**
   143 /**
   103  * Blending modes
   144  * Blending modes
   104  */
   145  */
   105 enum TBlendingMode
   146 enum TBlendingMode
  1042     /**
  1083     /**
  1043      * Gets the format of the image.
  1084      * Gets the format of the image.
  1044      *
  1085      *
  1045      * @return a format in which image is represented.
  1086      * @return a format in which image is represented.
  1046      */
  1087      */
  1047     virtual int getFormat() = 0;
  1088     virtual TImageFormat getFormat() = 0;
  1048 
  1089 
  1049     /**
  1090     /**
  1050      * Gets the height of the image.
  1091      * Gets the height of the image.
  1051      * @return height
  1092      * @return height
  1052      */
  1093      */
  1053     virtual int getHeight() = 0;
  1094     virtual int getHeight() = 0;
  1054 
  1095 
  1055     /**
  1096     /**
  1056      * Returnes native QPixmap.
  1097      * Returnes the actual QImage wrapper by this instance.
       
  1098      * If the image in guestion is not QImage, null is returned.
       
  1099      * The actual type of the image can be queried with type() -method.
       
  1100      * Note that the caller of this method must not delete returned QImage.
       
  1101      * This variant should be used if caller needs only to read the pixels
       
  1102      * of returned image. Using const Qimage pointer ensures that the QImage.bits()
       
  1103      * variant not detaching memory is used, i.e. it ensures better perfomance.
       
  1104      * @return native QImage or null if type is not QImage
       
  1105      */
       
  1106     virtual const QImage* getConstImage() = 0;
       
  1107     
       
  1108     /**
       
  1109      * Returnes the actual QImage wrapper by this instance.
       
  1110      * If the image in guestion is not QImage, null is returned.
       
  1111      * The actual type of the image can be queried with type() -method.
       
  1112      * Note that the caller of this method must not delete returned QImage.
       
  1113      * It is recommended to use toImage() instead if possible.
       
  1114      * @return native QImage or null if type is not QImage
       
  1115      */
       
  1116     virtual QImage* getImage() = 0;
       
  1117     
       
  1118     /**
       
  1119      * Returnes the actual QPixmap wrapper by this instance.
  1057      * If the image in guestion is not QPixmap, null is returned.
  1120      * If the image in guestion is not QPixmap, null is returned.
       
  1121      * The actual type of the image can be queried with type() -method.
       
  1122      * It is recommended to use this method over the non const getPixmap(), 
       
  1123      * if possible. 
       
  1124      * @return native QPixmap or null if type is not QPixmap
       
  1125      */
       
  1126     virtual const QPixmap* getConstPixmap() = 0;
       
  1127 
       
  1128     /**
       
  1129      * Returnes the actual QPixmap wrapper by this instance.
       
  1130      * If the image in guestion is not QPixmap, null is returned.
       
  1131      * The actual type of the image can be queried with type() -method.
  1058      * Note that the caller of this method must not delete returned pixmap.
  1132      * Note that the caller of this method must not delete returned pixmap.
       
  1133      * This method must be used with extreme caution and only if 
       
  1134      * there's no other option.
       
  1135      * It is recommended to use toPixmap() or getConstPixmap() instead if possible.
  1059      * @return native QPixmap or null if type is not QPixmap
  1136      * @return native QPixmap or null if type is not QPixmap
  1060      */
  1137      */
  1061     virtual QPixmap* getPixmap() = 0;
  1138     virtual QPixmap* getPixmap() = 0;
  1062 
  1139     
  1063     /**
  1140     /**
  1064      * Copies image rgb (32-bit) data of given region to given data array.
  1141      * Copies image rgb (32-bit) data of given region to given data array.
  1065      * @param aRgbdata The array to copy the data into.
  1142      * @param aRgbdata The array to copy the data into.
  1066      * @param aOffset The offset of image data start in array to copy into.
  1143      * @param aOffset The offset of image data start in array to copy into.
  1067      * @param aScanlength The relative offset between corresponding pixels in consecutive rows of the region.
  1144      * @param aScanlength The relative offset between corresponding pixels in consecutive rows of the region.
  1070      * @param aWidth The width of the area to be copied.
  1147      * @param aWidth The width of the area to be copied.
  1071      * @param aHeight The height of the area to be copied.
  1148      * @param aHeight The height of the area to be copied.
  1072      * @exception GfxException
  1149      * @exception GfxException
  1073      */
  1150      */
  1074     virtual void getRgb(int* aRgbdata, int aOffset, int aScanlength, int aX, int aY, int aWidth, int aHeight) = 0;
  1151     virtual void getRgb(int* aRgbdata, int aOffset, int aScanlength, int aX, int aY, int aWidth, int aHeight) = 0;
  1075 
       
  1076 
  1152 
  1077     /**
  1153     /**
  1078      * Copies image rgb (1-bit) data of given region to given data array.
  1154      * Copies image rgb (1-bit) data of given region to given data array.
  1079      * @param aRgbdata The array to copy the data into.
  1155      * @param aRgbdata The array to copy the data into.
  1080      * @param aTransparencyMask The array to copy transparency values into
  1156      * @param aTransparencyMask The array to copy transparency values into
  1108      * @return width
  1184      * @return width
  1109      */
  1185      */
  1110     virtual int getWidth() = 0;
  1186     virtual int getWidth() = 0;
  1111 
  1187 
  1112     /**
  1188     /**
  1113      * Converts this image to QImage for pixel access.
  1189      * Converts this image to QImage for pixel access regardless
       
  1190      * of the actual image type inside. Returned instance is always
       
  1191      * a copy of the original, thus modifications to it are not
       
  1192      * reflected to state of this Image instance.
       
  1193      * It is recommended to use this variant when it's only needed to 
       
  1194      * read the pixels of the image, as usign QImage.bits() with const
       
  1195      * QImage prevents any pixeldata detaching and thus is better in
       
  1196      * performance.
  1114      * If conversion fails a null image is returned.
  1197      * If conversion fails a null image is returned.
  1115      * @return QImage instance created from wrapped Qt's image type.
  1198      * @return QImage instance created from wrapped Qt's image type.
  1116      */
  1199      */
  1117       virtual QImage toImage() = 0;
  1200     virtual const QImage toConstImage() = 0;
       
  1201     
       
  1202     /**
       
  1203      * Converts this image to QImage for pixel access regardless
       
  1204      * of the actual image type inside. Returned instance is always
       
  1205      * a copy of the original, thus modifications to it are not
       
  1206      * reflected to state of this Image instance.
       
  1207      * If conversion fails a null image is returned.
       
  1208      * @return QImage instance created from wrapped Qt's image type.
       
  1209      */
       
  1210     virtual QImage toImage() = 0;
       
  1211     
       
  1212     /**
       
  1213      * Converts this image to QPixmap regardless of the actual
       
  1214      * image type inside. Returned instance is always a copy
       
  1215      * of the original, thus modifications to it are not
       
  1216      * reflected to state of this Image instance.
       
  1217      * If conversion fails a null pixmap is returned.
       
  1218      * @return QPixmap instance created from wrapped Qt's image type.
       
  1219      */
       
  1220     virtual QPixmap toPixmap() = 0;
  1118 
  1221 
  1119     /**
  1222     /**
  1120      * Transforms image with given transformation.
  1223      * Transforms image with given transformation.
  1121      * @param aTransform The transform type
  1224      * @param aTransform The transform type
  1122      */
  1225      */
  1195      * The image will be scaled to this size on load. Useful for SVG images. 
  1298      * The image will be scaled to this size on load. Useful for SVG images. 
  1196      * @param aWidth The width to scale to when the Image is loaded. 
  1299      * @param aWidth The width to scale to when the Image is loaded. 
  1197      * @param aHeight The height to scale to when the Image is loaded. 
  1300      * @param aHeight The height to scale to when the Image is loaded. 
  1198      */
  1301      */
  1199     virtual void setLoadSize(int aWidth, int aHeight) = 0;
  1302     virtual void setLoadSize(int aWidth, int aHeight) = 0;
       
  1303     
       
  1304     /**
       
  1305      * Sets the result image type.
       
  1306      * @param aType The type of the image either EImage or EPixmap
       
  1307      */
       
  1308     virtual void setResultImageType(TImageType aType) = 0;
  1200 };
  1309 };
  1201 
  1310 
  1202 /**
  1311 /**
  1203  * Interface for wrapping SWT image data structure
  1312  * Interface for wrapping SWT image data structure
  1204  */
  1313  */
  1648      *
  1757      *
  1649      * @param aWidth Image width
  1758      * @param aWidth Image width
  1650      * @param aHeight Image height
  1759      * @param aHeight Image height
  1651      * @param aFillColor The initial color for the image in format #00RRGGBB
  1760      * @param aFillColor The initial color for the image in format #00RRGGBB
  1652      * where hight order byte, i.e. alpha is ingored
  1761      * where hight order byte, i.e. alpha is ingored
  1653      */
  1762      * @param aType The type of the image either EImage or EPixmap
  1654     static Image* createImage(int aWidth, int aHeight, int aFillColor);
  1763      */
       
  1764     static Image* createImage(int aWidth, int aHeight, int aFillColor, TImageType aType);
  1655 
  1765 
  1656     /**
  1766     /**
  1657      * Create a copy based on the given image.
  1767      * Create a copy based on the given image.
  1658      * If the given copy region is empty, the whole image is copied.
  1768      * If the given copy region is empty, the whole image is copied.
       
  1769      * The copy will have the same native type as the original.
  1659      *
  1770      *
  1660      * @param aImage The source image
  1771      * @param aImage The source image
  1661      * @param aX The top-left x coordinate of the copy region.
  1772      * @param aX The top-left x coordinate of the copy region.
  1662      * @param aY The top-left y coordinate of the copy region.
  1773      * @param aY The top-left y coordinate of the copy region.
  1663      * @param aWidth The width of the copy region.
  1774      * @param aWidth The width of the copy region.
  1664      * @param aHeight The height of the copy region.
  1775      * @param aHeight The height of the copy region.
  1665      * @see Image::createImage
  1776      * @see Image::createImage
  1666      */
  1777      */
  1667     static Image* createImage(
  1778     static Image* createImage(Image* aImage, int aX = 0, int aY = 0, int aWidth = 0, int aHeight = 0);
  1668         Image* aImage, int aX = 0, int aY = 0, int aWidth = 0, int aHeight = 0);
  1779     
       
  1780     /**
       
  1781      * Create a copy based on the given image.
       
  1782      * If the given copy region is empty, the whole image is copied.
       
  1783      * The new copy will hav the native type specified by aTypeOfCopy. 
       
  1784      *
       
  1785      * @param aImage The source image
       
  1786      * @param aX The top-left x coordinate of the copy region.
       
  1787      * @param aY The top-left y coordinate of the copy region.
       
  1788      * @param aWidth The width of the copy region.
       
  1789      * @param aHeight The height of the copy region.
       
  1790      * @param aTypeOfCopy The native type of the new copy, either EImage or EPixmap
       
  1791      * @see Image::createImage
       
  1792      */
       
  1793     static Image* createImage(Image* aImage, int aX, int aY, int aWidth, 
       
  1794                                  int aHeight, TImageType aTypeOfCopy);
  1669     
  1795     
  1670     /**
  1796     /**
  1671      * Create image from a QImage
  1797      * Create image from a QImage
  1672      *
  1798      *
  1673      * @param aImage The source QImage
  1799      * @param aImage The source QImage
  1674      */
  1800      */
  1675     static Image* createImage(const QImage& aImage);
  1801     static Image* createImage(const QImage& aImage, TImageType aType);
  1676 
  1802 
  1677     /**
  1803     /**
  1678      * Create image from a QPixmap.
  1804      * Create image from a QPixmap.
  1679      * 
  1805      * 
  1680      * @param aImage The source QPixmap
  1806      * @param aImage The source QPixmap
  1681      */
  1807      */
  1682     static Image* createImage(const QPixmap& aPixmap);
  1808     static Image* createImage(const QPixmap& aPixmap, TImageType aType);
  1683 
  1809 
  1684     /**
  1810     /**
  1685      * Creates an image based on the given ARGB data array.
  1811      * Creates an image based on the given ARGB data array.
  1686      * @param aRgbData ARGB data array. One pixel is specified as 0xAARRGGBB.
  1812      * @param aRgbData ARGB data array. One pixel is specified as 0xAARRGGBB.
  1687      * @param aWidth Image width
  1813      * @param aWidth Image width
  1688      * @param aHeight Image height
  1814      * @param aHeight Image height
  1689      * @param aHasAlpha If true the rgb data has also an alpha channel,
  1815      * @param aHasAlpha If true the rgb data has also an alpha channel,
  1690      * otherwise all pixels are fully opaque, e.g. 0xFFRRGGBB.
  1816      * otherwise all pixels are fully opaque, e.g. 0xFFRRGGBB.
  1691      */
  1817      * @param aType The type of the image either EImage or EPixmap
  1692     static Image* createImage(int* aRgbData, int aWidth, int aHeight, bool aHasAlpha);
  1818      */
       
  1819     static Image* createImage(int* aRgbData, int aWidth, int aHeight, bool aHasAlpha, TImageType aType);
  1693 
  1820 
  1694     /**
  1821     /**
  1695      * Creates new imageloader instance
  1822      * Creates new imageloader instance
  1696      */
  1823      * @param aType The type of the loaded image either EImage or EPixmap
  1697     static ImageLoader* createImageLoader();
  1824      */
  1698 
  1825     static ImageLoader* createImageLoader(TImageType aType);
  1699     /**
  1826 
  1700      * TODO
  1827     /**
  1701      */
  1828      * Creates an Image instance from given image data.
  1702     static Image* createImage(ImageDataWrapper* aImageDataPtr);
  1829      * @param aImageDataPtr The image data 
       
  1830      * @param aType The type of the image either EImage or EPixmap 
       
  1831      */
       
  1832     static Image* createImage(ImageDataWrapper* aImageDataPtr, TImageType aType);
  1703 
  1833 
  1704     /**
  1834     /**
  1705      * TODO
  1835      * TODO
  1706      */
  1836      */
  1707     static ImageDataWrapper* createImageData(Image* aImage = NULL);
  1837     static ImageDataWrapper* createImageData(Image* aImage = NULL);