14#if defined(__BORLANDC__)
57 TGdiObject(clipboard.GetClipboardData(CF_BITMAP))
61 TRACEX(OwlGDI,
OWL_CDLEVEL,
"TBitmap constructed @" << (
void*)
this <<
" from clipboard.");
70 Handle = ::CreateBitmap(width, height, planes, bitCount, bits);
71 WARNX(OwlGDI, !
Handle, 0,
"Cannot create bitmap (" << width <<
"x" <<
72 height <<
"x" << planes <<
")");
75 TRACEX(OwlGDI,
OWL_CDLEVEL,
"TBitmap constructed @" << (
void*)
this <<
" using parameters (" <<
76 dec << width <<
"x" << height <<
"x" << planes <<
")." << hex);
84 Handle = ::CreateBitmapIndirect(&bitmap);
85 WARNX(OwlGDI, !
Handle, 0,
"Cannot create bitmap from BITMAP @" <<
static_cast<const void*
>(&bitmap));
89 <<
" from BITMAP @" <<
static_cast<const void*
>(&bitmap) <<
".");
92#if defined(OWL5_COMPAT)
101 Handle = ::CreateBitmapIndirect((LPBITMAP)bitmap);
102 WARNX(OwlGDI, !
Handle, 0,
"Cannot create bitmap from BITMAP @" <<
103 hex << (
void*)bitmap);
106 TRACEX(OwlGDI,
OWL_CDLEVEL,
"TBitmap constructed @" << (
void*)
this <<
" from BITMAP @" <<
107 (
void*)bitmap <<
".");
119 Handle = ::CreateDiscardableBitmap(dc, width, height);
120 WARNX(OwlGDI, !
Handle, 0,
"Cannot create discardable bitmap (" << width <<
121 "x" << height <<
") for " <<
static_cast<void*
>(dc.
GetHDC()));
124 Handle = ::CreateCompatibleBitmap(dc, width, height);
125 WARNX(OwlGDI, !
Handle, 0,
"Cannot create compatible bitmap (" << width <<
126 "x" << height <<
") for " <<
static_cast<void*
>(dc.
GetHDC()));
132 TRACEX(OwlGDI,
OWL_CDLEVEL,
"Discardable TBitmap constructed @" << (
void*)
this <<
" (" <<
133 dec << width <<
"x" << height <<
") for " <<
static_cast<void*
>(dc.
GetHDC()) <<
".");
136 TRACEX(OwlGDI,
OWL_CDLEVEL,
"Compatible TBitmap constructed @" << (
void*)
this <<
" (" <<
137 dec << width <<
"x" << height <<
") for " <<
static_cast<void*
>(dc.
GetHDC()) <<
".");
147 Handle = ::CreateDIBitmap(dc,
150 const_cast<BITMAPINFO *
>(dib.
GetInfo()),
153 WARNX(OwlGDI, !
Handle, 0,
"Cannot create bitmap from DIB " <<
static_cast<void*
>(dib.
GetHandle())
154 <<
" for " <<
static_cast<void*
>(dc.
GetHDC()));
158 " from DIB for " <<
static_cast<void*
>(dc.
GetHDC()) <<
".");
167 Handle = ::LoadBitmap(instance, resId);
168 WARNX(OwlGDI, !
Handle, 0,
"Cannot load bitmap " << resId <<
169 " from " <<
static_cast<void*
>(instance));
172 TRACEX(OwlGDI,
OWL_CDLEVEL,
"TBitmap constructed from resource @" << (
void*)
this <<
".");
183 TRACEX(OwlGDI,
OWL_CDLEVEL,
"TBitmap duplicated @" << (
void*)
this <<
" from @" << (
void*)&src <<
".");
203 Handle = ::CreateCompatibleBitmap(dc, size.cx, size.cy);
206 Handle = ::CreateBitmap(size.cx, size.cy, 1, 1,
nullptr);
216 memDC.
PatBlt(0, 0, size.cx, size.cy);
222 " from metafile @" << (
void*)&metaFile <<
".");
244 const_cast<LPBITMAPINFO
>(dib.
GetInfo()),
250 TRACEX(OwlGDI,
OWL_CDLEVEL,
"TBitmap constructed @" << (
void*)
this <<
" from DIB @" <<
251 (
void*)&dib <<
" and palette @" << (
void*)palette <<
".");
270 if (!r)
throw TXOwl(
_T(
"TBitmap::GetObject failed"));
304 return TSize(bm.bmWidth, bm.bmHeight);
326 return bm.bmBitsPixel;
337 if (!ok)
throw TXOwl(
_T(
"TBitmap::GetBitmapDimension failed"));
366 Handle = ::CreateDIBitmap(
371 const_cast<LPBITMAPINFO
>(dib.
GetInfo()),
392 if (bm.bmPlanes != 1 || bm.bmBitsPixel != 1) {
395 Handle = ::CreateCompatibleBitmap(dc, bm.bmWidth, bm.bmHeight);
399 Handle = ::CreateBitmap(bm.bmWidth, bm.bmHeight, 1, 1,
nullptr);
407 memDC1,
TPoint(0, 0), SRCCOPY);
#define WARNX(group, condition, level, message)
#define PRECONDITION(condition)
#define TRACEX(group, level, message)
void ToClipboard(TClipboard &clipboard)
Put a device-dependent bitmap on the clipboard as a (DD)BITMAP.
bool GetBitmapDimension(TSize &size) const
Retrieves the size of this bitmap (width and height, measured in tenths of millimeters) and sets it i...
void Create(const TDib &dib, const TPalette &palette)
Create a bitmap & get its handle, given a dib and a palette Used by ctors here and in derived classes...
int Planes() const
Returns the number of planes in this bitmap.
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.
bool GetObject(BITMAP &bitmap) const
Retrieves data (width, height, and color format) for this bitmap and sets it in the given BITMAP stru...
TSize GetBitmapDimension() const
Functional-style overload.
TBitmap(HBITMAP handle, TAutoDelete autoDelete=NoAutoDelete)
Construct an alias TBitmap for an existing bitmap handle.
int Height() const
Returns the height of this bitmap using GDI's GetObject.
int BitsPixel() const
Returns the number of bits per pixel in this bitmap.
The clipboard class encapsulates the methods for the clipboard object of Windows.
HANDLE SetClipboardData(uint format, HANDLE handle)
Copy the data onto the clipboard in the format.
TDC is the root class for GDI DC wrappers.
void SelectObject(const TBrush &brush)
Selects the given GDI brush object into this DC.
virtual void SelectStockObject(int index)
Selects into the DC a predefined stock pen, brush, font, or palette.
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).
int RealizePalette()
Maps to the system palette the logical palette entries selected into this DC.
bool PatBlt(int x, int y, int w, int h, uint32 rop=PATCOPY)
HDC GetHDC() const
Return the handle of the device context.
Pseudo-GDI object Device Independent Bitmap (DIB) class.
uint16 Usage() const
Returns the Mode for this DIB.
const BITMAPINFOHEADER * GetInfoHeader() const
Returns this DIB's bmiHeader field of the BITMAPINFO structure contains information about the color a...
const BITMAPINFO * GetInfo() const
Returns this DIB's Info field.
const void * GetBits() const
Returns the Bits data member for this DIB.
HANDLE GetHandle() const
Returns the handle of the DIB with type HANDLE.
static void RefInc(HANDLE handle)
Increments by 1 the reference count of the object associated with the given handle.
void CheckValid(uint resId=IDS_GDIFAILURE)
static void RefRemove(HANDLE handle)
Removes the reference entry to the object with the given handle.
bool ShouldDelete
Should object delete GDI handle in dtor?
static void RefAdd(HANDLE handle, TType type)
RefAdd adds a reference entry for the object with the given handle and type.
TGdiObject()
This default constructor sets Handle to 0 and ShouldDelete to true.
HANDLE Handle
GDI handle of this object.
A device context (DC) class derived from TCreatedDC, TMemoryDC provides access to a memory DC.
TPalette is the GDI Palette class derived from TGdiObject.
TPalette(HPALETTE handle, TAutoDelete autoDelete=NoAutoDelete)
Alias an existing palette handle. Assume ownership if autoDelete says so.
bool GetObject(uint16 &numEntries) const
Finds the number of entries in this logical palette and sets the value in the numEntries argument.
TPoint is a support class, derived from tagPOINT.
TPoint()
Constructs an uninitialized point.
TRect()
Default constructor that does nothing.
Derived from TWindowDC, TScreenDC is a DC class that provides direct access to the screen bitmap.
The tagSIZE struct is defined as.
TSize()
Default constructor that does nothing.
Definition of classes for clipboard Encapsulation.
Definition of abstract GDI object class and derived classes.
TAutoDelete
Flag for Handle ctors to control Handle deletion in dtor.
TXOwl(const tstring &msg, uint resId=0)
An OWL exception with a given message for displaying and an unsigned Id that can be used for identifi...
Object Windows Library (OWLNext Core).
long NColors(uint16 bitCount)
Functions to convert number of bits to number of palette colors and back, and build an RGB COLORREF.
DIAG_DECLARE_GROUP(OwlThread)
Classes for window system structure and type encapsulation.