home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Think Class Libraries / PixelWorld classes 1.2 / CPixelWorld.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-30  |  4.4 KB  |  125 lines  |  [TEXT/KAHL]

  1. /******************************************************************************
  2.  CPixelWorld.h
  3.  
  4.                     Interface for the PixelWorld Class
  5.     
  6.     The CPixelWorld class is a subclass of CBitMap designed to maintain a 
  7.     color offscreen drawing environment using the standard conventions of 
  8.     Color QuickDraw.  An offscreen color graphics device (GDevice) and an 
  9.     offscreen color graphics port (CGrafPort) are used to maintain this 
  10.     offscreen world.  This implementation supports 1,2,4 and 8 bit pixel 
  11.     depths.  Pixel depths of 16 and 32 bits are currently not supported.  
  12.     
  13.     This implementation does not depend upon any 32-Bit QuickDraw features.  
  14.     Future versions of the CPixelWorld class will provide support for pixel 
  15.     depths of 16 and 32 bits, and for GWorlds under 32-Bit QuickDraw.  
  16.     
  17.     SUPERCLASS = CBitMap
  18.     
  19.     This implementation is based in part on material copyrighted by 
  20.     Symantec Corporation and Apple Computer, Inc.  
  21.     
  22.     Copyright © 1992 Vincent R. Vann, Jr.  All rights reserved.  
  23.  
  24.     Version 1.1 Changes:
  25.     [
  26.         - CopyFrom and CopyTo methods were modified so that the foreground 
  27.           and background colors are set to black and white before calling 
  28.           CopyBits.  This ensures that the PixelWorld image is copied with 
  29.           the proper colors.  The foreground and background colors of the 
  30.           current CGrafPort are preserved by these methods. 
  31.     ]
  32.  
  33.     Version 1.2 Changes:
  34.     [
  35.         - added new instance variables saveFgColor and saveBgColor.
  36.         - implemented new methods SaveColors, RestoreColors, 
  37.           CopyFromColors, and CopyToColors.  
  38.         - changed CopyFrom and CopyTo methods to use these color routines.
  39.         - see comments for CopyFromColors and CopyToColors for information 
  40.           about how to colorize your image.  
  41.     ]
  42.  
  43.  ******************************************************************************/
  44.  
  45. #define _H_CPixelWorld
  46.  
  47. #include "CBitMap.h"                    /* Interface for its superclass        */
  48. #include "LongCoordinates.h"
  49.  
  50. class CPixelWorld : public CBitMap {        /* Class Declaration                */
  51.  
  52. public:
  53.                             /** Instance Variables **/
  54.     
  55.     Boolean                worldIsOK;            /* TRUE if initialized successfully    */
  56.     Boolean                worldHasColor;        /* TRUE if have Color QuickDraw        */
  57.     Boolean                worldHas32BitQD;    /* TRUE if have 32-Bit QuickDraw    */
  58.     Boolean                worldOwnsPixels;    /* TRUE if world owns pixel image    */
  59.     Boolean                worldPixelsLocked;    /* TRUE if pixel image is locked    */
  60.     
  61.     short                worldDepth;            /* Pixel depth                    */
  62.     LongRect            worldBounds;        /* Bounds rectangle                */
  63.     CTabHandle            worldColors;        /* Color table handle            */
  64.     Handle                worldPixels;        /* Pixel image handle            */
  65.     GDHandle            worldDevice;        /* Offscreen GDevice handle        */
  66.     CGrafPtr            worldPort;            /* Offscreen CGrafPort pointer    */
  67.     
  68.     GDHandle            saveDevice;            /* Saved graphics device        */
  69.     RGBColor            saveFgColor;        /* Saved foreground color        */
  70.     RGBColor            saveBgColor;        /* Saved background color        */
  71.     
  72.                             /** Instance Methods **/
  73.     
  74.                                 /** Contruction **/
  75.     void        IPixelWorld( short aPixelDepth, Rect *aBoundsRect, 
  76.                                 CTabHandle aColorTable, Handle aPixelImage, 
  77.                                 short aRowBytes);
  78.     void        IPixelWorldBW( short aPixelDepth, Rect *aBoundsRect, 
  79.                                 Handle aPixelImage, short aRowBytes);
  80.     void        IPixelWorldColor( short aPixelDepth, Rect *aBoundsRect, 
  81.                                 CTabHandle aColorTable, Handle aPixelImage, 
  82.                                 short aRowBytes);
  83.     
  84.                                 /** Destruction **/
  85.     virtual void        Dispose(void);
  86.     
  87.                                 /** Checking **/
  88.     virtual Boolean        WorldIsOK( void);
  89.     
  90.                                 /** Accessing Parameters **/
  91.     virtual short        GetPixelDepth( void);
  92.     virtual void        GetBounds( LongRect *theBounds);
  93.     virtual short        GetRowBytes( void);
  94.     
  95.                                 /** Accessing Pixels **/
  96.     virtual Boolean        PixelIsBlack( LongPt *pixelPos);
  97.     virtual Boolean        GetPixelColor( LongPt *pixelPos, RGBColor *color);
  98.     virtual Handle        GetHandleToPixels( void);
  99.     virtual Ptr            GetPointerToPixels( void);
  100.     
  101.                                 /** Setting Coordinates **/
  102.     virtual void        SetBoundsOrigin( short hOrigin, short vOrigin);
  103.     
  104.                                 /** Drawing **/
  105.     virtual void        BeginDrawing( void);
  106.     virtual void        EndDrawing( void);
  107.     
  108.                                 /** Activating **/
  109.     virtual    void        ActivateWorld( void);
  110.     virtual void        DeactivateWorld( void);
  111.     virtual Boolean        LockWorld( Boolean setLock);
  112.     
  113.                                 /** Colors **/
  114.     virtual    void        SaveColors( void);
  115.     virtual    void        RestoreColors( void);
  116.     virtual    void        CopyFromColors( void);
  117.     virtual    void        CopyToColors( void);
  118.     
  119.                                 /** Copying **/
  120.     virtual void        CopyFrom( LongRect *fromRect, LongRect *toRect, RgnHandle maskRgn);
  121.     virtual void        CopyTo( LongRect *fromRect, LongRect *toRect, RgnHandle maskRgn);
  122. };
  123.  
  124.  
  125.