PURE API 0.5
PR00F's Ultimate Rendering Engine full documentation
Loading...
Searching...
No Matches
PureImageManager Class Reference

Image manager class. More...

Detailed Description

Image manager class.

Definition at line 116 of file PureImageManager.h.

#include <PureImageManager.h>

+ Inheritance diagram for PureImageManager:

Classes

class  PureImageManagerImpl
 

Public Member Functions

 PureImageManager ()
 
virtual ~PureImageManager ()
 
CConsole & getConsole () const
 Returns access to console preset with logger module name as this class.
 
virtual PureImagecreateFromFile (const char *filename)
 Creates an Image object from the given file.
 
PureImagecreateBlank (TPureUInt width, TPureUInt height, TPureUInt bpp)
 Creates a blank Image object as specified.
 
virtual void WriteList () const
 From PureFiledManager, adding logging image size data.
 
- Public Member Functions inherited from PureFiledManager
 PureFiledManager ()
 
virtual ~PureFiledManager ()
 
CConsole & getConsole () const
 Returns access to console preset with logger module name as this class.
 
PureFiledManagedgetByFilename (const char *filename) const
 Gets the FiledManaged by the specified filename.
 
- Public Member Functions inherited from PureManager
 PureManager ()
 
virtual ~PureManager ()
 
CConsole & getConsole () const
 Returns access to console preset with logger module name as this class.
 
TPureInt getCount () const
 Gets the number of managed objects.
 
TPureBool isEmpty () const
 Is the number of manageds 0?
 
TPureInt getSize () const
 Gets the number of allocated slots for managed objects; getSize() >= getCount().
 
PureManagedgetAttachedAt (TPureInt ind) const
 Gets the pointer to the managed at the given index.
 
TPureInt getAttachedIndex (const PureManaged &m) const
 Gets the index of the given managed.
 
void PreAlloc (TPureInt count)
 Allocates count free slots for manageds.
 
TPureBool hasAttached (const PureManaged &m) const
 Gets whether the given managed is managed by this manager.
 
virtual void Attach (PureManaged &m)
 Adds the given managed to the manager, if the managed has no manager yet.
 
virtual void Detach (PureManaged &m)
 Removes the given managed from the manager, so the managed will have no manager.
 
void DeleteAttachedInstance (PureManaged &m)
 Removes the given managed from the manager and destructs it.
 
void DeleteAll ()
 Removes and destructs every managed element in the manager.
 
virtual void HandleManagedPropertyChanged (PureManaged &m)
 Should be invoked when a managed's property got changed from a different kind of manager or managed.
 
virtual TPureUInt getUsedSystemMemory () const
 Gets the amount of allocated system memory for all manageds owner by this manager.
 

Static Public Member Functions

static TPureUInt getColorConversionSwapCount (TPIXCOMPORD from, TPIXCOMPORD to)
 Calculates the number of swaps needed from the given color component order to the other.
 
static TPIXCOMPORD getMirroredPixelComponentOrder (TPIXCOMPORD corder)
 Transforms the given color component order to its mirrored form.
 
static const char * getLoggerModuleName ()
 Returns the logger module name of this class.
 
- Static Public Member Functions inherited from PureFiledManager
static const char * getLoggerModuleName ()
 Returns the logger module name of this class.
 
- Static Public Member Functions inherited from PureManager
static const char * getLoggerModuleName ()
 Returns the logger module name of this class.
 

Protected Member Functions

 PureImageManager (const PureImageManager &)
 
PureImageManageroperator= (const PureImageManager &)
 
virtual void WriteListCallback (const PureManaged &mngd) const
 From PureFiledManager, adding W x H x BPP.
 
- Protected Member Functions inherited from PureFiledManager
 PureFiledManager (const PureFiledManager &)
 
PureFiledManageroperator= (const PureFiledManager &)
 
- Protected Member Functions inherited from PureManager
 PureManager (const PureManager &other)
 
PureManageroperator= (const PureManager &)
 

Private Attributes

PureImageManagerImplpImpl
 

Constructor & Destructor Documentation

◆ PureImageManager() [1/2]

PureImageManager::PureImageManager ( )
Exceptions
std::bad_alloc- This class or its ancestor dynamically allocates memory with operator new, in case of failure the exception is not handled but propagated to caller.

Definition at line 276 of file PureImageManager.cpp.

◆ ~PureImageManager()

PureImageManager::~PureImageManager ( )
virtual

Definition at line 283 of file PureImageManager.cpp.

◆ PureImageManager() [2/2]

PureImageManager::PureImageManager ( const PureImageManager & )
protected

Definition at line 454 of file PureImageManager.cpp.

Member Function Documentation

◆ createBlank()

PureImage * PureImageManager::createBlank ( TPureUInt width,
TPureUInt height,
TPureUInt bpp )

Creates a blank Image object as specified.

Parameters
widthWidth of the new image. Cannot be 0.
heightHeight of the new image. Cannot be 0.
bppBits per pixel. Currently only 24 is supported.
Returns
The created Image object on success, PGENULL otherwise.

Definition at line 415 of file PureImageManager.cpp.

◆ createFromFile()

PureImage * PureImageManager::createFromFile ( const char * filename)
virtual

Creates an Image object from the given file.

