OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
owl::TDib Class Reference

Pseudo-GDI object Device Independent Bitmap (DIB) class. More...

#include <owl/gdiobjec.h>

Inheritance diagram for owl::TDib:
owl::TGdiBase owl::TDiBitmap

Classes

class  IFileIn
 Internal DIB file Reda/Write functions talk to these interfaces. More...
 
class  IFileOut
 

Public Types

enum  { MapFace = 0x01 , MapText = 0x02 , MapShadow = 0x04 , MapHighlight = 0x08 , MapFrame = 0x10 }
 Map colors in color table matching stock UI colors to current UI colors. More...
 
typedef HANDLE THandle
 TDib encapsulates an memory HANDLE w/ a DIB.
 

Public Member Functions

 TDib (HGLOBAL handle, TAutoDelete autoDelete=NoAutoDelete)
 Creates a TDib object and sets the Handle data member to the given borrowed handle.
 
 TDib (const TClipboard &clipboard)
 Constructs a TDib object with a handle borrowed from the given Clipboard.
 
 TDib (const TDib &src)
 This public copy constructor creates a complete copy of the given src object as in:
 
 TDib (int width, int height, uint32 nColors, uint16 mode=DIB_RGB_COLORS)
 Creates a DIB object with the given width, height, number of colors, mode values.
 
 TDib (HINSTANCE module, TResId resid)
 Creates a TDib given a module instance and a resource name or int Id.
 
 TDib (LPCTSTR filename)
 Creates a DIB object from the given resource file (.bmp).
 
 TDib (const tstring &filename)
 String-aware overload.
 
 TDib (TFile &file, bool readFileHeader=true)
 Creates a DIB from the file.
 
 TDib (std::istream &is, bool readFileHeader=false)
 Creates a DIB from the file stream.
 
 TDib (const TBitmap &bitmap, const TPalette *pal=nullptr)
 Creates a DIB object from the given resource bitmap and palette.
 
virtual ~TDib ()
 Destruct a TDib by unlocking & freeing its global memory handle as required.
 
bool operator== (const TDib &other) const
 Compares two handles and returns true if this DIB's handle equals the other (other) DIB's handle.
 
const BITMAPINFOGetInfo () const
 Returns this DIB's Info field.
 
BITMAPINFOGetInfo ()
 Returns this DIB's Info field.
 
const BITMAPINFOHEADERGetInfoHeader () const
 Returns this DIB's bmiHeader field of the BITMAPINFO structure contains information about the color and dimensions of this DIB.
 
BITMAPINFOHEADERGetInfoHeader ()
 Returns this DIB's bmiHeader field of the BITMAPINFO structure contains information about the color and dimensions of this DIB.
 
const TRgbQuadGetColors () const
 Returns the bmiColors value of this DIB.
 
TRgbQuadGetColors ()
 Returns the bmiColors value of this DIB.
 
const uint16GetIndices () const
 Returns the bmiColors indexes of this DIB.
 
uint16GetIndices ()
 Returns the bmiColors indexes of this DIB.
 
const voidGetBits () const
 Returns the Bits data member for this DIB.
 
voidGetBits ()
 Returns the Bits data member for this DIB.
 
HANDLE GetHandle () const
 Returns the handle of the DIB with type HANDLE.
 
 operator HANDLE () const
 Return the handle of the DIB with type HANDLE.
 
 operator const BITMAPINFO * () const
 Typecasts this DIB by returning a pointer to its bitmap information structure (BITMAPINFO) which contains information about this DIB's color format and dimensions (size, width, height, resolution, and so on).
 
 operator BITMAPINFO * ()
 Typecasts this DIB by returning a pointer to its bitmap information structure (BITMAPINFO) which contains information about this DIB's color format and dimensions (size, width, height, resolution, and so on).
 
 operator const BITMAPINFOHEADER * () const
 Typecasts this DIB by returning a pointer to its bitmap info header.
 
 operator BITMAPINFOHEADER * ()
 Typecasts this DIB by returning a pointer to its bitmap info header.
 
 operator const TRgbQuad * () const
 Typecasts this DIB by returning a pointer to its colors structure.
 
 operator TRgbQuad * ()
 Typecasts this DIB by returning a pointer to its colors structure.
 
