35 NCels = NCelsUsed = std::max(1, numCels);
36 NRows = std::max(1, numRows);
37 CSize = celSize.cx && celSize.cy ?
47 " from slicing the bitmap @" << (
void*)bmp);
58 NCels = NCelsUsed = std::max(1, numCels);
59 NRows = std::max(1, numRows);
65 TPalette palette(
static_cast<HPALETTE
>(::GetStockObject(DEFAULT_PALETTE)));
66 Bitmap =
new TBitmap(dib, &palette);
69 " from slicing the dib @" << (
void*)&dib);
82 NCelsUsed = src.NCelsUsed;
83 NGrowBy = src.NGrowBy;
84 BkColor = src.BkColor;
85 NCurRow = src.NCurRow;
88 ShouldDelete = src.ShouldDelete;
90 Bitmap = ShouldDelete ?
new TBitmap(*src.Bitmap) : src.Bitmap;
93 " from @" << (
void*)&src);
105 NCels = initCount > 1 ? initCount : 1;
108 NRows = std::max(1, numRows);
121 " size (" << size.cx <<
"x" << size.cy <<
")");
147 ShouldDelete = src.ShouldDelete;
148 Bitmap = ShouldDelete ?
new TBitmap(*src.Bitmap) : src.Bitmap;
152 NCurRow = src.NCurRow;
156 TRACEX(OwlGadget, 1,
"TCelArray @" << (
void*)
this <<
157 " contents copied over with TCelArray @" << (
void*)&src);
167 row = row < 0 ? NCurRow : row;
168 return TPoint(Offs.x+cel*CSize.cx, Offs.y+CSize.cy*row);
177 row = row < 0 ? NCurRow : row;
178 return TRect(
TPoint(Offs.x+cel*CSize.cx, Offs.y+CSize.cy*row), CSize);
188 int width = image.
Width();
189 int count = width /
CelSize().cx;
191 if (!MaybeResize(count))
196 int index = NCelsUsed;
199 TRACEX(OwlGadget, 1,
"TCelArray @" << (
void*)
this <<
" added bitmap @" <<
214 if (NCelsUsed >= NCels)
215 if (!Resize(NCels + NGrowBy))
219 TSize(CSize.cx,CSize.cy*NRows),
CelRect(index,0).TopLeft());
221 TRACEX(OwlGadget, 1,
"TCelArray @" << (
void*)
this <<
" added TCelArray @" <<
222 (
void*)&src <<
" index 0x" << index);
234 if (index >= NCelsUsed)
240 else if (index < NCelsUsed) {
241 if (index < NCelsUsed-1) {
244 bitmapDC.
BitBlt(offs.x, offs.y, (NCelsUsed-index-1)*CSize.cx,
245 CSize.cy*NRows,bitmapDC, offs.x+CSize.cx, offs.y);
250 TRACEX(OwlGadget, 1,
"TCelArray @" << (
void*)
this <<
" removed index 0x" << index);
261 if (index >= 0 && index < NCelsUsed) {
263 TRACEX(OwlGadget, 1,
"TCelArray @" << (
void*)
this <<
" index 0x" << index <<
264 " replaced by TBitmap @" << (
void*)&image);
276 if (index >= 0 && index < NCelsUsed) {
278 TSize(CSize.cx,CSize.cy*NRows),
CelRect(srcidx,0).TopLeft());
279 TRACEX(OwlGadget, 1,
"TCelArray @" << (
void*)
this <<
" index 0x" << index <<
280 " replaced by TCelArray @" <<
" index 0x" << srcidx);
320 srcDC, cr.left, cr.top, cr.
Width(), cr.
Height(), rop);
336 return dstDC.
BitBlt(
TRect(pt, size), srcDC, offset);
344TCelArray::MaybeResize(
int need)
346 if (NCelsUsed + need > NCels)
347 if (!Resize(NCels + NGrowBy*((NCelsUsed+need-NCels) / NGrowBy + 1)))
357TCelArray::Resize(
int newCount)
364 TBitmap* bitmap =
new TBitmap(
TScreenDC(), CSize.cx*newCount, CSize.cy*NRows);
369 TMemoryDC srcDC(*Bitmap);
370 TMemoryDC dstDC(*bitmap);
371 dstDC.BitBlt(
TRect(0, 0, CSize.cx*NCels, CSize.cy*NRows), srcDC, TPoint(0));
375 srcDC.RestoreBitmap();
Definition of a bitmap Cel array class.
#define PRECONDITION(condition)
#define TRACEX(group, level, message)
TBitmap is the GDI bitmap class derived from TGdiObject.
TSize Size() const
The width and height of the bitmap in pixels.
int Width() const
Returns the width of this bitmap using GDI's GetObject.
int Height() const
Returns the height of this bitmap using GDI's GetObject.
TCelArray is a horizontal array of cels (a unit of animation) created by slicing a portion of or an e...
TSize CelSize() const
Return the size of the celarray.
bool StretchBlt(int index, TDC &dc, const TRect &dstRect, uint32 rop=SRCCOPY)
Draws the image of the cel onto the DC.
TCelArray(TBitmap *bmp, int numCels, TSize celSize=TSize(), TPoint offset=TPoint(), int numRows=1, TAutoDelete=AutoDelete)
Constructs a TCelArray from a bitmap by slicing the bitmap into a horizontal array of cels of a speci...
bool BitBlt(int index, TDC &dc, int x, int y, uint32 rop=SRCCOPY)
Draws the cel at index onto the DC at position x and y.
bool Remove(int index=-1)
Removes a cel from this CelArray.
TCelArray & operator=(const TCelArray &)
Assign a CelArray over this CelArray, replacing all contents.
virtual ~TCelArray()
Destruct the CelArray and clean up its resources.
bool Replace(int index, const TBitmap &image)
Replace a cel in this CelArray.
int Add(const TBitmap &image)
Add new cel(s) to the CelArray - return index of new addition.
TPoint CelOffset(int cel) const
Returns the position of the upper left corner of a given cel from the current row,...
TRect CelRect(int cel) const
Returns the upper left and lower right corner of a given cell from the current row,...
Class wrapper for management of color values.
TDC is the root class for GDI DC wrappers.
bool BitBlt(int dstX, int dstY, int w, int h, const TDC &srcDC, int srcX, int srcY, uint32 rop=SRCCOPY)
Performs a bit-block transfer from srcDc (the given source DC) to this DC (the destination DC).
bool StretchBlt(int dstX, int dstY, int dstW, int dstH, const TDC &srcDC, int srcX, int srcY, int srcW, int srcH, uint32 rop=SRCCOPY)
Copies a bitmap from the source DC to a destination rectangle on this DC specified either by upper le...
Pseudo-GDI object Device Independent Bitmap (DIB) class.
int Width() const
Returns the width of the DIB.
int Height() const
Returns the height of the DIB.
A device context (DC) class derived from TCreatedDC, TMemoryDC provides access to a memory DC.
TPalette is the GDI Palette class derived from TGdiObject.
TPoint is a support class, derived from tagPOINT.
TPoint()
Constructs an uninitialized point.
TRect is a mathematical class derived from tagRect.
int Height() const
Returns the height of this rectangle (bottom - top).
int Width() const
Returns the width of this rectangle (right - left).
TRect()
Default constructor that does nothing.
The tagSIZE struct is defined as.
TSize()
Default constructor that does nothing.
TAutoDelete
Flag for Handle ctors to control Handle deletion in dtor.
Object Windows Library (OWLNext Core).
bool OwlCopyBmp(TBitmap &dstBM, const TBitmap &srcBM, const TPoint &pt, const TSize &size, const TPoint offset=TPoint(0, 0))
Copy specified bitmap to the destination DC.
DIAG_DECLARE_GROUP(OwlThread)
#define CONST_CAST(targetType, object)