home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / include / igbitmap.hpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-22  |  7.4 KB  |  243 lines

  1. #ifndef _IGBITMAP_
  2. #define _IGBITMAP_
  3. /*******************************************************************************
  4. * FILE NAME: igbitmap.hpp                                                      *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   Declaration of the classes:                                                *
  8. *     IGBitmap                                                                 *
  9. *                                                                              *
  10. * COPYRIGHT:                                                                   *
  11. *   IBM Open Class Library                                                     *
  12. *   (C) Copyright International Business Machines Corporation 1992, 1996       *
  13. *   Licensed Material - Program-Property of IBM - All Rights Reserved.         *
  14. *   US Government Users Restricted Rights - Use, duplication, or disclosure    *
  15. *   restricted by GSA ADP Schedule Contract with IBM Corp.                     *
  16. *                                                                              *
  17. *******************************************************************************/
  18.  
  19. #include <igraphic.hpp>
  20. #include <ihandle.hpp>
  21. #include <ipoint.hpp>
  22. #include <icolor.hpp>
  23.  
  24.  
  25. #pragma pack(4)
  26.  
  27. class IString;
  28. class IGraphicContext;
  29. class IResourceId;
  30. class IGBitmapData;
  31. struct _MOD;
  32.  
  33. class IGBitmap : public IGraphic {
  34. typedef IGraphic
  35.   Inherited;
  36.  
  37. public:
  38.  
  39. enum ImageFormat {
  40.   Bitmap,
  41.   GIF,
  42.   PCX,
  43.   TIFF,
  44.   Targa,
  45.   Amiga,
  46.   XBM,
  47.   PSEG
  48.   };
  49.  
  50. /*------------------------------- Constructors -------------------------------*/
  51.   IGBitmap  ( const IBitmapHandle&   bitmapHandle           );
  52.  
  53.   IGBitmap  ( unsigned long          bitmapIdentifier,
  54.               IBase::Boolean         useColorData = false   );
  55.  
  56.   IGBitmap  ( const IResourceId&     resourceIdentifier,
  57.               IBase::Boolean         useColorData = false   );
  58.  
  59.   IGBitmap  ( const IString&         imageFilename          );
  60.  
  61.   IGBitmap  ( const IString&         imageFilename,
  62.               ImageFormat            imageFormat            );
  63.  
  64.   IGBitmap  ( const IGraphicContext& graphicContext,
  65.               const IRectangle&      windowRectangle        );
  66.  
  67.   IGBitmap  ( const IGBitmap&        bitmap,
  68.               const IRectangle&      rectangle,
  69.               long                   rasterOperation = normal );
  70.  
  71. virtual
  72.   ~IGBitmap ( );
  73.  
  74. /*----------------------- Common Raster Operations ---------------------------*/
  75. static const long
  76.   IC_IMPORTU black,
  77.   IC_IMPORTU notSourceErase,
  78.   IC_IMPORTU halftone,
  79.   IC_IMPORTU invert,
  80.   IC_IMPORTU sourceErase,
  81.   IC_IMPORTU destInvert,
  82.   IC_IMPORTU patternInvert,
  83.   IC_IMPORTU sourceInvert,
  84.   IC_IMPORTU sourceAnd,
  85.   IC_IMPORTU mergePaint,
  86.   IC_IMPORTU mergeCopy,
  87.   IC_IMPORTU normal,
  88.   IC_IMPORTU sourcePaint,
  89.   IC_IMPORTU patternCopy,
  90.   IC_IMPORTU patternPaint,
  91.   IC_IMPORTU white;
  92.  
  93. /*------------------------------ Compress Mode -------------------------------*/
  94. enum CompressMode {
  95.   bitAnd,
  96.   bitOr,
  97.   ignore
  98. #if ( IC_OBSOLETE <= IC_OBSOLETE_2 )
  99. #ifndef __DIGRAPHS__
  100.   ,
  101.   or  = bitOr,
  102.   and = bitAnd
  103. #endif
  104. #endif
  105.   };
  106.  
  107. /*-------------------------------- Drawing -----------------------------------*/
  108. virtual IGBitmap
  109.   &drawOn              ( IGraphicContext& graphicContext            ),
  110.  
  111.   &drawOn              ( IGraphicContext& graphicContext,
  112.                          long             rasterOperation           ),
  113.  
  114.   &drawOn              ( IGraphicContext& graphicContext,
  115.                          const IPoint&    targetBottomLeft,
  116.                          const IPoint&    targetTopRight,
  117.                          const IPoint&    sourceBottomLeft,
  118.                          const IPoint&    sourceTopRight,
  119.                          long             rasterOperation = normal,
  120.                          CompressMode     compressMode    = ignore  );
  121.  
  122. /*--------------------------- Writing To A File ------------------------------*/
  123. virtual IGBitmap
  124.   &writeToFile         ( const IString& imageFilename,
  125.                          ImageFormat    imageFormat            );
  126.  
  127. virtual ImageFormat
  128.   imageFormat          ( ) const;
  129.  
  130. /*--------------------------- Bitmap Positioning -----------------------------*/
  131. virtual IGBitmap
  132.   &moveTo              ( const IPoint& point   ),
  133.   &sizeTo              ( const ISize&  newSize );
  134.  
  135. virtual ISize
  136.   size                 ( ) const;
  137. virtual IPoint
  138.   position             ( ) const;
  139.  
  140. /*-------------------------- Modifying The Bitmap ----------------------------*/
  141. virtual IGBitmap
  142.   &reflectHorizontally ( ),
  143.   &reflectVertically   ( ),
  144.   &transposeXForY      ( ),
  145.   &rotateBy90          ( ),
  146.   &rotateBy180         ( ),
  147.   &rotateBy270         ( );
  148.  
  149. /*------------------------------- View Option --------------------------------*/
  150. enum ViewOption {
  151.   raw,
  152.   errorDiffused,
  153.   halftoned
  154.   };
  155.  
  156. virtual IGBitmap
  157.   &setViewOption       ( ViewOption viewOption = raw );
  158. virtual ViewOption
  159.   viewOption           ( ) const;
  160.  
  161.  
  162. /*--------------------------- Bitmap Transparency ----------------------------*/
  163. virtual IGBitmap
  164.   &setTransparentColor   ( const IColor& aColor ),
  165.   &resetTransparentColor ( );
  166.  
  167. virtual IColor
  168.   transparentColor       ( ) const;
  169.  
  170. virtual IBase::Boolean
  171.   hasTransparentColor    ( ) const;
  172.  
  173. /*----------------------------- Bitmap Palette -------------------------------*/
  174. unsigned long
  175.   setPalette             ( unsigned long palette );
  176.  
  177. unsigned long
  178.   palette                ( ) const;
  179.  
  180. /*-------------------------------- Accessors ---------------------------------*/
  181. virtual IBitmapHandle
  182.   handle               ( ) const;
  183.  
  184. virtual IPointerHandle
  185.   asPointerHandle      ( ) const;
  186.  
  187. /*----------------------------- Bitmap Copying -------------------------------*/
  188. static IBitmapHandle
  189.   copy                   ( const IBitmapHandle& bitmapHandle );
  190.  
  191. protected:
  192. /*---------------------------- Loading a Bitmap ------------------------------*/
  193. static unsigned long
  194.   loadBitmap           ( unsigned long        bitmapIdentifier,
  195.                          const IModuleHandle& moduleHandle,
  196.                          const ISize&         bitmapSize = ISize(0,0) ),
  197.   tryToLoadBitmap      ( unsigned long        bitmapIdentifier,
  198.                          const IModuleHandle& moduleHandle,
  199.                          const ISize&         bitmapSize = ISize(0,0) );
  200.  
  201. private:
  202. /*------------------------------ Hidden Members ------------------------------*/
  203.   IGBitmap    ( const IGBitmap& bitmap );
  204. IGBitmap
  205.  &operator=   ( const IGBitmap& bitmap );
  206.  
  207. /*--------------------------------- Private ----------------------------------*/
  208. friend class IResourceLibrary;
  209. static unsigned long
  210.   copyBitmap(IGraphicContext&, unsigned long, const ISize&);
  211. IGBitmap
  212.   &modReflect  ( int (* _Optlink reflector)(_MOD*, _MOD*) ),
  213.   &loadFromFile( const IString&    filename,
  214.                  int               ft             ),
  215.   &draw        ( IGraphicContext&, long, void *   );
  216. static int
  217.   ft( const ImageFormat& imageFormat );
  218. void
  219.   createMask();
  220. IBitmapHandle
  221.   fBitmap,
  222.   fMask;
  223. IPoint
  224.   fPos;
  225. IColor*
  226.   fTransparent;
  227. IBase::Boolean
  228.   fCheckMaskNeeded;
  229. ViewOption
  230.   fVo;
  231. ImageFormat
  232.   fIf;
  233. struct _MOD*
  234.   fMod;
  235.  
  236. IGBitmapData
  237.  *fGBitmapData;
  238. };
  239.  
  240. #pragma pack()
  241.  
  242. #endif // _IGBITMAP_
  243.