void ToClipboard (TClipboard &clipboard)
 Moves this dib to the clipboard.
 
bool IsOK () const
 Returns false if Info is 0, otherwise returns true.
 
bool IsPM () const
 Returns true if IsCore is true; that is, if the DIB is an old-style PM DIB using core headers.
 
int Width () const
 Returns the width of the DIB.
 
int Height () const
 Returns the height of the DIB.
 
int FlippedY (int y) const
 Returns the coordinate of y if the direction of the y-axis was reversed.
 
TSize Size () const
 Returns TSize(W,H), the size of this DIB.
 
int BitsPixel () const
 Return the number of bits (2, 4, 8, 16, 24, or 32) used to store a pixel for the DIB.
 
int Pitch () const
 Size of scan in bytes = Pixel Width * bits per pixel rounded up to a uint32 boundary.
 
uint32 Compression () const
 Returns type of compression and encoding for bottom-up DIBs.
 
uint32 SizeImage () const
 Returns number of bytes used to store the image.
 
long NumColors () const
 Returns NumClrs, the number of colors in this DIB's palette.
 
uint StartScan () const
 Returns the starting scan line.
 
uint NumScans () const
 Returns the number of scans in this DIB.
 
int32 SizeColors () const
 Return number of colors times the size of each entry in the table, whether it is an RGB color table or palette index table.
 
uint32 SizeDib () const
 Size of dib is measured as the end of the bits minus the start of the block.
 
uint16 Usage () const
 Returns the Mode for this DIB.
 
int XOffset (uint16 x) const
 Returns the byte offset from the start of the scan line to the xth pixel.
 
int YOffset (uint16 y) const
 Returns the starting position of the scan line.
 
voidPixelPtr (uint16 x, uint16 y)
 Returns the byte of where the pixel is located.
 
bool WriteFile (const tstring &filename)
 Writes the DIB into an external file.
 
bool Write (TFile &file, bool writeFileHeader=false)
 Write this DIB to a file object.
 
bool Write (std::ostream &os, bool writeFileHeader=false)
 Writes this DIB to an ostream.
 
TColor GetColor (int entry) const
 Returns the color for the given palette entry.
 
void SetColor (int entry, const TColor &color)
 Sets the given color for the given palette entry.
 
int FindColor (const TColor &color)
 Returns the palette entry for the given color.
 
int MapColor (const TColor &fromColor, const TColor &toColor, bool doAll=false)
 Maps the first or all occurances of fromColor to the toColor in the current palette of this DIB.
 
uint16 GetIndex (int entry) const
 
void SetIndex (int entry, uint16 index)
 Sets the given index for the given entry.
 
int FindIndex (uint16 index)
 Returns the palette entry corresponding to the given index.
 
int MapIndex (uint16 fromIndex, uint16 toIndex, bool doAll=false)
 Maps the fromIndex to the toIndex in the current palette of this DIB.
 
bool ChangeModeToPal (const TPalette &pal)
 Converts the existing color table in place to use palette relative values.
 
bool ChangeModeToRGB (const TPalette &pal)
 Converts the existing color table in place to use absolute RGB values.
 
void MapUIColors (uint mapColors, const TColor *bkColor=nullptr)
 Maps the UI colors to the value specified in the parameter, mapColors, which is one of the values of the Map enum.
 
void MapToPalette (const TPalette &pal)
 Modifies this DIB so that the pixels and color table coincide with a given palette.
 

Protected Member Functions

 TDib ()
 Protected ctor- derived classes need to fill in handle & get info.
 
void InfoFromHeader (const BITMAPINFOHEADER &infoHeader)
 Given a BITMAPINFOHEADER, allocate a global buffer for Handle & init Info.
 
void InfoFromHandle ()
 Locks the global/res handle if needed and extracts the pointers and cached info maintained as member variables from Info.
 
void CopyOnWrite ()
 Copies the DIB.
 
void ResToMemHandle ()
 Under Win32, resources are read-only.
 
