Kicking it Olde Sküül! Burgerlib on Github Follow Olde Sküül on Twitter Burgerbecky on LinkedIn Burgerbecky on LinkedIn
Loading...
Searching...
No Matches
Burger::Image Class Reference

Class for containing raw images. More...

Public Types

enum  eFlags { FLAGS_IMAGENOTALLOCATED =0x0020 , FLAGS_MIPMAPMASK =0x001F }
 
enum  ePixelTypes {
  PIXELTYPE1BIT =1 , PIXELTYPE2BIT =2 , PIXELTYPE4BIT =4 , PIXELTYPE332 =7 ,
  PIXELTYPE8BIT =8 , PIXELTYPE4444 =13 , PIXELTYPE1555 =14 , PIXELTYPE555 =15 ,
  PIXELTYPE565 =16 , PIXELTYPEDXT1 =17 , PIXELTYPEDXT2 =18 , PIXELTYPEDXT3 =19 ,
  PIXELTYPEDXT4 =20 , PIXELTYPEDXT5 =21 , PIXELTYPE888 =24 , PIXELTYPE1010102 =31 ,
  PIXELTYPE8888 =32
}
 Pixel data type. More...
 

Public Member Functions

 Image ()
 Default constructor.
 
 ~Image ()
 Default destructor.
 
void Init (uint_t uWidth, uint_t uHeight, ePixelTypes eType, uintptr_t uStride, const uint8_t *pImage, uint_t uFlags=0, uint_t uMipMaps=0)
 Manually initialize an Image.
 
uint_t Init (uint_t uWidth, uint_t uHeight, ePixelTypes eType)
 Allocates memory suitable for an image.
 
uint_t Init (uint_t uWidth, uint_t uHeight, ePixelTypes eType, uint_t uMipMaps)
 Allocates memory suitable for an image and its mipmaps.
 
uint_t Init (const Image *pInput)
 Make a copy of an image.
 
uint_t InitPNG (InputMemoryStream *pInput, RGBAWord8_t *pPalette=0)
 Initialize an Image from a PNG file stream.
 
uint_t InitPNG (const char *pFilename, RGBAWord8_t *pPalette=0)
 Initialize an Image from a PNG file.
 
uint_t InitPNG (Filename *pFilename, RGBAWord8_t *pPalette=0)
 Initialize an Image from a PNG file.
 
uint_t InitPNG (RezFile *pRezFile, uint_t uRezNum, RGBAWord8_t *pPalette=0)
 Initialize an Image from a PNG file.
 
uint_t InitGIF (InputMemoryStream *pInput, RGBAWord8_t *pPalette=0)
 Initialize an Image from a GIF file stream.
 
uint_t InitGIF (const char *pFilename, RGBAWord8_t *pPalette=0)
 Initialize an Image from a GIF file.
 
uint_t InitGIF (Filename *pFilename, RGBAWord8_t *pPalette=0)
 Initialize an Image from a GIF file.
 
uint_t InitGIF (RezFile *pRezFile, uint_t uRezNum, RGBAWord8_t *pPalette=0)
 Initialize an Image from a GIF file.
 
uint_t InitTGA (InputMemoryStream *pInput, RGBAWord8_t *pPalette=0)
 Initialize an Image from a TGA file stream.
 
uint_t InitTGA (const char *pFilename, RGBAWord8_t *pPalette=0)
 Initialize an Image from a TGA file.
 
uint_t InitTGA (Filename *pFilename, RGBAWord8_t *pPalette=0)
 Initialize an Image from a TGA file.
 
uint_t InitTGA (RezFile *pRezFile, uint_t uRezNum, RGBAWord8_t *pPalette=0)
 Initialize an Image from a TGA file.
 
uint_t InitBMP (InputMemoryStream *pInput, RGBAWord8_t *pPalette=0)
 Initialize an Image from a BMP file stream.
 
uint_t InitBMP (const char *pFilename, RGBAWord8_t *pPalette=0)
 Initialize an Image from a BMP file.
 
uint_t InitBMP (Filename *pFilename, RGBAWord8_t *pPalette=0)
 Initialize an Image from a BMP file.
 
uint_t InitBMP (RezFile *pRezFile, uint_t uRezNum, RGBAWord8_t *pPalette=0)
 Initialize an Image from a BMP file.
 
void Transfer (Image *pInput)
 Move an image to the control of another Image.
 
void Shutdown (void)
 Releases all memory managed by this class instance.
 
const uint8_t * GetImage (void) const
 Return the base pointer of the image.
 
uint8_t * GetImage (void)
 Return the base pointer of the image.
 
const uint8_t * GetImage (uint_t uMipMap) const
 Return the base pointer of the image.
 
uint_t GetWidth (void) const
 Return the width of the image in pixels.
 
uint_t GetWidth (uint_t uMipMap) const
 Return the width of the image in pixels for the requested mip map.
 
uint_t GetHeight (void) const
 Return the height of the image in pixels.
 
uint_t GetHeight (uint_t uMipMap) const
 Return the height of the image in pixels for the requested mip map.
 
uintptr_t GetStride (void) const
 Return the number of bytes per scan line.
 
uintptr_t GetStride (uint_t uMipMap) const
 Return the height of the image in pixels for the requested mip map.
 
ePixelTypes GetType (void) const
 Return the pixel format type.
 
uint_t GetMipMapCount (void) const
 Return the number of available mip maps.
 
uint_t GetBytesPerPixel (void) const
 Return the bytes needed for each pixel.
 
uint_t GetBitsPerPixel (void) const
 Return the bits needed for each pixel.
 
