home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 5.7 KB | 215 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWBitmap.h
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWBITMAP_H
- #define FWBITMAP_H
-
- #ifndef FWGCONST_H
- #include "FWGConst.h"
- #endif
-
- #ifndef FWRECT_H
- #include "FWRect.h"
- #endif
-
- #ifndef SLGRDEF_H
- #include "SLGrDef.h"
- #endif
-
- #ifndef SLGDEV_H
- #include "SLGDev.h"
- #endif
-
- #ifndef FWRESOUR_H
- #include "FWResour.h"
- #endif
-
- #ifndef FWGC_H
- #include "FWGC.h"
- #endif
-
- #ifndef FWPICTUR_H
- #include "FWPictur.h"
- #endif
-
- #ifndef SLBITMAP_H
- #include "SLBitmap.h"
- #endif
-
- #ifndef SLPALETE_H
- #include "SLPalete.h"
- #endif
-
- //========================================================================================
- // Forward Class Declarations
- //========================================================================================
-
- class FW_CWritableStream;
- class FW_CReadableStream;
- class FW_CPicture;
- class FW_CGraphicContext;
- struct FW_SGraphicContext;
- class FW_CColor;
- struct FW_SColor;
-
- //========================================================================================
- // class FW_CBitmap
- //========================================================================================
-
- class FW_CBitmap : public FW_TGrRefPtr<FW_HBitmap>
- {
- public:
- FW_DECLARE_AUTO(FW_CBitmap)
-
- FW_CBitmap();
- ~FW_CBitmap();
-
- FW_CBitmap(short width, short height,
- short pixelSize, FW_Palette palette = NULL);
-
- FW_CBitmap(void* image, long imageSize, short rowBytes,
- short width, short height, short pixelSize, FW_Palette palette = NULL);
-
- #ifdef FW_BUILD_MAC
- static const FW_SRect gWholePicture;
- FW_CBitmap(const FW_CPicture& picture,
- const FW_CColor& fillColor = FW_kRGBWhite,
- const FW_CRect& pictPart = gWholePicture);
-
- FW_CPicture MacGetAsPicture(const FW_SRect& pictPart = gWholePicture) const;
- #endif
-
- FW_CBitmap(FW_PResourceFile& resourceFile, FW_ResourceID resourceID);
- FW_CBitmap(FW_CReadableStream& stream, FW_Boolean bDIBHeader = TRUE);
-
- FW_CBitmap(FW_PlatformBitmap platformBitmap);
-
- FW_CBitmap(const FW_CBitmap& other);
- FW_CBitmap& operator=(const FW_CBitmap& other);
-
- FW_CBitmap Copy(const FW_CRect& srcRect) const;
-
- friend FW_CReadableStream& operator>>(FW_CReadableStream& stream, FW_CBitmap& bitmap);
- friend FW_CWritableStream& operator<<(FW_CWritableStream& stream, const FW_CBitmap& bitmap);
-
- // Delegation
-
- FW_Boolean IsEqual(const FW_CBitmap& bitmap) const
- { return FW_PrivBitmap_IsEqual(fRep, bitmap.fRep); }
-
- // Handle operations
-
- FW_PlatformBitmap GetPlatformBitmap() const
- { return FW_PrivBitmap_GetPlatformBitmap(fRep); }
-
- FW_Boolean IsPlatformBitmapOrphan() const
- { return FW_PrivBitmap_IsPlatformBitmapOrphan(fRep); }
-
- FW_PlatformBitmap OrphanPlatformBitmap() const
- { return FW_PrivBitmap_OrphanPlatformBitmap(fRep); }
-
- void SetPlatformBitmap(FW_PlatformBitmap newBitmap)
- { FW_PrivBitmap_SetPlatformBitmap(fRep, newBitmap); }
-
- void AdoptPlatformBitmap(FW_PlatformBitmap newBitmap)
- { FW_PrivBitmap_AdoptPlatformBitmap(fRep, newBitmap); }
-
- // Palette
-
- FW_Palette GetPalette() const;
-
- void SetPalette(FW_Palette palette)
- { FW_FailOnError(FW_PrivBitmap_SetPalette(fRep, palette)); }
-
- // Bitmap info
- void GetBitmapInfo(
- short& width,
- short& height,
- short& rowBytes,
- short& pixelSize) const
- { FW_FailOnError(FW_PrivBitmap_GetBitmapInfo(fRep, width, height, rowBytes, pixelSize)); }
-
- void GetBitmapBounds(FW_SGraphicContext& gc, FW_SRect& bounds) const;
-
- void GetBitmapBounds(FW_SRect& bounds) const
- { FW_PrivBitmap_GetBitmapBounds(fRep, bounds); }
-
- void GetPixelColor(short horiz, short vert, FW_CColor& color) const
- { FW_PrivBitmap_GetPixelColor(fRep, horiz, vert, color); }
- void SetPixelColor(short horiz, short vert, const FW_CColor& newColor)
- { FW_PrivBitmap_SetPixelColor(fRep, horiz, vert, newColor); }
-
- // Changing the bitmap
-
- void ChangeBitmap(
- void* image,
- long imageSize,
- short rowBytes,
- short width,
- short height,
- short pixelSize,
- FW_Boolean bScale)
- { FW_FailOnError(FW_PrivBitmap_ChangeBitmap(fRep, image, imageSize, rowBytes, width, height, pixelSize, bScale)); }
-
- void ChangeBitmap(
- short width,
- short height,
- short pixelSize,
- FW_Boolean bScale)
- { FW_FailOnError(FW_PrivBitmap_ChangeBitmapGeometry(fRep, width, height, pixelSize, bScale)); }
-
- void SetImage(void* image, long imageSize, short rowBytes)
- { FW_FailOnError(FW_PrivBitmap_SetImage(fRep, image, imageSize, rowBytes)); }
-
- // Copy Pixels
- void CopyPixels(
- const FW_CBitmap& bitmapDst,
- FW_SRect& boundsSrc,
- FW_SRect& boundsDst)
- { FW_FailOnError(FW_PrivBitmap_CopyPixels(fRep, bitmapDst.fRep, boundsSrc, boundsDst)); }
-
- // Macintosh specific
-
- #ifdef FW_BUILD_MAC
- PixMapHandle MacLockPixels()
- { return FW_PrivBitmap_MacLockPixels(fRep); } // return NULL if fails
-
- void MacUnlockPixels()
- { FW_FailOnError(FW_PrivBitmap_MacUnlockPixels(fRep)); }
-
- FW_Boolean MacIsPixelsLocked() const
- { return FW_PrivBitmap_MacIsPixelsLocked(fRep); }
- #endif
- };
-
- //========================================================================================
- // class FW_CBitmapContext
- //========================================================================================
-
- class FW_CBitmapContext : public FW_CGraphicContext
- {
- public:
- FW_DECLARE_AUTO(FW_CBitmapContext)
-
- FW_CBitmapContext(Environment* ev, FW_CBitmap& bitmap);
- ~FW_CBitmapContext();
-
- virtual void Reset();
-
- private:
- FW_CBitmap fBitmap;
- FW_HGDevice fGraphicDevice;
-
- #ifdef FW_BUILD_WIN
- HBITMAP fOldBitmap;
- #endif
- };
-
- #endif
-