bool ReadFile (const tstring &name)
 Tests if the passed file is a Windows 3.x (or PM 1.x) DIB and if so read it.
 
bool Read (TFile &file, bool readFileHeader=false)
 Read a Windows 3.x or PM 1.x device independent bitmap from a TFile Return true iff Dib was read OK.
 
bool Read (std::istream &is, bool readFileHeader=false)
 Read a Windows 3.0 or PM 1.X device independent bitmap from an istream.
 
bool LoadResource (HINSTANCE, TResId)
 Loads this DIB from the given resource and returns true if successful.
 
virtual bool Read (IFileIn &in, bool readFileHeader=false)
 Reads a Windows 3.0 or PM 1.X device independent bitmap.
 
virtual bool Write (IFileOut &out, bool writeFileHeader=false)
 Writes the DIB into a file stream.
 
void CheckValid (uint resId=IDS_GDIFAILURE)
 

Static Protected Member Functions

static int ScanBytes (long w, int bpp)
 Width+bpp to dword aligned bytes.
 

Protected Attributes

HANDLE Handle
 GDI handle of this object.
 
bool ShouldDelete
 Should object delete GDI handle in dtor?
 

Detailed Description

Pseudo-GDI object Device Independent Bitmap (DIB) class.

DIBs really have no Window's handle, they are just a structure containing format and palette information and a collection of bits (pixels). This class provides a very convenient way to work with DIBs like any other GDI object. The memory for the DIB is in one GlobalAlloc'd chunk so it can be passed to the Clipboard, OLE, etc. Overloads the destructor since it is not a real GDI object.

This is what is really inside a .BMP file, what is in bitmap resources, and what is put on the clipboard as a DIB.

Definition at line 795 of file gdiobjec.h.

Member Typedef Documentation

◆ THandle

TDib encapsulates an memory HANDLE w/ a DIB.

Definition at line 799 of file gdiobjec.h.

Member Enumeration Documentation

◆ anonymous enum

Map colors in color table matching stock UI colors to current UI colors.

Enumerates the values for the part of the window whose color is to be set. You can OR these together to control the colors used for face shading on push buttons, the color of a selected control button, the edge shading on push buttons, text on push buttons, the color of the window frame, and the background color of the various parts of a window. The function MapUIColors uses one of these values to map the colors of various parts of a window to a specified color.

Enumerator
MapFace 
MapText 
MapShadow 
MapHighlight 
MapFrame 

Definition at line 909 of file gdiobjec.h.

Constructor & Destructor Documentation

◆ TDib() [1/11]

owl::TDib::TDib ( HGLOBAL handle,
TAutoDelete autoDelete = NoAutoDelete )
explicit

Creates a TDib object and sets the Handle data member to the given borrowed handle.

The ShouldDelete data member defaults to false, ensuring that the borrowed handle will not be deleted when the C++ object is destroyed.

Definition at line 170 of file dib.cpp.

References InfoFromHandle().

◆ TDib() [2/11]

owl::TDib::TDib ( const TClipboard & clipboard)
explicit

Constructs a TDib object with a handle borrowed from the given Clipboard.

Definition at line 182 of file dib.cpp.

References InfoFromHandle().

◆ TDib() [3/11]

owl::TDib::TDib ( const TDib & src)

This public copy constructor creates a complete copy of the given src object as in:

Pseudo-GDI object Device Independent Bitmap (DIB) class.
Definition gdiobjec.h:795

Definition at line 198 of file dib.cpp.

References Handle, PRECONDITION, and owl::TXOutOfMemory::Raise().

◆ TDib() [4/11]

owl::TDib::TDib ( int width,
int height,
uint32 nColors,
uint16 mode = DIB_RGB_COLORS )

Creates a DIB object with the given width, height, number of colors, mode values.

Definition at line 955 of file dib.cpp.

References owl::TDC::GetDeviceCaps(), InfoFromHeader(), owl::NBits(), PRECONDITION, ScanBytes(), and Swap().

◆ TDib() [5/11]

owl::TDib::TDib ( HINSTANCE module,
TResId resid )

