vtdata library
Public Member Functions | Public Attributes | List of all members
vtDIB Class Reference
Inheritance diagram for vtDIB:
Inheritance graph
[legend]

Public Member Functions

 vtDIB ()
 
bool Create (const IPoint2 &size, int bitdepth)
 
bool IsAllocated () const
 
bool Read (const char *fname, bool progress_callback(int)=NULL)
 
bool ReadJPEG (const char *fname, bool progress_callback(int)=NULL)
 
bool ReadPNG (const char *fname, bool progress_callback(int)=NULL)
 
bool WriteJPEG (const char *fname, int quality, bool progress_callback(int)=NULL)
 
bool WritePNG (const char *fname)
 
bool WriteTIF (const char *fname, const DRECT *area=NULL, const vtCRS *proj=NULL, bool progress_callback(int)=NULL)
 
uint GetPixel24 (int x, int y) const
 
void GetPixel24 (int x, int y, RGBi &rgb) const
 
void SetPixel24 (int x, int y, uint color)
 
void SetPixel24 (int x, int y, const RGBi &rgb)
 
void GetPixel32 (int x, int y, RGBAi &rgba) const
 
void SetPixel32 (int x, int y, const RGBAi &rgba)
 
uchar GetPixel8 (int x, int y) const
 
void SetPixel8 (int x, int y, uchar color)
 
void SetColor (const RGBi &rgb)
 
void Invert ()
 
void Blit (vtDIB &target, int x, int y)
 
IPoint2 GetSize () const
 
uint GetWidth () const
 
uint GetHeight () const
 
uint GetDepth () const
 
void * GetData () const
 
- Public Member Functions inherited from vtBitmapBase
void ScalePixel8 (int x, int y, float fScale)
 
void ScalePixel24 (int x, int y, float fScale)
 
void ScalePixel32 (int x, int y, float fScale)
 
void BlitTo (vtBitmapBase &target, int x, int y)
 

Public Attributes

bool m_bLoadedSuccessfully
 

Detailed Description

A DIB is a Device-Independent Bitmap. It is a way of representing a bitmap in memory which has its origins in early MS Windows usage, but is entirely applicable to normal bitmap operations.

Constructor & Destructor Documentation

vtDIB::vtDIB ( )

Create a new empty DIB wrapper.

Member Function Documentation

void vtDIB::Blit ( vtDIB target,
int  x,
int  y 
)

Copy from this bitmap to another. Currently, this is implemented with a slow, completely unoptimized approach of one pixel at a time.

bool vtDIB::Create ( const IPoint2 size,
int  bitdepth 
)

Create a new DIB in memory.

uint vtDIB::GetPixel24 ( int  x,
int  y 
) const

Get a 24-bit RGB value from a 24-bit bitmap.

Returns
R,G,B as the three lowest bytes in an uint.
void vtDIB::GetPixel24 ( int  x,
int  y,
RGBi rgb 
) const
virtual

Get a 24-bit RGB value from a 24-bit bitmap, place it in the rgb parameter.

Implements vtBitmapBase.

uchar vtDIB::GetPixel8 ( int  x,
int  y 
) const
virtual

Get a single byte from an 8-bit bitmap.

Implements vtBitmapBase.

void vtDIB::Invert ( )

Invert the bitmap colors.

bool vtDIB::Read ( const char *  fname,
bool   progress_callbackint = NULL 
)

Read a image file into the DIB. This method will check to see if the file is a BMP or JPEG and call the appropriate reader.

bool vtDIB::ReadJPEG ( const char *  fname,
bool   progress_callbackint = NULL 
)

Read a JPEG file. A DIB of the necessary size and depth is allocated.

bool vtDIB::ReadPNG ( const char *  fname,
bool   progress_callbackint = NULL 
)

Read a PNG file. A DIB of the necessary size and depth is allocated.

Returns
True if successful.
void vtDIB::SetColor ( const RGBi rgb)

Sets the entire bitmap to a single color.

void vtDIB::SetPixel24 ( int  x,
int  y,
uint  color 
)

Set a 24-bit RGB value in a 24-bit bitmap.

void vtDIB::SetPixel8 ( int  x,
int  y,
uchar  value 
)
virtual

Set a single byte in an 8-bit bitmap.

Implements vtBitmapBase.

bool vtDIB::WriteJPEG ( const char *  fname,
int  quality,
bool   progress_callbackint = NULL 
)

Write a JPEG file.

Parameters
fnameThe output filename.
qualityJPEG quality in the range of 0..100.
progress_callbackIf supplied, this will be called back with progress indication in the range of 1 to 100.
Returns
True if successful.
bool vtDIB::WritePNG ( const char *  fname)

Write a PNG file.

Returns
True if successful.
bool vtDIB::WriteTIF ( const char *  fname,
const DRECT area = NULL,
const vtCRS proj = NULL,
bool   progress_callbackint = NULL 
)

Write a TIFF file. If extents and projection are support, a GeoTIFF file will be written.

Parameters
fnameThe output filename.
areaThe extents if the image. Can be NULL if the image is not georeferenced.
projThe CRS if the image. Can be NULL if the image is not georeferenced.
progress_callbackIf supplied, this will be called back with progress indication in the range of 1 to 100.
Returns
True if successful.