Berserk
Public Types | Public Member Functions | Static Public Member Functions | List of all members
Image Class Reference

Hardware-independent image representation. More...

#include <Image.hpp>

Public Types

enum class  FileFormat { Png , Jpg , Bmp }
 Formats to save image. More...
 
using Format = RHITextureFormat
 

Public Member Functions

BRK_API Image ()=default
 
BRK_API Image (uint32 width, uint32 height, Format format)
 
BRK_API Image (uint32 width, uint32 height, uint32 stride, uint32 pixelSize, Format format, Ref< Data > pixelData)
 
BRK_API Image (const Image &)=default
 
BRK_API Image (Image &&) noexcept=default
 
BRK_API ~Image ()=default
 
BRK_API Imageoperator= (const Image &)=default
 
BRK_API Imageoperator= (Image &&) noexcept=default
 
BRK_API Image Resize (uint32 newWidth, uint32 newHeight) const
 
BRK_API bool Empty () const
 
BRK_API uint32 GetWidth () const
 
BRK_API uint32 GetHeight () const
 
BRK_API uint32 GetStride () const
 
BRK_API uint32 GetPixelSize () const
 
BRK_API uint32 GetSizeBytes () const
 
BRK_API Format GetFormat () const
 
BRK_API const Ref< Data > & GetPixelData () const
 
BRK_API bool SaveRgba (const String &filepath, FileFormat fileFormat, int quality=100) const
 Save rgba image to the file. More...
 

Static Public Member Functions

static BRK_API Image LoadRgba (const String &path, uint32 channels=4)
 Load rgba image from the disc. More...
 

Detailed Description

Hardware-independent image representation.

Image class allows to load/save image data, get access to the pixels, manipulate, transform, change data, pass pixel data to rendering-hardware for the rendering.

Member Typedef Documentation

◆ Format

Member Enumeration Documentation

◆ FileFormat

enum Image::FileFormat
strong

Formats to save image.

Enumerator
Png 
Jpg 
Bmp 

Constructor & Destructor Documentation

◆ Image() [1/5]

BRK_API Image::Image ( )
default

◆ Image() [2/5]

BRK_NS_BEGIN Image::Image ( uint32  width,
uint32  height,
Format  format 
)

◆ Image() [3/5]

Image::Image ( uint32  width,
uint32  height,
uint32  stride,
uint32  pixelSize,
Format  format,
Ref< Data pixelData 
)

◆ Image() [4/5]

BRK_API Image::Image ( const Image )
default

◆ Image() [5/5]

BRK_API Image::Image ( Image &&  )
defaultnoexcept

◆ ~Image()

BRK_API Image::~Image ( )
default

Member Function Documentation

◆ Empty()

BRK_API bool Image::Empty ( ) const
inline

◆ GetFormat()

BRK_API Format Image::GetFormat ( ) const
inline

◆ GetHeight()

BRK_API uint32 Image::GetHeight ( ) const
inline

◆ GetPixelData()

BRK_API const Ref<Data>& Image::GetPixelData ( ) const
inline

◆ GetPixelSize()

BRK_API uint32 Image::GetPixelSize ( ) const
inline

◆ GetSizeBytes()

BRK_API uint32 Image::GetSizeBytes ( ) const
inline

◆ GetStride()

BRK_API uint32 Image::GetStride ( ) const
inline

◆ GetWidth()

BRK_API uint32 Image::GetWidth ( ) const
inline

◆ LoadRgba()

Image Image::LoadRgba ( const String path,
uint32  channels = 4 
)
static

Load rgba image from the disc.

Note
Use engine file system class to retrieve correct and full path to file.
Parameters
pathPath to the image file
channelsNumber of channels to load; must be within {1,2,3,4}
Returns
Loaded image; empty if failed

◆ operator=() [1/2]

BRK_API Image& Image::operator= ( const Image )
default

◆ operator=() [2/2]

BRK_API Image& Image::operator= ( Image &&  )
defaultnoexcept

◆ Resize()

Image Image::Resize ( uint32  newWidth,
uint32  newHeight 
) const

◆ SaveRgba()

bool Image::SaveRgba ( const String filepath,
FileFormat  fileFormat,
int  quality = 100 
) const

Save rgba image to the file.

Note
Use engine file system class to retrieve correct and full path to file.
Parameters
filepathPath to the file to save
fileFormatImage format to save
qualityImage quality; must be within [1..100]
Returns
True if saved

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