Creates a TDib given a module instance and a resource name or int Id.

Definition at line 796 of file dib.cpp.

References LoadResource(), and owl::TXGdi::Raise().

◆ TDib() [6/11]

owl::TDib::TDib ( LPCTSTR filename)
explicit

Creates a DIB object from the given resource file (.bmp).

Definition at line 494 of file dib.cpp.

References owl::TXGdi::Raise(), and ReadFile().

◆ TDib() [7/11]

owl::TDib::TDib ( const tstring & filename)
explicit

String-aware overload.

Definition at line 503 of file dib.cpp.

References owl::TXGdi::Raise(), and ReadFile().

◆ TDib() [8/11]

owl::TDib::TDib ( TFile & file,
bool readFileHeader = true )
explicit

Creates a DIB from the file.

Definition at line 513 of file dib.cpp.

References owl::TXGdi::Raise(), and Read().

◆ TDib() [9/11]

owl::TDib::TDib ( std::istream & is,
bool readFileHeader = false )
explicit

Creates a DIB from the file stream.

Definition at line 522 of file dib.cpp.

References owl::TXGdi::Raise(), and Read().

◆ TDib() [10/11]

owl::TDib::TDib ( const TBitmap & bitmap,
const TPalette * palette = nullptr )
explicit

Creates a DIB object from the given resource bitmap and palette.

If pal is 0 (the default), the default palette is used.

Definition at line 1006 of file dib.cpp.

References owl::TDC::GetDIBits(), InfoFromHeader(), owl::NBits(), owl::NColors(), NumScans(), ScanBytes(), owl::TDC::SelectObject(), StartScan(), and Usage().

◆ ~TDib()

owl::TDib::~TDib ( )
virtual

Destruct a TDib by unlocking & freeing its global memory handle as required.

Definition at line 233 of file dib.cpp.

References Handle, and ShouldDelete.

◆ TDib() [11/11]

owl::TDib::TDib ( )
protected

Protected ctor- derived classes need to fill in handle & get info.

Constructs an empty DIB for use by derived classes.

Definition at line 532 of file dib.cpp.

Member Function Documentation

◆ BitsPixel()

int owl::TDib::BitsPixel ( ) const
inline

Return the number of bits (2, 4, 8, 16, 24, or 32) used to store a pixel for the DIB.

Definition at line 1873 of file gdiobjec.h.

◆ ChangeModeToPal()

bool owl::TDib::ChangeModeToPal ( const TPalette & pal)

Converts the existing color table in place to use palette relative values.

The palette that is passed is used as a reference. Returns true if the call is successful; otherwise returns false.

Makes sure that color table is RGB

Definition at line 250 of file dib.cpp.

◆ ChangeModeToRGB()

bool owl::TDib::ChangeModeToRGB ( const TPalette & pal)

Converts the existing color table in place to use absolute RGB values.

The palette that is passed is used as a reference. Returns true if the call is successful; otherwise returns false.

Makes sure that color table is pal relative & that there is enough space

Definition at line 284 of file dib.cpp.

◆ CheckValid()

void owl::TGdiBase::CheckValid ( uint resId = IDS_GDIFAILURE)
protected

Definition at line 86 of file gdibase.cpp.

◆ Compression()

uint32 owl::TDib::Compression ( ) const
inline

Returns type of compression and encoding for bottom-up DIBs.

Definition at line 1890 of file gdiobjec.h.

◆ CopyOnWrite()

void owl::TDib::CopyOnWrite ( )
inlineprotected

Copies the DIB.

Definition at line 1986 of file gdiobjec.h.

References ResToMemHandle().

◆ FindColor()

int owl::TDib::FindColor ( const TColor & color)

Returns the palette entry for the given color.

Definition at line 340 of file dib.cpp.

References GetColors().

◆ FindIndex()

int owl::TDib::FindIndex ( uint16 index)

Returns the palette entry corresponding to the given index.

Definition at line 399 of file dib.cpp.

References GetIndices().

◆ FlippedY()

int owl::TDib::FlippedY ( int y) const
inline

Returns the coordinate of y if the direction of the y-axis was reversed.