Only BMP format is supported at this time. Can load any bit depth BMP in theory, but below 16 bits, the rules are the following:

  • at 8 bits (256 colors) the width of the image must be divisible by 4;
  • at 4 bits (16 colors) the width of the image must be divisible by 8;
  • at 1 bits (2 colors) the width of the image must be divisible by 32.

Note that with 32 bit BMP files you can utilize real alpha component of pixel colors, but not all image editing applications save real alpha values into 32 bit color depth bitmap files.

For example, IrfanView and MS Paint save 0 or 255 for every pixel's alpha component even if the source image was a true transparent PNG: 0 for background and 255 for foreground pixels. This can be ok in some cases, but usually not good enough from quality perspective in most cases, since the edges of a shape will look sharp.

Adobe Flash properly saves transparency data to 32 bit color depth bitmap file without any hassle.

Adobe Photoshop CS2 is a bit tricky but can work properly. If you open a transparent PNG without background, or remove background of an image, it will look transparent, but when you save that into a 32 bit depth BMP file, 0 alpha will be set for all pixels which basically makes this BMP useless for us from transparency perspective. To work around this problem, you also need to manually edit the transparency channel on the Channels tab. By default it is black (0) even when background is removed. I read the trick here: https://stackoverflow.com/questions/7369649/how-to-convert-32-bit-bmp-to-contain-alpha-channel

In Photoshop, removing the background and saving to a different format like PNG would automatically save alpha values properly without the need of manually editing the transparency channel, but for a proper BMP we need to deal with this hassle. Note that loading the true transparent BMP again in Photoshop will also work fine, although there will be white background displayed but transparency channel will be properly loaded from the 32bit BMP.

If you want to utilize transparency of 32 bit bitmaps properly, follow the instructions given in at PureMaterial::setBlendFuncs().

The BMP loader implemented in PURE is not compatible with all BMP formats, and this might lead to texture misalignment once you create texture from such BMP file and apply it to an Object3D instance. One case of such misalignment issue is if you export the BMP with color space information. Some applications like GIMP give option to skip writing color space information, so a workaround for this issue can be if you are selecting the option "Do not write color space information": https://github.com/proof88/PRooFPS-dd/issues/271 .

If you do not have such control over the BMP exporting procedure, then as another workaround you need to manually adjust the texture UV-coordinates. Texture UV-coordinates can be accessed using PureMaterial::getTexcoords(). Note that in case the geometry of your PureObject3D instance is already stored in video memory, you need to re-upload geometry to video memory after correcting the texture coordinates. This can be done by setting the already set vertex transfer mode again for the PureObject3D instace, e.g.:

PureObject3D* obj = (... create your object ...);
(... adjust texture coordinates by writing to obj.getMaterial().getTexcoords() ...);
obj.setVertexTransferMode( obj.getVertexTransferMode() );
Returns
The created Image object on success, PGENULL otherwise.

Reimplemented from PureFiledManager.

Reimplemented in PureTextureManager.

Definition at line 365 of file PureImageManager.cpp.

◆ getColorConversionSwapCount()

TPureUInt PureImageManager::getColorConversionSwapCount ( TPIXCOMPORD from,
TPIXCOMPORD to )
static

Calculates the number of swaps needed from the given color component order to the other.

Calculates the number of needed swaps needed from the given color component order to the other.

Returns
Number of swaps needed from the given color component order to the other.

Definition at line 227 of file PureImageManager.cpp.

◆ getConsole()

CConsole & PureImageManager::getConsole ( ) const

Returns access to console preset with logger module name as this class.

Intentionally not virtual, so the getConsole() in derived class should hide this instead of overriding.

Returns
Console instance used by this class.

Definition at line 296 of file PureImageManager.cpp.

◆ getLoggerModuleName()

const char * PureImageManager::getLoggerModuleName ( )
static

Returns the logger module name of this class.

Intentionally not virtual, so derived class should hide this instead of overriding. Not even private, so user can also access this from outside, for any reason like controlling log filtering per logger module name.

Returns
The logger module name of this class.

Definition at line 309 of file PureImageManager.cpp.

◆ getMirroredPixelComponentOrder()

TPIXCOMPORD PureImageManager::getMirroredPixelComponentOrder ( TPIXCOMPORD corder)
static

Transforms the given color component order to its mirrored form.

Returns
The mirrored form of the given color component order.

Definition at line 252 of file PureImageManager.cpp.

◆ operator=()

PureImageManager & PureImageManager::operator= ( const PureImageManager & )
protected

Definition at line 460 of file PureImageManager.cpp.

◆ WriteList()

void PureImageManager::WriteList ( ) const
virtual

From PureFiledManager, adding logging image size data.

Reimplemented from PureFiledManager.

Reimplemented in PureTextureManager.

Definition at line 481 of file PureImageManager.cpp.

◆ WriteListCallback()

void PureImageManager::WriteListCallback ( const PureManaged & mngd) const
protectedvirtual

From PureFiledManager, adding W x H x BPP.

Reimplemented from PureFiledManager.

Reimplemented in PureTextureManager.

Definition at line 470 of file PureImageManager.cpp.

Member Data Documentation

◆ pImpl

PureImageManagerImpl* PureImageManager::pImpl
private

Definition at line 154 of file PureImageManager.h.


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