Nirtcpp 2.1.0
Nirtcpp is a high-performance c++ graphics engine.
Loading...
Searching...
No Matches
nirt::video::IImage Class Referenceabstract

Interface for software image data. More...

#include <nirtcpp/core/engine/IImage.hpp>

Inheritance diagram for nirt::video::IImage:
Inheritance graph
Collaboration diagram for nirt::video::IImage:
Collaboration graph

Public Member Functions

 IImage (ECOLOR_FORMAT format, const core::dimension2d< u32 > &size, bool deleteMemory)
 constructor
 
virtual ~IImage ()
 destructor
 
ECOLOR_FORMAT getColorFormat () const
 Returns the color format.
 
const core::dimension2d< u32 > & getDimension () const
 Returns width and height of image data.
 
u32 getBitsPerPixel () const
 Returns bits per pixel.
 
u32 getBytesPerPixel () const
 Returns bytes per pixel.
 
size_t getImageDataSizeInBytes () const
 Returns image data size in bytes.
 
u32 getImageDataSizeInPixels () const
 Returns image data size in pixels.
 
u32 getPitch () const
 Returns pitch of image.
 
u32 getRedMask () const
 Returns mask for red value of a pixel.
 
u32 getGreenMask () const
 Returns mask for green value of a pixel.
 
u32 getBlueMask () const
 Returns mask for blue value of a pixel.
 
u32 getAlphaMask () const
 Returns mask for alpha value of a pixel.
 
void * getData () const
 Use this to get a pointer to the image data.
 
NIRT_DEPRECATED void * lock ()
 Lock function. Use this to get a pointer to the image data.
 
NIRT_DEPRECATED void unlock ()
 Unlock function.
 
core::dimension2du getMipMapsSize (u32 mipmapLevel) const
 Get the mipmap size for this image for a certain mipmap level.
 
void * getMipMapsData (nirt::u32 mipLevel=1) const
 Get mipmaps data.
 
void setMipMapsData (void *data, bool ownForeignMemory, bool deleteMemory)
 Set mipmaps data.
 
virtual SColor getPixel (u32 x, u32 y) const =0
 Returns a pixel.
 
virtual void setPixel (u32 x, u32 y, const SColor &color, bool blend=false)=0
 Sets a pixel.
 
virtual void copyToScaling (void *target, u32 width, u32 height, ECOLOR_FORMAT format=ECF_A8R8G8B8, u32 pitch=0)=0
 Copies the image into the target, scaling the image to fit.
 
virtual void copyToScaling (IImage *target)=0
 Copies the image into the target, scaling the image to fit.
 
virtual void copyTo (IImage *target, const core::position2d< s32 > &pos=core::position2d< s32 >(0, 0))=0
 copies this surface into another
 
virtual void copyTo (IImage *target, const core::position2d< s32 > &pos, const core::rect< s32 > &sourceRect, const core::rect< s32 > *clipRect=0)=0
 copies this surface into another
 
virtual void copyToWithAlpha (IImage *target, const core::position2d< s32 > &pos, const core::rect< s32 > &sourceRect, const SColor &color, const core::rect< s32 > *clipRect=0, bool combineAlpha=false)=0
 copies this surface into another, using the alpha mask and cliprect and a color to add with
 
virtual void copyToScalingBoxFilter (IImage *target, s32 bias=0, bool blend=false)=0
 copies this surface into another, scaling it to fit, applying a box filter
 
virtual void flip (bool topBottom, bool leftRight)=0
 Flips (mirrors) the image in one or two directions.
 
virtual void fill (const SColor &color)=0
 fills the surface with given color
 
NIRT_DEPRECATED bool isCompressed () const
 Inform whether the image is compressed.
 
NIRT_DEPRECATED bool hasMipMaps () const
 Check whether the image has MipMaps.
 
- Public Member Functions inherited from nirt::IReferenceCounted
 IReferenceCounted ()
 Constructor.
 
virtual ~IReferenceCounted ()
 Destructor.
 
void grab () const
 Grabs the object. Increments the reference counter by one.
 
bool drop () const
 Drops the object. Decrements the reference counter by one.
 
s32 getReferenceCount () const
 Get the reference count.
 
const c8getDebugName () const
 Returns the debug name of the object.
 

Static Public Member Functions

static core::dimension2du getMipMapsSize (const core::dimension2du &sizeLevel0, u32 mipmapLevel)
 Calculate mipmap size for a certain level.
 
static u32 getBitsPerPixelFromFormat (const ECOLOR_FORMAT format)
 get the amount of Bits per Pixel of the given color format
 
static bool checkDataSizeLimit (size_t dataSize)
 You should not create images where the result of getDataSizeFromFormat doesn't pass this function.
 
static size_t getDataSizeFromFormat (ECOLOR_FORMAT format, u32 width, u32 height)
 calculate image data size in bytes for selected format, width and height.
 
static bool isCompressedFormat (const ECOLOR_FORMAT format)
 check if this is compressed color format
 
static bool isDepthFormat (const ECOLOR_FORMAT format)
 check if the color format is only viable for depth/stencil textures
 
static bool isFloatingPointFormat (const ECOLOR_FORMAT format)
 Check if the color format uses floating point values for pixels.
 

Protected Attributes

ECOLOR_FORMAT Format
 
core::dimension2d< u32Size
 
u8Data
 
u8MipMapsData
 
u32 BytesPerPixel
 
u32 Pitch
 
bool DeleteMemory
 
bool DeleteMipMapsMemory
 
core::irrAllocator< u8Allocator
 

Additional Inherited Members