Definition at line 1848 of file gdiobjec.h.

◆ GetBits() [1/2]

void * owl::TDib::GetBits ( )
inline

Returns the Bits data member for this DIB.

Definition at line 1735 of file gdiobjec.h.

◆ GetBits() [2/2]

const void * owl::TDib::GetBits ( ) const
inline

Returns the Bits data member for this DIB.

Definition at line 1727 of file gdiobjec.h.

◆ GetColor()

TColor owl::TDib::GetColor ( int entry) const

Returns the color for the given palette entry.

Definition at line 314 of file dib.cpp.

References GetColors().

◆ GetColors() [1/2]

TRgbQuad * owl::TDib::GetColors ( )
inline

Returns the bmiColors value of this DIB.

Definition at line 1703 of file gdiobjec.h.

◆ GetColors() [2/2]

const TRgbQuad * owl::TDib::GetColors ( ) const
inline

Returns the bmiColors value of this DIB.

Definition at line 1695 of file gdiobjec.h.

◆ GetHandle()

HANDLE owl::TDib::GetHandle ( ) const
inline

Returns the handle of the DIB with type HANDLE.

Definition at line 1743 of file gdiobjec.h.

References Handle.

◆ GetIndex()

uint16 owl::TDib::GetIndex ( int entry) const

Definition at line 373 of file dib.cpp.

References GetColors().

◆ GetIndices() [1/2]

uint16 * owl::TDib::GetIndices ( )
inline

Returns the bmiColors indexes of this DIB.

Definition at line 1719 of file gdiobjec.h.

◆ GetIndices() [2/2]

const uint16 * owl::TDib::GetIndices ( ) const
inline

Returns the bmiColors indexes of this DIB.

Definition at line 1711 of file gdiobjec.h.

◆ GetInfo() [1/2]

BITMAPINFO * owl::TDib::GetInfo ( )
inline

Returns this DIB's Info field.

A DIB's BITMAPINFO structure contains information about the dimensions and color of the DIB and specifies an array of data types that define the colors in the bitmap.

Definition at line 1669 of file gdiobjec.h.

◆ GetInfo() [2/2]

const BITMAPINFO * owl::TDib::GetInfo ( ) const
inline

Returns this DIB's Info field.

A DIB's BITMAPINFO structure contains information about the dimensions and color of the DIB and specifies an array of data types that define the colors in the bitmap.

Definition at line 1659 of file gdiobjec.h.

◆ GetInfoHeader() [1/2]

BITMAPINFOHEADER * owl::TDib::GetInfoHeader ( )
inline

Returns this DIB's bmiHeader field of the BITMAPINFO structure contains information about the color and dimensions of this DIB.

Definition at line 1687 of file gdiobjec.h.

◆ GetInfoHeader() [2/2]

const BITMAPINFOHEADER * owl::TDib::GetInfoHeader ( ) const
inline

Returns this DIB's bmiHeader field of the BITMAPINFO structure contains information about the color and dimensions of this DIB.

Definition at line 1678 of file gdiobjec.h.

◆ Height()

int owl::TDib::Height ( ) const
inline

Returns the height of the DIB.

Definition at line 1840 of file gdiobjec.h.

◆ InfoFromHandle()

void owl::TDib::InfoFromHandle ( )
protected

Locks the global/res handle if needed and extracts the pointers and cached info maintained as member variables from Info.

Needs only Info setup, or if Info is 0 then Handle & IsResHandle setup

Definition at line 88 of file dib.cpp.

References Handle, owl::NColors(), and owl::TXGdi::Raise().

◆ InfoFromHeader()

void owl::TDib::InfoFromHeader ( const BITMAPINFOHEADER & infoHeader)
protected

Given a BITMAPINFOHEADER, allocate a global buffer for Handle & init Info.

Definition at line 60 of file dib.cpp.

References Handle, InfoFromHandle(), and owl::TXOutOfMemory::Raise().

◆ IsOK()

bool owl::TDib::IsOK ( ) const
inline

Returns false if Info is 0, otherwise returns true.

