home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 7.1 KB | 248 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWBmpShp.cpp
- // Release Version: $ 1.0d11 $
- //
- // Copyright: © 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWOS.hpp"
-
- #ifndef FWBMPSHP_H
- #include "FWBmpShp.h"
- #endif
-
- #ifndef FWGRGLOB_H
- #include "FWGrGlob.h"
- #endif
-
- #ifndef FWGC_H
- #include "FWGC.h"
- #endif
-
- #ifndef FWFXMATH_H
- #include "FWFxMath.h"
- #endif
-
- #ifndef FWRASTER_H
- #include "FWRaster.h"
- #endif
-
- // ----- Foundation Includes -----
-
- #ifndef FWSTREAM_H
- #include "FWStream.h"
- #endif
-
- #ifndef FWDEBUG_H
- #include "FWDebug.h"
- #endif
-
- //========================================================================================
- // RunTime Info
- //========================================================================================
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export on
- #endif
-
- #ifdef FW_BUILD_MAC
- #pragma segment fwgraphxshape
- #endif
-
- FW_DEFINE_CLASS_M1(FW_CBitmapShape, FW_CBoundedShape)
-
- FW_REGISTER_ARCHIVABLE_CLASS(FW_LBitmapShape, FW_CBitmapShape, FW_CBitmapShape::Read, FW_CShape::Write)
-
- //========================================================================================
- // CLASS FW_CBitmapShape
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CBitmapShape::FW_CBitmapShape
- //----------------------------------------------------------------------------------------
-
- FW_CBitmapShape::FW_CBitmapShape(const FW_CBitmapShape& other) :
- FW_CBoundedShape(other),
- fSrcRect(other.fSrcRect),
- fBitmap(other.fBitmap)
- {
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBitmapShape::FW_CBitmapShape
- //----------------------------------------------------------------------------------------
-
- FW_CBitmapShape::FW_CBitmapShape(FW_PBitmap bitmap, const FW_CRect& dstRect) :
- FW_CBoundedShape(dstRect, FW_kFill, FW_kNormalInk, FW_kNormalStyle, FW_kNormalFont),
- fBitmap(bitmap)
- {
- short width, height,rowBytes, pixelSize;
- fBitmap->GetBitmapInfo(width, height, rowBytes, pixelSize);
- fSrcRect.SetInt(0, 0, width, height);
-
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBitmapShape::FW_CBitmapShape
- //----------------------------------------------------------------------------------------
-
- FW_CBitmapShape::FW_CBitmapShape(FW_PBitmap bitmap, const FW_CRect& srcRect, const FW_CRect& dstRect) :
- FW_CBoundedShape(dstRect, FW_kFill, FW_kNormalInk, FW_kNormalStyle, FW_kNormalFont),
- fSrcRect(srcRect),
- fBitmap(bitmap)
- {
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBitmapShape::FW_CBitmapShape
- //----------------------------------------------------------------------------------------
-
- FW_CBitmapShape::FW_CBitmapShape(FW_CReadableStream& archive) :
- FW_CBoundedShape(archive)
- {
- archive.Read(&fSrcRect, 4);
- archive >> fBitmap;
-
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBitmapShape::~FW_CBitmapShape
- //----------------------------------------------------------------------------------------
-
- FW_CBitmapShape::~FW_CBitmapShape()
- {
- FW_START_DESTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBitmapShape::operator=
- //----------------------------------------------------------------------------------------
-
- FW_CBitmapShape& FW_CBitmapShape::operator=(const FW_CBitmapShape& other)
- {
- if (this != &other)
- {
- FW_CBoundedShape::operator=(other);
-
- fBitmap = other.fBitmap;
- fSrcRect = other.fSrcRect;
- }
-
- return *this;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBitmapShape::Copy
- //----------------------------------------------------------------------------------------
-
- FW_CShape* FW_CBitmapShape::Copy() const
- {
- return FW_NEW(FW_CBitmapShape, (*this));
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBitmapShape::Render
- //----------------------------------------------------------------------------------------
-
- void FW_CBitmapShape::Render(FW_CGraphicContext& gc) const
- {
- gc.GetRasterizer()->RenderBitmap(gc,
- fBitmap,
- fSrcRect,
- fRect,
- GetRenderVerb(),
- fInk);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBitmapShape::RenderBitmap
- //----------------------------------------------------------------------------------------
-
- void FW_CBitmapShape::RenderBitmap(FW_CGraphicContext& gc,
- FW_PBitmap bitmap,
- const FW_CRect& dstRect,
- const FW_PInk& ink)
- {
- FW_CRect srcRect;
- bitmap->GetBitmapBounds(srcRect);
-
- gc.GetRasterizer()->RenderBitmap(gc,
- bitmap,
- srcRect,
- dstRect,
- FW_kFill,
- ink);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBitmapShape::RenderBitmap
- //----------------------------------------------------------------------------------------
-
- void FW_CBitmapShape::RenderBitmap(FW_CGraphicContext& gc,
- FW_PBitmap bitmap,
- const FW_CRect& srcRect,
- const FW_CRect& dstRect,
- const FW_PInk& ink)
- {
- gc.GetRasterizer()->RenderBitmap(gc,
- bitmap,
- srcRect,
- dstRect,
- FW_kFill,
- ink);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBitmapShape::GetGeometry
- //----------------------------------------------------------------------------------------
-
- void FW_CBitmapShape::GetGeometry(FW_PBitmap& bitmap,
- FW_CRect& srcRect,
- FW_CRect& dstRect) const
- {
- bitmap = fBitmap;
- srcRect = fSrcRect;
- dstRect = fRect;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBitmapShape::SetGeometry
- //----------------------------------------------------------------------------------------
-
- void FW_CBitmapShape::SetGeometry(const FW_PBitmap& bitmap,
- const FW_CRect& srcRect,
- const FW_CRect& dstRect)
- {
- fBitmap = bitmap;
- fSrcRect = srcRect;
- fRect = dstRect;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBitmapShape::Flatten
- //----------------------------------------------------------------------------------------
-
- void FW_CBitmapShape::Flatten(FW_CWritableStream& archive) const
- {
- FW_CBoundedShape::Flatten(archive);
- archive.Write(&fSrcRect, 4);
- fBitmap->Flatten(archive);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CBitmapShape::Read
- //----------------------------------------------------------------------------------------
-
- void* FW_CBitmapShape::Read(FW_CReadableStream& archive)
- {
- FW_CBitmapShape* object = FW_NEW(FW_CBitmapShape, (archive));
- return object;
- }
-
-