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

Interface for software image data. More...

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

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

Public Member Functions

 IImage (ECOLOR_FORMAT format, const dcpp::nub::dimension2du &size, bool deleteMemory)
 constructor
 
virtual ~IImage ()
 destructor
 
ECOLOR_FORMAT getColorFormat () const
 Returns the color format.
 
const dcpp::nub::dimension2dugetDimension () const
 Returns width and height of image data.
 
dcpp::uint32_kt getBitsPerPixel () const
 Returns bits per pixel.
 
dcpp::uint32_kt getBytesPerPixel () const
 Returns bytes per pixel.
 
size_t getImageDataSizeInBytes () const
 Returns image data size in bytes.
 
dcpp::uint32_kt getImageDataSizeInPixels () const
 Returns image data size in pixels.
 
dcpp::uint32_kt getPitch () const
 Returns pitch of image.
 
dcpp::uint32_kt getRedMask () const
 Returns mask for red value of a pixel.
 
dcpp::uint32_kt getGreenMask () const
 Returns mask for green value of a pixel.
 
dcpp::uint32_kt getBlueMask () const
 Returns mask for blue value of a pixel.
 
dcpp::uint32_kt getAlphaMask () const
 Returns mask for alpha value of a pixel.
 
void * getData () const
 Use this to get a pointer to the image data.
 
DCPP_DEPRECATED void * lock ()
 Lock function. Use this to get a pointer to the image data.
 
DCPP_DEPRECATED void unlock ()
 Unlock function.
 
dcpp::nub::dimension2du getMipMapsSize (dcpp::uint32_kt mipmapLevel) const
 Get the mipmap size for this image for a certain mipmap level.
 
void * getMipMapsData (dcpp::uint32_kt mipLevel=1) const
 Get mipmaps data.
 
void setMipMapsData (void *data, bool ownForeignMemory, bool deleteMemory)
 Set mipmaps data.
 
virtual SColor getPixel (dcpp::uint32_kt x, dcpp::uint32_kt y) const =0
 Returns a pixel.
 
virtual void setPixel (dcpp::uint32_kt x, dcpp::uint32_kt y, const SColor &color, bool blend=false)=0
 Sets a pixel.
 
virtual void copyToScaling (void *target, dcpp::uint32_kt width, dcpp::uint32_kt height, ECOLOR_FORMAT format=ECF_A8R8G8B8, dcpp::uint32_kt 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 dcpp::nub::position2di &pos=dcpp::nub::position2di(0, 0))=0
 copies this surface into another
 
virtual void copyTo (IImage *target, const dcpp::nub::position2di &pos, const dcpp::nub::recti &sourceRect, const dcpp::nub::recti *clipRect=0)=0
 copies this surface into another
 
virtual void copyToWithAlpha (IImage *target, const dcpp::nub::position2di &pos, const dcpp::nub::recti &sourceRect, const SColor &color, const dcpp::nub::recti *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, dcpp::int32_kt 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
 
DCPP_DEPRECATED bool isCompressed () const
 Inform whether the image is compressed.
 
DCPP_DEPRECATED bool hasMipMaps () const
 Check whether the image has MipMaps.
 
- Public Member Functions inherited from dcpp::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.
 
dcpp::int32_kt getReferenceCount () const
 Get the reference count.
 
const dcpp::char_ktgetDebugName () const
 Returns the debug name of the object.
 

Static Public Member Functions

static dcpp::nub::dimension2du getMipMapsSize (const dcpp::nub::dimension2du &sizeLevel0, dcpp::uint32_kt mipmapLevel)
 Calculate mipmap size for a certain level.
 
static dcpp::uint32_kt 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, dcpp::uint32_kt width, dcpp::uint32_kt 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
 
dcpp::nub::dimension2du Size
 
dcpp::uint8_ktData
 
dcpp::uint8_ktMipMapsData
 
dcpp::uint32_kt BytesPerPixel
 
dcpp::uint32_kt Pitch
 
bool DeleteMemory
 
bool DeleteMipMapsMemory
 
dcpp::nub::irrAllocator< dcpp::uint8_ktAllocator
 

Additional Inherited Members

- Protected Member Functions inherited from dcpp::IReferenceCounted
void setDebugName (const dcpp::char_kt *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 dcpp::video::IImage::checkDataSizeLimit ( size_t  dataSize)
inlinestatic

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

Note that PImage 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 dcpp::uint32_kt too early.

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

◆ copyTo() [1/2]

virtual void dcpp::video::IImage::copyTo ( IImage target,
const dcpp::nub::position2di pos,
const dcpp::nub::recti sourceRect,
const dcpp::nub::recti clipRect = 0 
)
pure virtual

copies this surface into another

NOTE: mipmaps are ignored

◆ copyTo() [2/2]

virtual void dcpp::video::IImage::copyTo ( IImage target,
const dcpp::nub::position2di pos = dcpp::nub::position2di(0, 0) 
)
pure virtual

copies this surface into another

NOTE: mipmaps are ignored

◆ copyToScaling() [1/2]

virtual void dcpp::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 dcpp::video::IImage::copyToScaling ( void *  target,
dcpp::uint32_kt  width,
dcpp::uint32_kt  height,
ECOLOR_FORMAT  format = ECF_A8R8G8B8,
dcpp::uint32_kt  pitch = 0 
)
pure virtual

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

NOTE: mipmaps are ignored

◆ copyToScalingBoxFilter()

virtual void dcpp::video::IImage::copyToScalingBoxFilter ( IImage target,
dcpp::int32_kt  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 dcpp::video::IImage::copyToWithAlpha ( IImage target,
const dcpp::nub::position2di pos,
const dcpp::nub::recti sourceRect,
const SColor color,
const dcpp::nub::recti 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 dcpp::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 * dcpp::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 dcpp::uint32_kt.

◆ getMipMapsData()

void * dcpp::video::IImage::getMipMapsData ( dcpp::uint32_kt  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 dcpp::nub::dimension2du dcpp::video::IImage::getMipMapsSize ( const dcpp::nub::dimension2du sizeLevel0,
dcpp::uint32_kt  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]

dcpp::nub::dimension2du dcpp::video::IImage::getMipMapsSize ( dcpp::uint32_kt  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()

DCPP_DEPRECATED bool dcpp::video::IImage::hasMipMaps ( ) const
inline

Check whether the image has MipMaps.

Returns
True if image has MipMaps, else false.

◆ lock()

DCPP_DEPRECATED void * dcpp::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 dcpp::uint32_kt. Be sure to call unlock() after you don't need the pointer any more.

◆ setMipMapsData()

void dcpp::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()

DCPP_DEPRECATED void dcpp::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:

Duckcpp    @cppfx.xyz