If there is a problem with the construction of the DIB, memory is freed and Info is set to 0. Therefore, using Info is a reliable way to determine if the DIB is constructed correctly.

Definition at line 1813 of file gdiobjec.h.

◆ IsPM()

bool owl::TDib::IsPM ( ) const
inline

Returns true if IsCore is true; that is, if the DIB is an old-style PM DIB using core headers.

Otherwise returns false.

Note
Returns false always since PM bitmaps are not supported.

Definition at line 1824 of file gdiobjec.h.

◆ LoadResource()

bool owl::TDib::LoadResource ( HINSTANCE instance,
TResId resId )
protected

Loads this DIB from the given resource and returns true if successful.

Definition at line 811 of file dib.cpp.

References Handle, InfoFromHandle(), LoadResource(), PRECONDITION, ResToMemHandle(), and TRACEX.

◆ MapColor()

int owl::TDib::MapColor ( const TColor & fromColor,
const TColor & toColor,
bool mapAll = false )

Maps the first or all occurances of fromColor to the toColor in the current palette of this DIB.

Returns the palette entry for the given color. Returns the palette entry for the toColor argument.

Definition at line 355 of file dib.cpp.

References GetColors().

◆ MapIndex()

int owl::TDib::MapIndex ( uint16 fromIndex,
uint16 toIndex,
bool doAll = false )

Maps the fromIndex to the toIndex in the current palette of this DIB.

Returns the palette entry for the toIndex argument.

Definition at line 413 of file dib.cpp.

References GetIndices().

◆ MapToPalette()

void owl::TDib::MapToPalette ( const TPalette & pal)

Modifies this DIB so that the pixels and color table coincide with a given palette.

!CQ 8bpp only!

Definition at line 1053 of file dib.cpp.

References GetBits(), GetColor(), GetColors(), Height(), and Pitch().

◆ MapUIColors()

void owl::TDib::MapUIColors ( uint mapColors,
const TColor * bkColor = nullptr )

Maps the UI colors to the value specified in the parameter, mapColors, which is one of the values of the Map enum.

Use this function to get the colors for the face shading on push buttons, the highlighting for a selected control button, the text on push buttons, the shade of the window frame and the background color. Use MapColor to map selected standard UI colors in this DIB to their current system values. Also can map a background color. Used to update a UI DIB to current colors before rendering.

  • LtGray -> 3d Face
  • Black -> Button Text
  • Gray -> 3d Shadow
  • White -> 3d Hilight
  • Magenta -> Window Frame
  • LtYellow -> bkColor

Definition at line 446 of file dib.cpp.

References owl::TColor::Black, owl::TColor::Gray, owl::TColor::LtGray, owl::TColor::LtMagenta, owl::TColor::LtYellow, MapColor(), MapFace, MapFrame, MapHighlight, MapShadow, MapText, owl::TColor::Sys3dFace, owl::TColor::Sys3dHilight, owl::TColor::Sys3dShadow, owl::TColor::SysBtnText, owl::TColor::SysWindow, owl::TColor::SysWindowFrame, and owl::TColor::White.

◆ NumColors()

long owl::TDib::NumColors ( ) const
inline

Returns NumClrs, the number of colors in this DIB's palette.

Definition at line 1906 of file gdiobjec.h.

◆ NumScans()

uint owl::TDib::NumScans ( ) const
inline

Returns the number of scans in this DIB.

Always same as height of the DIB.

Definition at line 1926 of file gdiobjec.h.

References Height().

◆ operator BITMAPINFO *()

owl::TDib::operator BITMAPINFO * ( )
inline

Typecasts this DIB by returning a pointer to its bitmap information structure (BITMAPINFO) which contains information about this DIB's color format and dimensions (size, width, height, resolution, and so on).

Definition at line 1771 of file gdiobjec.h.

◆ operator BITMAPINFOHEADER *()

owl::TDib::operator BITMAPINFOHEADER * ( )
inline

Typecasts this DIB by returning a pointer to its bitmap info header.

Definition at line 1787 of file gdiobjec.h.

◆ operator const BITMAPINFO *()