- Protected Member Functions inherited from nirt::IReferenceCounted
void setDebugName (const c8 *newName)
 Sets the debug name of the object.
 

Detailed Description

Interface for software image data.

Image loaders create these images from files. IVideoDrivers convert these images into their (hardware) textures. NOTE: Floating point formats are not well supported yet. Basically only getData() works for them.

Member Function Documentation

◆ checkDataSizeLimit()

static bool nirt::video::IImage::checkDataSizeLimit ( size_t  dataSize)
inlinestatic

You should not create images where the result of getDataSizeFromFormat doesn't pass this function.

Note that CImage does not yet check for this, but going beyond this limit is not supported well. Image loaders should check for this. If you don't have the format yet then checking width*height*bytes_per_pixel is mostly fine, but make sure to work with size_t so it doesn't clip the result to u32 too early.

Returns
true when dataSize is small enough that it should be fine.

◆ copyTo() [1/2]

virtual void nirt::video::IImage::copyTo ( IImage target,
const core::position2d< s32 > &  pos,
const core::rect< s32 > &  sourceRect,
const core::rect< s32 > *  clipRect = 0 
)
pure virtual

copies this surface into another

NOTE: mipmaps are ignored

◆ copyTo() [2/2]

virtual void nirt::video::IImage::copyTo ( IImage target,
const core::position2d< s32 > &  pos = core::position2d< s32 >(0, 0) 
)
pure virtual

copies this surface into another

NOTE: mipmaps are ignored

◆ copyToScaling() [1/2]

virtual void nirt::video::IImage::copyToScaling ( IImage target)
pure virtual

Copies the image into the target, scaling the image to fit.

NOTE: mipmaps are ignored

◆ copyToScaling() [2/2]

virtual void nirt::video::IImage::copyToScaling ( void *  target,
u32  width,
u32  height,
ECOLOR_FORMAT  format = ECF_A8R8G8B8,
u32  pitch = 0 
)
pure virtual

Copies the image into the target, scaling the image to fit.

NOTE: mipmaps are ignored

◆ copyToScalingBoxFilter()

virtual void nirt::video::IImage::copyToScalingBoxFilter ( IImage target,
s32  bias = 0,
bool  blend = false 
)
pure virtual

copies this surface into another, scaling it to fit, applying a box filter

NOTE: mipmaps are ignored

◆ copyToWithAlpha()

virtual void nirt::video::IImage::copyToWithAlpha ( IImage target,
const core::position2d< s32 > &  pos,
const core::rect< s32 > &  sourceRect,
const SColor color,
const core::rect< s32 > *  clipRect = 0,
bool  combineAlpha = false 
)
pure virtual

copies this surface into another, using the alpha mask and cliprect and a color to add with

NOTE: mipmaps are ignored

Parameters
combineAlpha- When true then combine alpha channels. When false replace target image alpha with source image alpha.

◆ flip()

virtual void nirt::video::IImage::flip ( bool  topBottom,
bool  leftRight 
)
pure virtual

Flips (mirrors) the image in one or two directions.

Parameters
topBottomFlip around central x-axis (vertical flipping)
leftRightFlip around central y-axis (typical mirror, horizontal flipping)

◆ getData()

void * nirt::video::IImage::getData ( ) const
inline

Use this to get a pointer to the image data.

Returns
Pointer to the image data. What type of data is pointed to depends on the color format of the image. For example if the color format is ECF_A8R8G8B8, it is of u32.

◆ getMipMapsData()

void * nirt::video::IImage::getMipMapsData ( nirt::u32  mipLevel = 1) const
inline

Get mipmaps data.

Note that different mip levels are just behind each other in memory block. So if you just get level 1 you also have the data for all other levels. There is no level 0 - use getData to get the original image data.

◆ getMipMapsSize() [1/2]

static core::dimension2du nirt::video::IImage::getMipMapsSize ( const core::dimension2du sizeLevel0,
u32  mipmapLevel 
)
inlinestatic

Calculate mipmap size for a certain level.

level 0 will be full image size. Every further level is half the size.

◆ getMipMapsSize() [2/2]

core::dimension2du nirt::video::IImage::getMipMapsSize ( u32  mipmapLevel) const
inline

Get the mipmap size for this image for a certain mipmap level.

level 0 will be full image size. Every further level is half the size. Doesn't care if the image actually has mipmaps, just which size would be needed.

◆ hasMipMaps()

NIRT_DEPRECATED bool nirt::video::IImage::hasMipMaps ( ) const
inline

Check whether the image has MipMaps.

Returns
True if image has MipMaps, else false.

◆ lock()

NIRT_DEPRECATED void * nirt::video::IImage::lock ( )
inline

Lock function. Use this to get a pointer to the image data.

Use getData instead.

Returns
Pointer to the image data. What type of data is pointed to depends on the color format of the image. For example if the color format is ECF_A8R8G8B8, it is of u32. Be sure to call unlock() after you don't need the pointer any more.

◆ setMipMapsData()

void nirt::video::IImage::setMipMapsData ( void *  data,
bool  ownForeignMemory,
bool  deleteMemory 
)
inline

Set mipmaps data.

This method allows you to put custom mipmaps data for image.

Parameters
dataA byte array with pixel color information
ownForeignMemoryIf true, the image will use the data pointer directly and own it afterward. If false, the memory will by copied internally.
deleteMemoryWhether the memory is deallocated upon destruction.

◆ unlock()

NIRT_DEPRECATED void nirt::video::IImage::unlock ( )
inline

Unlock function.

Should be called after the pointer received by lock() is not needed anymore.


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

Nirtcpp    @cppfx.xyz

Esvcpp    esv::print