uintptr_t GetSuggestedStride (void) const
 Determine the minimum number of bytes for a stride.
 
uintptr_t GetSuggestedBufferSize (void) const
 Determine the amount of memory needed for an image buffer.
 
uintptr_t GetImageSize (uint_t uMipMap) const
 Return the number of bytes a specific mip map image occupies.
 
const char * ValidateForSave (void) const
 Test the Image for validity before using it for a save.
 
void ClearBitmap (void)
 Erase all of the pixels in the bitmap.
 
uint_t VerticleFlip (void)
 Flip an image upside down.
 
uint_t HorizontalFlip (void)
 Flip an image horizontally.
 
uint_t Store8888 (const Image *pInput, const RGBAWord8_t *pPalette)
 Convert an image into PIXELTYPE8888 format.
 

Static Public Member Functions

static ImageNew (void)
 Returns a pointer to a newly allocated instance of an Image.
 
static ImageNew (uint_t uWidth, uint_t uHeight, ePixelTypes eType)
 Returns a pointer to a newly allocated instance of an Image.
 
static ImageNew (uint_t uWidth, uint_t uHeight, ePixelTypes eType, uint_t uMipMaps)
 Returns a pointer to a newly allocated instance of an Image.
 
static ImageNew (const Image *pInput)
 Returns a pointer to a copy of the image.
 
static uint_t GetBytesPerPixel (ePixelTypes eType)
 Given a pixel type, return the bytes needed for each pixel.
 
static uint_t GetBitsPerPixel (ePixelTypes eType)
 Given a pixel type, return the bits needed for each pixel.
 
static uintptr_t GetSuggestedStride (uint_t uWidth, ePixelTypes eType)
 Determine the minimum number of bytes for a stride.
 
static uintptr_t GetSuggestedBufferSize (uint_t uWidth, uint_t uHeight, ePixelTypes eType)
 Determine the amount of memory needed for an image buffer.
 
static uintptr_t GetSuggestedBufferSize (uint_t uWidth, uint_t uHeight, ePixelTypes eType, uint_t uMipMapLevels)
 Determine the amount of memory needed for an image buffer with mip maps.
 

Protected Attributes

uint8_t * m_pImage
 Pointer to pixel array.
 
uint_t m_uStride
 Number of bytes per scan line (Likely not the same value as m_uWidth)
 
uint_t m_uWidth
 Width of image in pixels.
 
uint_t m_uHeight
 Height of image in pixels.
 
uint_t m_uFlags
 Internal behavior flags.
 
ePixelTypes m_eType
 Type of pixel image.
 

Private Member Functions

 Image (const Image &)=delete
 
Imageoperator= (const Image &)=delete
 
 Image (Image &&)=delete
 
Imageoperator= (Image &&)=delete
 

Detailed Description

Class for containing raw images.


This class is the mechanism for loading and saving popular file formats for image files such as TGA, LBM, PCX, PNG and the like. It's used as input for the Burger::Texture manager to convert the data from an image into a hardware texture for GPU rendering. Graphics tools can use this class exclusively for image conversion and manipulation

See also
Burger::FileBMP and Burger::FileTGA

Member Enumeration Documentation

◆ eFlags

Enumerator
FLAGS_IMAGENOTALLOCATED 