owl::TDib::operator const BITMAPINFO * ( ) const
inline

Typecasts this DIB by returning a pointer to its bitmap information structure (BITMAPINFO) which contains information about this DIB's color format and dimensions (size, width, height, resolution, and so on).

Definition at line 1761 of file gdiobjec.h.

◆ operator const BITMAPINFOHEADER *()

owl::TDib::operator const BITMAPINFOHEADER * ( ) const
inline

Typecasts this DIB by returning a pointer to its bitmap info header.

Definition at line 1779 of file gdiobjec.h.

◆ operator const TRgbQuad *()

owl::TDib::operator const TRgbQuad * ( ) const
inline

Typecasts this DIB by returning a pointer to its colors structure.

Definition at line 1795 of file gdiobjec.h.

◆ operator HANDLE()

owl::TDib::operator HANDLE ( ) const
inline

Return the handle of the DIB with type HANDLE.

Definition at line 1751 of file gdiobjec.h.

◆ operator TRgbQuad *()

owl::TDib::operator TRgbQuad * ( )
inline

Typecasts this DIB by returning a pointer to its colors structure.

Definition at line 1803 of file gdiobjec.h.

◆ operator==()

bool owl::TDib::operator== ( const TDib & other) const
inline

Compares two handles and returns true if this DIB's handle equals the other (other) DIB's handle.

Definition at line 1649 of file gdiobjec.h.

References Handle.

◆ Pitch()

int owl::TDib::Pitch ( ) const
inline

Size of scan in bytes = Pixel Width * bits per pixel rounded up to a uint32 boundary.

Definition at line 1882 of file gdiobjec.h.

References BitsPixel(), ScanBytes(), and Width().

◆ PixelPtr()

void * owl::TDib::PixelPtr ( uint16 x,
uint16 y )
inline

Returns the byte of where the pixel is located.

Definition at line 1978 of file gdiobjec.h.

References XOffset(), and YOffset().

◆ Read() [1/3]

bool owl::TDib::Read ( IFileIn & in,
bool readFileHeader = false )
protectedvirtual

Reads a Windows 3.0 or PM 1.X device independent bitmap.

(.BMP) from an implementor of TDib's IFileIn interface

Checks header, read Info, palette and bitmap. PM Dibs are converted to Windows 3.x Dibs on the fly.

Returns true iff Dib was read OK

Definition at line 636 of file dib.cpp.

References BFT_BITMAP, Handle, InfoFromHeader(), owl::NColors(), owl::TXBadFormat::Raise(), ScanBytes(), and TRACEX.

◆ Read() [2/3]

bool owl::TDib::Read ( std::istream & is,
bool readFileHeader = false )
protected

Read a Windows 3.0 or PM 1.X device independent bitmap from an istream.

Checks header, read Info, palette and bitmap. PM DIBs can be converted to Win 3.x DIBs on the fly.

Returns true iff DIB was read OK

Definition at line 619 of file dib.cpp.

References Read().

◆ Read() [3/3]

bool owl::TDib::Read ( TFile & file,
bool readFileHeader = false )
protected

Read a Windows 3.x or PM 1.x device independent bitmap from a TFile Return true iff Dib was read OK.

Definition at line 571 of file dib.cpp.

References Read().

◆ ReadFile()

bool owl::TDib::ReadFile ( const tstring & name)
protected

Tests if the passed file is a Windows 3.x (or PM 1.x) DIB and if so read it.

Returns true if Dib was read OK.

Definition at line 549 of file dib.cpp.

References owl::TFile::OpenExisting, Read(), owl::TFile::ReadOnly, and TRACEX.

◆ ResToMemHandle()

void owl::TDib::ResToMemHandle ( )
protected

Under Win32, resources are read-only.

So, to allow for modification of the Dib, a copy must be made.

Definition at line 143 of file dib.cpp.

References Handle, InfoFromHandle(), and owl::TXOutOfMemory::Raise().

◆ ScanBytes()

int owl::TDib::ScanBytes ( long w,
int bpp )
inlinestaticprotected

Width+bpp to dword aligned bytes.

Returns the number of bytes used to store a scanline for the DIB.

