NAP
Public Types | Public Member Functions | List of all members
BitmapFileBuffer Class Referencefinal

#include <bitmapfilebuffer.h>

Public Types

enum  EImageFileFormat : int { PNG, JPEG, TIFF, BMP }
 

Public Member Functions

 BitmapFileBuffer ()
 
 BitmapFileBuffer (const Bitmap &bitmap, bool copyData)
 
 BitmapFileBuffer (const SurfaceDescriptor &surfaceDescriptor, const void *data, bool copyData)
 
 BitmapFileBuffer (const SurfaceDescriptor &surfaceDescriptor)
 
 ~BitmapFileBuffer ()
 
 BitmapFileBuffer (const BitmapFileBuffer &rhs)=delete
 
BitmapFileBufferoperator= (const BitmapFileBuffer &rhs)=delete
 
 BitmapFileBuffer (BitmapFileBuffer &&rhs)=delete
 
BitmapFileBufferoperator= (BitmapFileBuffer &&rhs)=delete
 
bool load (const std::string &path, SurfaceDescriptor &outSurfaceDescriptor, utility::ErrorState &errorState)
 
bool save (const std::string &path, utility::ErrorState &errorState)
 
void * getData ()
 
void * getHandle ()
 

Description

Bitmap extension class that encodes/decodes image data for writing to/reading from disk.

Member Enumeration Documentation

◆ EImageFileFormat

enum EImageFileFormat : int
strong

All supported output extensions

Enumerator
PNG 

Portable Network Graphics (*.PNG)

JPEG 

Independent JPEG Group (*.JPG, *.JIF, *.JPEG, *.JPE)

TIFF 

Tagged Image File Format (*.TIF, *.TIFF)

BMP 

Windows or OS/2 Bitmap File (*.BMP)

Constructor & Destructor Documentation

◆ BitmapFileBuffer() [1/6]

Creates an empty bitmap file buffer

◆ BitmapFileBuffer() [2/6]

BitmapFileBuffer ( const Bitmap bitmap,
bool  copyData 
)

Creates a bitmap file buffer from a bitmap

Parameters
bitmapthe source bitmap
copyDataif true, allocates an additional file buffer to copy the bitmap data to, else wraps the image data

◆ BitmapFileBuffer() [3/6]

BitmapFileBuffer ( const SurfaceDescriptor surfaceDescriptor,
const void *  data,
bool  copyData 
)

Creates a bitmap file buffer from a bitmap

Parameters
surfaceDescriptorthe surface descriptor used to allocate the file buffer
dataa pointer to the raw bitmap data
copyDataif true, allocates an additional file buffer to copy the bitmap data to, else wraps the image data

◆ BitmapFileBuffer() [4/6]

BitmapFileBuffer ( const SurfaceDescriptor surfaceDescriptor)

Creates a bitmap file buffer from a surface descriptor

Parameters
surfaceDescriptorthe surface descriptor used to allocate the file buffer

◆ ~BitmapFileBuffer()

Unloads the internal bitmap handle

◆ BitmapFileBuffer() [5/6]

BitmapFileBuffer ( const BitmapFileBuffer rhs)
delete

BitmapFileBuffer cannot be copied

◆ BitmapFileBuffer() [6/6]

BitmapFileBuffer ( BitmapFileBuffer &&  rhs)
delete

BitmapFileBuffer cannot be moved

Member Function Documentation

◆ getData()

void* getData ( )

Returns a pointer to the internal pixel data

Returns
a pointer to the internal pixel data

◆ getHandle()

void* getHandle ( )

Returns a handle to the FreeImage bitmap. This comprises the FreeImage info header and pixel data Cast to a FIBITMAP pointer as follows:

FIBITMAP* fi_bitmap = reinterpret_cast<FIBITMAP*>(bitmap_file_buffer.getHandle());
Returns
a handle to the FreeImage bitmap

◆ load()

bool load ( const std::string &  path,
SurfaceDescriptor outSurfaceDescriptor,
utility::ErrorState errorState 
)

Loads an image from disk and creates the bitmap file buffer

Parameters
paththe path to the image on disk to load
outSurfaceDescriptorthe surface descriptor containing information about the image
errorStatecontains the error if the image could not be loaded from disk

◆ operator=() [1/2]

BitmapFileBuffer& operator= ( BitmapFileBuffer &&  rhs)
delete

◆ operator=() [2/2]

BitmapFileBuffer& operator= ( const BitmapFileBuffer rhs)
delete

◆ save()

bool save ( const std::string &  path,
utility::ErrorState errorState 
)

Writes this bitmap to the given location on disk with the specified image format

Parameters
paththe path including filename and image extension of the output file e.g. "targetFolder/MyOutputFile.png"
errorStatecontains the error if the image could not be saved to disk