TRUE if the image pointer was not allocated (And won't be released when Image goes out of scope)

FLAGS_MIPMAPMASK 

Mask for the number of mip maps present (0 means only one level, max 16)

◆ ePixelTypes

Pixel data type.


An enumeration to declare how each pixel is formatted.

Enumerator
PIXELTYPE1BIT 

1 bit per pixel monochrome

PIXELTYPE2BIT 

2 bits per pixel indexed by RGB palette

PIXELTYPE4BIT 

4 bits per pixel indexed by RGB palette

PIXELTYPE332 

8 bits per pixel R:3, G:3, B:2

PIXELTYPE8BIT 

8 bits per pixel indexed RGB palette (Or greyscale)

PIXELTYPE4444 

16 bits per pixel native endian A:4, R:4, G:4, B:4

PIXELTYPE1555 

16 bits per pixel native endian A:1, R:5, G:5, B:5

PIXELTYPE555 

16 bits per pixel native endian R:5, G:5, B:5

PIXELTYPE565 

16 bits per pixel native endian R:5, G:6, B:5

PIXELTYPEDXT1 

Compressed with DXT1.

PIXELTYPEDXT2 

Compressed with DXT2.

PIXELTYPEDXT3 

Compressed with DXT3.

PIXELTYPEDXT4 

Compressed with DXT4.

PIXELTYPEDXT5 

Compressed with DXT5.

PIXELTYPE888 

24 bits per pixel in bytes of R:8, G:8 and B:8

PIXELTYPE1010102 

32 bits per pixel in bytes of R:10, G:10, B:10 and A:2 in that order

PIXELTYPE8888 

32 bits per pixel in bytes of R:8, G:8, B:8 and A:8 in that order

Constructor & Destructor Documentation

◆ Image() [1/3]

Burger::Image::Image ( const Image & )
privatedelete

◆ Image() [2/3]

Burger::Image::Image ( Image && )
privatedelete

◆ Image() [3/3]

Burger::Image::Image ( )

Default constructor.


Initialize to an empty image

◆ ~Image()

Burger::Image::~Image ( )

Default destructor.


Release all data

See also
Shutdown(void)

Member Function Documentation

◆ ClearBitmap()

void Burger::Image::ClearBitmap ( void )

Erase all of the pixels in the bitmap.


Using the width value, zero out the pixels in the bitmap and use the stride value to skip to the next scan line.

Compressed and uncompressed formats are fully supported

◆ GetBitsPerPixel() [1/2]

uint_t BURGER_API Burger::Image::GetBitsPerPixel ( ePixelTypes eType)
static

Given a pixel type, return the bits needed for each pixel.


Return 1-32 for number of bits per pixel. This will return zero where bytes per pixel doesn't make sense, like compressed formats.

Parameters
eTypePixel type to convert to a bit size
Returns
0 for compressed formats, 1-32 for uncompressed types
See also
GetBitsPerPixel(void) const

◆ GetBitsPerPixel() [2/2]

uint_t Burger::Image::GetBitsPerPixel ( void ) const
inline

Return the bits needed for each pixel.


Return 1-32 for number of bits per pixel. This will return zero where bytes per pixel doesn't make sense, like compressed formats.

Returns
0 for compressed formats, 1-32 for uncompressed types
See also
GetBitsPerPixel(ePixelTypes eType)

◆ GetBytesPerPixel() [1/2]

uint_t BURGER_API Burger::Image::GetBytesPerPixel ( ePixelTypes eType)
static

Given a pixel type, return the bytes needed for each pixel.


Return 1-4 for number of bytes per pixel. This will return zero where bytes per pixel doesn't make sense, like compressed formats or 2 or more pixels per byte

Returns
0 if compressed or multiple pixels per byte, 1-4 otherwise
See also
GetBytesPerPixel(void) const

◆ GetBytesPerPixel() [2/2]

uint_t Burger::Image::GetBytesPerPixel ( void ) const
inline

Return the bytes needed for each pixel.


Return 1-4 for number of bytes per pixel. This will return zero where bytes per pixel doesn't make sense, like compressed formats or 2 or more pixels per byte

Returns
0 if compressed or multiple pixels per byte, 1-4 otherwise
See also
GetBytesPerPixel(ePixelTypes)

◆ GetHeight() [1/2]

uint_t Burger::Image::GetHeight ( uint_t uMipMap) const

Return the height of the image in pixels for the requested mip map.


An index of zero will get the largest (Native sized) mip map, an index of one gets the next largest and so on until the size of the smallest is found. If a mip map index higher than the smallest mip map is passed, the height of the smallest available mip map is returned.

Parameters
uMipMapZero based index into the array of mip maps
Returns
The pixel height for the selected mip map
See also
GetWidth(uint_t) const, GetHeight(void) const or GetType(void) const

◆ GetHeight() [2/2]

uint_t Burger::Image::GetHeight ( void ) const
inline

Return the height of the image in pixels.


Returns
The pixel height
See also
GetWidth(void) const or GetType(void) const

◆ GetImage() [1/3]

const uint8_t * Burger::Image::GetImage ( uint_t uMipMap) const

Return the base pointer of the image.


Returns a constant pointer to the upper left corner of the pixel image.

Returns
NULL if there's no data, or a valid pointer
See also
GetImage(void) or GetType(void) const

◆ GetImage() [2/3]

uint8_t * Burger::Image::GetImage ( void )
inline

Return the base pointer of the image.


Returns the pointer to the upper left corner of the pixel image.

Returns
NULL if there's no data, or a valid pointer
See also
GetImage(void) const or GetType(void) const

◆ GetImage() [3/3]

const uint8_t * Burger::Image::GetImage ( void ) const
inline

Return the base pointer of the image.


Returns a constant pointer to the upper left corner of the pixel image.

Returns
NULL if there's no data, or a valid pointer
See also
GetImage(void) or GetType(void) const

◆ GetImageSize()

uintptr_t Burger::Image::GetImageSize ( uint_t uMipMap) const

Return the number of bytes a specific mip map image occupies.


Return the size in bytes of a specific mip map sub image.

Used in conjunction with GetImage(uint_t) const, this will allow an application to extract a specific mip map for uploading onto a video card.

Returns
The number of bytes that a specific mip map occupies
See also
GetImage(uint_t) const

◆ GetMipMapCount()

uint_t Burger::Image::GetMipMapCount ( void ) const

Return the number of available mip maps.


Returns
1 through 16 levels of mip maps
See also
GetWidth(void) const or GetHeight(void) const

◆ GetStride() [1/2]

uintptr_t Burger::Image::GetStride ( uint_t uMipMap) const

Return the height of the image in pixels for the requested mip map.


An index of zero will get the largest (Native sized) mip map, an index of one gets the next largest and so on until the size of the smallest is found. If a mip map index higher than the smallest mip map is passed, the byte stride of the smallest available mip map is returned.

Parameters
uMipMapZero based index into the array of mip maps
Returns
The number of bytes for one scan line for the selected mip map
See also
GetStride(void) const, GetWidth(uint_t) const, GetHeight(void) const or GetType(void) const

◆ GetStride() [2/2]

uintptr_t Burger::Image::GetStride ( void ) const
inline

Return the number of bytes per scan line.


Returns
The number of bytes for one scan line of the image
See also
GetWidth(void) const or GetHeight(void) const

◆ GetSuggestedBufferSize() [1/3]

uintptr_t BURGER_API Burger::Image::GetSuggestedBufferSize ( uint_t uWidth,
uint_t uHeight,
ePixelTypes eType )
static

Determine the amount of memory needed for an image buffer.


Given a width, height and pixel type, calculate the size of a buffer that would contain the entire image. This function is used to allocate an image buffer.

Parameters
uWidthThe width of the proposed image in pixels
uHeightThe height of the proposed image in pixels
eTypeThe format of a single pixel in the image
Returns
The number of bytes needed to allocate a buffer for this image.
See also
GetSuggestedBufferSize(uint_t,uint_t,ePixelTypes,uint_t), GetSuggestedStride(uint_t,ePixelTypes) or GetSuggestedBufferSize(void) const

◆ GetSuggestedBufferSize() [2/3]

uintptr_t BURGER_API Burger::Image::GetSuggestedBufferSize ( uint_t uWidth,
uint_t uHeight,
ePixelTypes eType,
uint_t uMipMapLevels )
static

Determine the amount of memory needed for an image buffer with mip maps.


Given a Width, Height,pixel type and number of levels of mip maps, calculate the size of a buffer that would contain the entire image. This function is used to allocate an image buffer.

Parameters
uWidthThe width of the proposed image in pixels
uHeightThe height of the proposed image in pixels
eTypeThe format of a single pixel in the image
uMipMapLevelsNumber of mip map levels deep. Zero is treated as one.
Returns
The number of bytes needed to allocate a buffer for this image.
See also
GetSuggestedStride(uint_t,ePixelTypes) or GetSuggestedBufferSize(void) const

◆ GetSuggestedBufferSize() [3/3]

uintptr_t Burger::Image::GetSuggestedBufferSize ( void ) const

Determine the amount of memory needed for an image buffer.


Given an Image set with Width, Height and pixel type, calculate the size of a buffer that would contain the entire image. This function is used to allocate an image buffer.

Returns
The number of bytes needed to allocate a buffer for this image.
See also
GetSuggestedBufferSize(uint_t,uint_t,ePixelTypes)

◆ GetSuggestedStride() [1/2]

uintptr_t BURGER_API Burger::Image::GetSuggestedStride ( uint_t uWidth,
ePixelTypes eType )
static

Determine the minimum number of bytes for a stride.


Given a Width and pixel type, calculate the number of bytes for a single scan line of an image.

Note: Compressed formats will give the stride to the next block group, not the next line.

Parameters
uWidthThe width of the proposed image in pixels
eTypeThe format of a single pixel in the image
Returns
The minimum number of bytes needed for a single scan line for this image
See also
GetSuggestedStride(void) const or GetSuggestedBufferSize(uint_t,uint_t,ePixelTypes)

◆ GetSuggestedStride() [2/2]

uintptr_t Burger::Image::GetSuggestedStride ( void ) const

Determine the minimum number of bytes for a stride.


Given an Image and using it's pixel format and pixel width, calculate the number of bytes for a single scan line of an image.

Note
This function does not return the m_uStride value, use GetStride() const instead.
Compressed formats will give the stride to the next block group, not the next line.
Returns
The minimum number of bytes needed for a single scan line for this image
See also
GetSuggestedStride(uint_t,ePixelTypes) or GetSuggestedBufferSize(uint_t,uint_t,ePixelTypes)

◆ GetType()

ePixelTypes Burger::Image::GetType ( void ) const
inline

Return the pixel format type.


Returns
The pixel type enumeration
See also
GetWidth(void) const or GetHeight(void) const

◆ GetWidth() [1/2]

uint_t Burger::Image::GetWidth ( uint_t uMipMap) const

Return the width of the image in pixels for the requested mip map.


An index of zero will get the largest (Native sized) mip map, an index of one gets the next largest and so on until the size of the smallest is found. If a mip map index higher than the smallest mip map is passed, the width of the smallest available mip map is returned.

Parameters
uMipMapZero based index into the array of mip maps
Returns
The pixel width for the selected mip map
See also
GetWidth(void) const, GetHeight(uint_t) const or GetType(void) const

◆ GetWidth() [2/2]

uint_t Burger::Image::GetWidth ( void ) const
inline

Return the width of the image in pixels.


Returns
The pixel width
See also
GetWidth(uint_t) const, GetHeight(void) const or GetType(void) const

◆ HorizontalFlip()

uint_t Burger::Image::HorizontalFlip ( void )

Flip an image horizontally.


For uncompressed pixel formats, this function will flip the image left to right

Returns
Zero if successful, non zero if the image can't be flipped
See also
VerticleFlip()

◆ Init() [1/4]

uint_t Burger::Image::Init ( const Image * pInput)

Make a copy of an image.


Given an image, make a copy of it in this image

Parameters
pInputPointer to a valid image to copy from
Returns
Zero on success, non-zero on failure
See also
Shutdown(void), Init(uint_t,uint_t,ePixelTypes)

◆ Init() [2/4]

uint_t Burger::Image::Init ( uint_t uWidth,
uint_t uHeight,
ePixelTypes eType )

Allocates memory suitable for an image.


Given a width, height and pixel depth of a requested image type, allocate an uninitialized buffer and set up the constants to describe this data.

If the image dimensions/type is already a match, this function returns immediately. If not, any previous data is released and new data is allocated.

Parameters
uWidthWidth of the new image in pixels
uHeightHeight of the new image in pixels
eTypePixel type of the new image
Returns
Zero on success, non-zero on failure
See also
Shutdown(void), Init(const Image *)

◆ Init() [3/4]

uint_t Burger::Image::Init ( uint_t uWidth,
uint_t uHeight,
ePixelTypes eType,
uint_t uMipMaps )

Allocates memory suitable for an image and its mipmaps.


Given a width, height, pixel depth and mip map count, of a requested image type, allocate an uninitialized buffer and set up the constants to describe this data.

If the image dimensions/type is already a match, this function returns immediately. If not, any previous data is released and new data is allocated.

Parameters
uWidthWidth of the new image in pixels
uHeightHeight of the new image in pixels
eTypePixel type of the new image
uMipMapsNumber of mip maps requested
Returns
Zero on success, non-zero on failure
See also
Shutdown(void), Init(const Image *)

◆ Init() [4/4]

void Burger::Image::Init ( uint_t uWidth,
uint_t uHeight,
ePixelTypes eType,
uintptr_t uStride,
const uint8_t * pImage,
uint_t uFlags = 0,
uint_t uMipMaps = 0 )

Manually initialize an Image.


Given all entries for an Image record, initialize it. If there was a previous buffer, it's released.

Note
If the buffer is manually controlled, pass FLAGS_IMAGENOTALLOCATED in the uFlags parameter.
Parameters
uWidthWidth of the new image in pixels
uHeightHeight of the new image in pixels
eTypePixel type of the new image
uStrideBytes per scan line of the new image
pImagePointer to the pixels of the new image
uFlagsFlag controlling whether or not the class will call Free() on pImage on shutdown
uMipMapsNumber of mip maps in the image (Max 16)
See also
Shutdown(void), Init(const Image *)

◆ InitBMP() [1/4]

uint_t Burger::Image::InitBMP ( const char * pFilename,
RGBAWord8_t * pPalette = 0 )

Initialize an Image from a BMP file.


Given a Burgerlib format filename, open the file, read it in, and convert the contents into an Image.

Note
If the graphic file has a palette, it will be returned to the buffer pointed to by pPalette. If there was an error or if the image doesn't have a palette (24/32 bit color), the palette will be cleared to black with an alpha set to 255,
Parameters
pFilenamePointer to a Burgerlib filename
pPalettePointer to a 256 entry RGBAWord8_t palette, or NULL if no buffer exists
Returns
Zero on success, non-zero on failure
See also
InitBMP(InputMemoryStream *,RGBAWord8_t *), InitBMP(Filename *,RGBAWord8_t *), InitBMP(RezFile *,uint_t,RGBAWord8_t *) or FileBMP::Load(Image *,InputMemoryStream *)

◆ InitBMP() [2/4]

uint_t Burger::Image::InitBMP ( Filename * pFilename,
RGBAWord8_t * pPalette = 0 )

Initialize an Image from a BMP file.


Given a Burgerlib Filename, open the file, read it in, and convert the contents into an Image.

Note
If the graphic file has a palette, it will be returned to the buffer pointed to by pPalette. If there was an error or if the image doesn't have a palette (24/32 bit color), the palette will be cleared to black with an alpha set to 255,
Parameters
pFilenamePointer to a Burgerlib Filename
pPalettePointer to a 256 entry RGBAWord8_t palette, or NULL if no buffer exists
Returns
Zero on success, non-zero on failure
See also
InitBMP(InputMemoryStream *,RGBAWord8_t *), InitBMP(const char *,RGBAWord8_t *), InitBMP(RezFile *,uint_t,RGBAWord8_t *) or FileBMP::Load(Image *,InputMemoryStream *)

◆ InitBMP() [3/4]

uint_t Burger::Image::InitBMP ( InputMemoryStream * pInput,
RGBAWord8_t * pPalette = 0 )

Initialize an Image from a BMP file stream.


Given a InputMemoryStream containing a BMP file, convert the contents into an Image.

Note
If the graphic file has a palette, it will be returned to the buffer pointed to by pPalette. If there was an error or if the image doesn't have a palette (24/32 bit color), the palette will be cleared to black with an alpha set to 255,
Parameters
pInputPointer to a stream with a BMP file inside
pPalettePointer to a 256 entry RGBAWord8_t palette, or NULL if no buffer exists
Returns
Zero on success, non-zero on failure
See also
InitBMP(const char *,RGBAWord8_t *), InitBMP(Filename *,RGBAWord8_t *), InitBMP(RezFile *,uint_t,RGBAWord8_t *) or FileBMP::Load(Image *,InputMemoryStream *)

◆ InitBMP() [4/4]

uint_t Burger::Image::InitBMP ( RezFile * pRezFile,
uint_t uRezNum,
RGBAWord8_t * pPalette = 0 )

Initialize an Image from a BMP file.


Given a Burgerlib Filename, open the file, read it in, and convert the contents into an Image.

Note
If the graphic file has a palette, it will be returned to the buffer pointed to by pPalette. If there was an error or if the image doesn't have a palette (24/32 bit color), the palette will be cleared to black with an alpha set to 255,
Parameters
pRezFilePointer to a Burgerlib RezFile
uRezNumIndex number of the file in the RezFile
pPalettePointer to a 256 entry RGBAWord8_t palette, or NULL if no buffer exists
Returns
Zero on success, non-zero on failure
See also
InitBMP(InputMemoryStream *,RGBAWord8_t *), InitBMP(Filename *,RGBAWord8_t *), InitBMP(const char *,RGBAWord8_t *) or FileBMP::Load(Image *,InputMemoryStream *)

◆ InitGIF() [1/4]

uint_t Burger::Image::InitGIF ( const char * pFilename,
RGBAWord8_t * pPalette = 0 )

Initialize an Image from a GIF file.


Given a Burgerlib format filename, open the file, read it in, and convert the contents into an Image.

If this is an animated GIF file, only load in the first frame. This is a convenience routine to simplify loading a graphic file into memory.

Note
The palette will be returned to the buffer pointed to by pPalette. If there was an error, the palette will be cleared to black with an alpha set to 255,
Parameters
pFilenamePointer to a Burgerlib filename
pPalettePointer to a 256 entry RGBAWord8_t palette, or NULL if no buffer exists
Returns
Zero on success, non-zero on failure
See also
InitGIF(InputMemoryStream *,RGBAWord8_t *), InitGIF(Filename *,RGBAWord8_t *), InitGIF(RezFile *,uint_t,RGBAWord8_t *) or FileGIF::Load(Image *,InputMemoryStream *)

◆ InitGIF() [2/4]

uint_t Burger::Image::InitGIF ( Filename * pFilename,
RGBAWord8_t * pPalette = 0 )

Initialize an Image from a GIF file.


Given a Burgerlib Filename, open the file, read it in, and convert the contents into an Image.

If this is an animated GIF file, only load in the first frame. This is a convenience routine to simplify loading a graphic file into memory.

Note
The palette will be returned to the buffer pointed to by pPalette. If there was an error, the palette will be cleared to black with an alpha set to 255,
Parameters
pFilenamePointer to a Burgerlib Filename
pPalettePointer to a 256 entry RGBAWord8_t palette, or NULL if no buffer exists
Returns
Zero on success, non-zero on failure
See also
InitGIF(InputMemoryStream *,RGBAWord8_t *), InitGIF(const char *,RGBAWord8_t *), InitGIF(RezFile *,uint_t,RGBAWord8_t *) or FileGIF::Load(Image *,InputMemoryStream *)

◆ InitGIF() [3/4]

uint_t Burger::Image::InitGIF ( InputMemoryStream * pInput,
RGBAWord8_t * pPalette = 0 )

Initialize an Image from a GIF file stream.


Given a InputMemoryStream containing a GIF file, convert the contents into an Image.

If this is an animated GIF file, only load in the first frame. This is a convenience routine to simplify loading a graphic file into memory.

Note
The palette will be returned to the buffer pointed to by pPalette. If there was an error, the palette will be cleared to black with an alpha set to 255,
Parameters
pInputPointer to a stream with a GIF file inside
pPalettePointer to a 256 entry RGBAWord8_t palette, or NULL if no buffer exists
Returns
Zero on success, non-zero on failure
See also
InitGIF(const char *,RGBAWord8_t *), InitGIF(Filename *,RGBAWord8_t *), InitGIF(RezFile *,uint_t,RGBAWord8_t *) or FileGIF::Load(Image *,InputMemoryStream *)

◆ InitGIF() [4/4]

uint_t Burger::Image::InitGIF ( RezFile * pRezFile,
uint_t uRezNum,
RGBAWord8_t * pPalette = 0 )

Initialize an Image from a GIF file.


Given a Burgerlib Filename, open the file, read it in, and convert the contents into an Image.

If this is an animated GIF file, only load in the first frame. This is a convenience routine to simplify loading a graphic file into memory.

Note
The palette will be returned to the buffer pointed to by pPalette. If there was an error, the palette will be cleared to black with an alpha set to 255,
Parameters
pRezFilePointer to a Burgerlib RezFile
uRezNumIndex number of the file in the RezFile
pPalettePointer to a 256 entry RGBAWord8_t palette, or NULL if no buffer exists
Returns
Zero on success, non-zero on failure
See also
InitGIF(InputMemoryStream *,RGBAWord8_t *), InitGIF(Filename *,RGBAWord8_t *), InitGIF(const char *,RGBAWord8_t *) or FileGIF::Load(Image *,InputMemoryStream *)

◆ InitPNG() [1/4]

uint_t Burger::Image::InitPNG ( const char * pFilename,
RGBAWord8_t * pPalette = 0 )

Initialize an Image from a PNG file.


Given a Burgerlib format filename, open the file, read it in, and convert the contents into an Image.

If this is an animated PNG file, only load in the first frame. This is a convenience routine to simplify loading a graphic file into memory.

Note
If the graphic file has a palette, it will be returned to the buffer pointed to by pPalette. If there was an error or if the image doesn't have a palette (24/32 bit color), the palette will be cleared to black with an alpha set to 255,
Parameters
pFilenamePointer to a Burgerlib filename
pPalettePointer to a 256 entry RGBAWord8_t palette, or NULL if no buffer exists
Returns
Zero on success, non-zero on failure
See also
InitPNG(InputMemoryStream *,RGBAWord8_t *), InitPNG(Filename *,RGBAWord8_t *), InitPNG(RezFile *,uint_t,RGBAWord8_t *) or FilePNG::Load(Image *,InputMemoryStream *)

◆ InitPNG() [2/4]

uint_t Burger::Image::InitPNG ( Filename * pFilename,
RGBAWord8_t * pPalette = 0 )

Initialize an Image from a PNG file.


Given a Burgerlib Filename, open the file, read it in, and convert the contents into an Image.

If this is an animated PNG file, only load in the first frame. This is a convenience routine to simplify loading a graphic file into memory.

Note
If the graphic file has a palette, it will be returned to the buffer pointed to by pPalette. If there was an error or if the image doesn't have a palette (24/32 bit color), the palette will be cleared to black with an alpha set to 255,
Parameters
pFilenamePointer to a Burgerlib Filename
pPalettePointer to a 256 entry RGBAWord8_t palette, or NULL if no buffer exists
Returns
Zero on success, non-zero on failure
See also
InitPNG(InputMemoryStream *,RGBAWord8_t *), InitPNG(const char *,RGBAWord8_t *), InitPNG(RezFile *,uint_t,RGBAWord8_t *) or FilePNG::Load(Image *,InputMemoryStream *)

◆ InitPNG() [3/4]

uint_t Burger::Image::InitPNG ( InputMemoryStream * pInput,
RGBAWord8_t * pPalette = 0 )

Initialize an Image from a PNG file stream.


Given a InputMemoryStream containing a PNG file, convert the contents into an Image.

If this is an animated PNG file, only load in the first frame. This is a convenience routine to simplify loading a graphic file into memory.

Note
If the graphic file has a palette, it will be returned to the buffer pointed to by pPalette. If there was an error or if the image doesn't have a palette (24/32 bit color), the palette will be cleared to black with an alpha set to 255,
Parameters
pInputPointer to a stream with a PNG file inside
pPalettePointer to a 256 entry RGBAWord8_t palette, or NULL if no buffer exists
Returns
Zero on success, non-zero on failure
See also
InitPNG(const char *,RGBAWord8_t *), InitPNG(Filename *,RGBAWord8_t *), InitPNG(RezFile *,uint_t,RGBAWord8_t *) or FilePNG::Load(Image *,InputMemoryStream *)

◆ InitPNG() [4/4]

uint_t Burger::Image::InitPNG ( RezFile * pRezFile,
uint_t uRezNum,
RGBAWord8_t * pPalette = 0 )

Initialize an Image from a PNG file.


Given a Burgerlib Filename, open the file, read it in, and convert the contents into an Image.

If this is an animated PNG file, only load in the first frame. This is a convenience routine to simplify loading a graphic file into memory.

Note
If the graphic file has a palette, it will be returned to the buffer pointed to by pPalette. If there was an error or if the image doesn't have a palette (24/32 bit color), the palette will be cleared to black with an alpha set to 255,
Parameters
pRezFilePointer to a Burgerlib RezFile
uRezNumIndex number of the file in the RezFile
pPalettePointer to a 256 entry RGBAWord8_t palette, or NULL if no buffer exists
Returns
Zero on success, non-zero on failure
See also
InitPNG(InputMemoryStream *,RGBAWord8_t *), InitPNG(Filename *,RGBAWord8_t *), InitPNG(const char *,RGBAWord8_t *) or FilePNG::Load(Image *,InputMemoryStream *)

◆ InitTGA() [1/4]

uint_t Burger::Image::InitTGA ( const char * pFilename,
RGBAWord8_t * pPalette = 0 )

Initialize an Image from a TGA file.


Given a Burgerlib format filename, open the file, read it in, and convert the contents into an Image.

Note
If the graphic file has a palette, it will be returned to the buffer pointed to by pPalette. If there was an error or if the image doesn't have a palette (24/32 bit color), the palette will be cleared to black with an alpha set to 255,
Parameters
pFilenamePointer to a Burgerlib filename
pPalettePointer to a 256 entry RGBAWord8_t palette, or NULL if no buffer exists
Returns
Zero on success, non-zero on failure
See also
InitTGA(InputMemoryStream *,RGBAWord8_t *), InitTGA(Filename *,RGBAWord8_t *), InitTGA(RezFile *,uint_t,RGBAWord8_t *) or FileTGA::Load(Image *,InputMemoryStream *)

◆ InitTGA() [2/4]

uint_t Burger::Image::InitTGA ( Filename * pFilename,
RGBAWord8_t * pPalette = 0 )

Initialize an Image from a TGA file.


Given a Burgerlib Filename, open the file, read it in, and convert the contents into an Image.

Note
If the graphic file has a palette, it will be returned to the buffer pointed to by pPalette. If there was an error or if the image doesn't have a palette (24/32 bit color), the palette will be cleared to black with an alpha set to 255,
Parameters
pFilenamePointer to a Burgerlib Filename
pPalettePointer to a 256 entry RGBAWord8_t palette, or NULL if no buffer exists
Returns
Zero on success, non-zero on failure
See also
InitTGA(InputMemoryStream *,RGBAWord8_t *), InitTGA(const char *,RGBAWord8_t *), InitTGA(RezFile *,uint_t,RGBAWord8_t *) or FileTGA::Load(Image *,InputMemoryStream *)

◆ InitTGA() [3/4]

uint_t Burger::Image::InitTGA ( InputMemoryStream * pInput,
RGBAWord8_t * pPalette = 0 )

Initialize an Image from a TGA file stream.


Given a InputMemoryStream containing a TGA file, convert the contents into an Image.

Note
If the graphic file has a palette, it will be returned to the buffer pointed to by pPalette. If there was an error or if the image doesn't have a palette (24/32 bit color), the palette will be cleared to black with an alpha set to 255,
Parameters
pInputPointer to a stream with a TGA file inside
pPalettePointer to a 256 entry RGBAWord8_t palette, or NULL if no buffer exists
Returns
Zero on success, non-zero on failure
See also
InitPNG(const char *,RGBAWord8_t *), InitTGA(Filename *,RGBAWord8_t *), InitTGA(RezFile *,uint_t,RGBAWord8_t *) or FileTGA::Load(Image *,InputMemoryStream *)

◆ InitTGA() [4/4]

uint_t Burger::Image::InitTGA ( RezFile * pRezFile,
uint_t uRezNum,
RGBAWord8_t * pPalette = 0 )

Initialize an Image from a TGA file.


Given a Burgerlib Filename, open the file, read it in, and convert the contents into an Image.

Note
If the graphic file has a palette, it will be returned to the buffer pointed to by pPalette. If there was an error or if the image doesn't have a palette (24/32 bit color), the palette will be cleared to black with an alpha set to 255,
Parameters
pRezFilePointer to a Burgerlib RezFile
uRezNumIndex number of the file in the RezFile
pPalettePointer to a 256 entry RGBAWord8_t palette, or NULL if no buffer exists
Returns
Zero on success, non-zero on failure
See also
InitTGA(InputMemoryStream *,RGBAWord8_t *), InitTGA(Filename *,RGBAWord8_t *), InitTGA(const char *,RGBAWord8_t *) or FileTGA::Load(Image *,InputMemoryStream *)

◆ New() [1/4]

Burger::Image *BURGER_API Burger::Image::New ( const Image * pInput)
static

Returns a pointer to a copy of the image.


Makes a duplicate of this image and returns a pointer to the new instance.

Release this object with a call to delete

Image *pFoo = Burger::Image::New(pOldImage);
if (pFoo) {
DoStuff(pFoo);
Delete(pFoo);
}
Class for containing raw images.
Definition burger.h:20274
static Image * New(void)
Returns a pointer to a newly allocated instance of an Image.
Definition brimage.cpp:102
void Delete(const Base *pInput) noexcept
Delete a base class.
Definition brbase.cpp:56
Parameters
pInputPointer to a valid Image to copy from
Returns
A valid pointer if memory is available or NULL if out of memory
See also
New(void), New(uint_t,uint_t,ePixelTypes)

◆ New() [2/4]

Burger::Image *BURGER_API Burger::Image::New ( uint_t uWidth,
uint_t uHeight,
ePixelTypes eType )
static

Returns a pointer to a newly allocated instance of an Image.


Creates an object of the specified type. All memory is initialized.

Release this object with a call to delete

// Create memory for a 64x128 32 bits per pixel image
if (pFoo) {
DoStuff(pFoo);
Delete(pFoo);
}
@ PIXELTYPE8888
32 bits per pixel in bytes of R:8, G:8, B:8 and A:8 in that order
Definition burger.h:20298
Parameters
uWidthWidth of the image in pixels
uHeightHeight of the image in pixels
eTypeType of pixel data
Returns
A valid pointer if memory is available or NULL if out of memory
See also
Init(uint_t,uint_t,ePixelTypes), New(void)

◆ New() [3/4]

Burger::Image *BURGER_API Burger::Image::New ( uint_t uWidth,
uint_t uHeight,
ePixelTypes eType,
uint_t uMipMaps )
static

Returns a pointer to a newly allocated instance of an Image.


Creates an object of the specified type. All memory is initialized.

Release this object with a call to delete

// Create memory for a 256x256 32 bits per pixel image with 3 mip maps (256x256,128x128,64x64)
if (pFoo) {
DoStuff(pFoo);
Delete(pFoo);
}
Parameters
uWidthWidth of the image in pixels
uHeightHeight of the image in pixels
eTypeType of pixel data
uMipMapsNumber of levels of mipmaps for the image
Returns
A valid pointer if memory is available or NULL if out of memory
See also
Init(uint_t,uint_t,ePixelTypes,uint_t), New(void)

◆ New() [4/4]

Burger::Image *BURGER_API Burger::Image::New ( void )
static

Returns a pointer to a newly allocated instance of an Image.


Creates an empty Image object.

Release this object with a call to delete

if (pFoo) {
DoStuff(pFoo);
Delete(pFoo);
}
Returns
A valid pointer if memory is available or NULL if out of memory
See also
New(uint_t,uint_t,ePixelTypes)

◆ operator=() [1/2]

Image & Burger::Image::operator= ( const Image & )
privatedelete

◆ operator=() [2/2]

Image & Burger::Image::operator= ( Image && )
privatedelete

◆ Shutdown()

void Burger::Image::Shutdown ( void )

Releases all memory managed by this class instance.


Releases all memory attached to this image and clears out all of the width/height/depth variables.

See also
Init(uint_t,uint_t,ePixelTypes), Init(const Image *)

◆ Store8888()

uint_t Burger::Image::Store8888 ( const Image * pInput,
const RGBAWord8_t * pPalette )

Convert an image into PIXELTYPE8888 format.


Assume that the Image is already an PIXELTYPE8888 format shape and a buffer is present. Return an error if not.

Note
Supported input formats are PIXELTYPE8BIT, PIXELTYPE4444, PIXELTYPE1555, PIXELTYPE555, PIXELTYPE565, PIXELTYPE888 and PIXELTYPE8888
Parameters
pInputPointer to an image to convert from
pPaletteOptional color palette if converting from an 8 bit format

◆ Transfer()

void Burger::Image::Transfer ( Image * pInput)

Move an image to the control of another Image.


Given an image, move the control of its contents into another Image. The pInput image will have no data within itself and can be immediately released or reappropriated.

No buffers are allocated or released. Only pointers are exchanged.

This Image will be purged before the transfer is started.

Parameters
pInputPointer to a valid image to transfer from
See also
Shutdown(void), Init(uint_t,uint_t,ePixelTypes)

◆ ValidateForSave()

const char * Burger::Image::ValidateForSave ( void ) const

Test the Image for validity before using it for a save.


Test the image if it has a non-zero width, height and image pointer.

Returns
NULL if the Image is valid or a pointer to a "C" string with the reason for failure.

◆ VerticleFlip()

uint_t Burger::Image::VerticleFlip ( void )

Flip an image upside down.


For uncompressed pixel formats, this function will flip the image upside down

Returns
Zero if successful, non zero if the image can't be flipped
See also
HorizontalFlip()

Member Data Documentation

◆ m_eType

ePixelTypes Burger::Image::m_eType
protected

Type of pixel image.

◆ m_pImage

uint8_t* Burger::Image::m_pImage
protected

Pointer to pixel array.

◆ m_uFlags

uint_t Burger::Image::m_uFlags
protected

Internal behavior flags.

◆ m_uHeight

uint_t Burger::Image::m_uHeight
protected

Height of image in pixels.

◆ m_uStride

uint_t Burger::Image::m_uStride
protected

Number of bytes per scan line (Likely not the same value as m_uWidth)

◆ m_uWidth

uint_t Burger::Image::m_uWidth
protected

Width of image in pixels.