Rounded up to the nearest 32-bit boundary.

Definition at line 1865 of file gdiobjec.h.

◆ SetColor()

void owl::TDib::SetColor ( int entry,
const TColor & color )

Sets the given color for the given palette entry.

Definition at line 328 of file dib.cpp.

References GetColors().

◆ SetIndex()

void owl::TDib::SetIndex ( int entry,
uint16 index )

Sets the given index for the given entry.

Definition at line 387 of file dib.cpp.

References GetColors().

◆ Size()

TSize owl::TDib::Size ( ) const
inline

Returns TSize(W,H), the size of this DIB.

Definition at line 1856 of file gdiobjec.h.

References Height(), and Width().

◆ SizeColors()

int32 owl::TDib::SizeColors ( ) const
inline

Return number of colors times the size of each entry in the table, whether it is an RGB color table or palette index table.

Definition at line 1935 of file gdiobjec.h.

References NumColors().

◆ SizeDib()

uint32 owl::TDib::SizeDib ( ) const
inline

Size of dib is measured as the end of the bits minus the start of the block.

Definition at line 1945 of file gdiobjec.h.

References SizeImage().

◆ SizeImage()

uint32 owl::TDib::SizeImage ( ) const
inline

Returns number of bytes used to store the image.

Definition at line 1898 of file gdiobjec.h.

◆ StartScan()

uint owl::TDib::StartScan ( ) const
inline

Returns the starting scan line.

Always 0 because all DIBs are normalized.

Definition at line 1916 of file gdiobjec.h.

◆ ToClipboard()

void owl::TDib::ToClipboard ( TClipboard & clipboard)

Moves this dib to the clipboard.

Ownership of the DIB handle is passed to the clipboard.

Definition at line 474 of file dib.cpp.

References Handle, owl::TClipboard::SetClipboardData(), and ShouldDelete.

◆ Usage()

uint16 owl::TDib::Usage ( ) const
inline

Returns the Mode for this DIB.

This value tells GDI how to treat the color table - whether the DIB has palette color entries or RGB color entries.

Definition at line 1954 of file gdiobjec.h.

◆ Width()

int owl::TDib::Width ( ) const
inline

Returns the width of the DIB.

Definition at line 1832 of file gdiobjec.h.

◆ Write() [1/3]

bool owl::TDib::Write ( IFileOut & out,
bool writeFileHeader = false )
protectedvirtual

Writes the DIB into a file stream.

Definition at line 912 of file dib.cpp.

References BFT_BITMAP, and Handle.

◆ Write() [2/3]

bool owl::TDib::Write ( std::ostream & os,
bool writeFileHeader = false )

Writes this DIB to an ostream.

Definition at line 901 of file dib.cpp.

References Write().

◆ Write() [3/3]

bool owl::TDib::Write ( TFile & file,
bool writeFileHeader = false )

Write this DIB to a file object.

Definition at line 870 of file dib.cpp.

References Write().

◆ WriteFile()

bool owl::TDib::WriteFile ( const tstring & name)

Writes the DIB into an external file.

Returns true if the call is successful; otherwise returns false.

Definition at line 846 of file dib.cpp.

References owl::TFile::CreateAlways, owl::TFile::PermExclusive, TRACEX, Write(), and owl::TFile::WriteOnly.

◆ XOffset()

int owl::TDib::XOffset ( uint16 x) const
inline

Returns the byte offset from the start of the scan line to the xth pixel.

Definition at line 1962 of file gdiobjec.h.

References BitsPixel().

◆ YOffset()

int owl::TDib::YOffset ( uint16 y) const
inline

Returns the starting position of the scan line.

Definition at line 1970 of file gdiobjec.h.

References Pitch().

Member Data Documentation

◆ Handle

HANDLE owl::TGdiBase::Handle
protected

GDI handle of this object.

Definition at line 81 of file gdibase.h.

◆ ShouldDelete

bool owl::TGdiBase::ShouldDelete
protected

Should object delete GDI handle in dtor?

Definition at line 82 of file gdibase.h.


The documentation for this class was generated from the following files: