VRay SDK for C++
Loading...
Searching...
No Matches
VRay::VRayImage Struct Reference

#include <vraysdk.hpp>

Public Types

enum  DrawMode { DRAW_MODE_COPY = 0 , DRAW_MODE_BLEND_FAST }
 
enum  IntList_DataType { bgra_byte = 0 , rgba_float = 1 , rgba_16bit = 3 , bgr_byte = 4 }
 These correspond to (some of) the values of RawBitmapBuffer::pixels_type. More...
 
enum  WhiteBalanceMode { WHITE_BALANCE_NONE , WHITE_BALANCE_AVERAGE , WHITE_BALANCE_WEIGHTED_AVERAGE , WHITE_BALANCE_HIGHLIGHTS }
 

Public Member Functions

bool addColor (const AColor &color)
 
bool addColor (const Color &color)
 
AColor calculateWhiteBalanceMultiplier (WhiteBalanceMode mode) const
 Returns a color multiplier to pass to mulColor function.
 
bool changeContrast (float contrast)
 
bool changeExposure (float ev)
 
bool changeGamma (float gamma)
 
bool changeSRGB (bool apply=true)
 
VRayImageclone () const
 
BmpcompressToBmp (bool preserveAlpha=false, bool swapChannels=false) const
 Returns a new BMP object with a copy of this image's contents. Caller has to delete it.
 
BmpcompressToBmp (const VRayRenderer &renderer, bool preserveAlpha=false, bool swapChannels=false) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
BmpcompressToBmp (size_t &size, bool preserveAlpha=false, bool swapChannels=false) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
BmpcompressToBmp (size_t &size, const VRayRenderer &renderer, bool preserveAlpha=false, bool swapChannels=false) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
JpegcompressToJpeg (const VRayRenderer &renderer, int quality=0) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
JpegcompressToJpeg (int quality=0) const
 Returns a new JPEG object with a compressed copy of this image's contents. Caller has to delete it.
 
JpegcompressToJpeg (size_t &size, const VRayRenderer &renderer, int quality=0) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
JpegcompressToJpeg (size_t &size, int quality=0) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
PngcompressToPng (bool preserveAlpha=false) const
 Returns a new PNG object with a compressed copy of this image's contents. Caller has to delete it.
 
PngcompressToPng (const VRayRenderer &renderer, bool preserveAlpha=false) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
PngcompressToPng (size_t &size, bool preserveAlpha=false) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
PngcompressToPng (size_t &size, const VRayRenderer &renderer, bool preserveAlpha=false) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
bool draw (const VRayImage *image, int x, int y, DrawMode mode=DRAW_MODE_COPY)
 
VRayImagegetCropped (int x, int y, int width, int height) const
 Returns a new cropped image. Caller has to delete it.
 
VRayImagegetCutIn (int width, int height) const
 
VRayImagegetDownscaled (int width, int height) const
 
VRayImagegetDownscaledCropped (int srcX, int srcY, int srcWidth, int srcHeight, int dstWidth, int dstHeight) const
 
VRayImagegetFitIn (int width, int height) const
 
VRayImagegetFitOut (int width, int height) const
 
float getGamma () const
 
int getHeight () const
 
AColorgetPixelData ()
 Returns a direct pointer to the image contents for in-place modification.
 
const AColorgetPixelData () const
 Returns a direct pointer to the image contents for reading.
 
AColorgetPixelData (size_t &count)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
const AColorgetPixelData (size_t &count) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
VRayImagegetResized (int width, int height) const
 Returns a new resized/rescaled image. Caller has to delete it.
 
VRayImagegetResizedCropped (int srcX, int srcY, int srcWidth, int srcHeight, int dstWidth, int dstHeight) const
 Returns a new cropped and then resized/rescaled image. Caller has to delete it.
 
bool getSize (int &width, int &height) const
 
int getWidth () const
 
bool makeNegative ()
 
bool mulColor (const AColor &color)
 
void operator delete (void *bmp)
 
bool saveToBmp (const char *fileName, bool preserveAlpha=false, bool swapChannels=false) const
 
bool saveToBmp (const char *fileName, const VRayRenderer &renderer, bool preserveAlpha=false, bool swapChannels=false) const
 
bool saveToBmp (const std::string &fileName, bool preserveAlpha=false, bool swapChannels=false) const
 
bool saveToBmp (const std::string &fileName, const VRayRenderer &renderer, bool preserveAlpha=false, bool swapChannels=false) const
 
bool saveToExr (const char *fileName) const
 
bool saveToExr (const char *fileName, const VRayRenderer &renderer) const
 
bool saveToExr (const std::string &fileName) const
 
bool saveToExr (const std::string &fileName, const VRayRenderer &renderer) const
 
bool saveToJpeg (const char *fileName, const VRayRenderer &renderer, int quality=0) const
 
bool saveToJpeg (const char *fileName, int quality=0) const
 
bool saveToJpeg (const std::string &fileName, const VRayRenderer &renderer, int quality=0) const
 
bool saveToJpeg (const std::string &fileName, int quality=0) const
 
bool saveToPng (const char *fileName, bool preserveAlpha=false, int bitsPerChannel=8) const
 
bool saveToPng (const char *fileName, const VRayRenderer &renderer, bool preserveAlpha=false, int bitsPerChannel=8) const
 
bool saveToPng (const std::string &fileName, bool preserveAlpha=false, int bitsPerChannel=8) const
 
bool saveToPng (const std::string &fileName, const VRayRenderer &renderer, bool preserveAlpha=false, int bitsPerChannel=8) const
 
bool saveToTiff (const char *fileName, const VRayRenderer &renderer, int bitsPerChannel=16) const
 
bool saveToTiff (const char *fileName, int bitsPerChannel=16) const
 
bool saveToTiff (const std::string &fileName, const VRayRenderer &renderer, int bitsPerChannel=16) const
 
bool saveToTiff (const std::string &fileName, int bitsPerChannel=16) const
 
bool setGamma (float gamma)
 
MemoryBuffertoBitmapData (size_t &size, bool preserveAlpha=false, bool swapChannels=false, bool reverseY=false, int stride=0, int alphaValue=-1) const
 
IntList toIntList (IntList_DataType type) const
 

Static Public Member Functions

static VRayImagecreate (int width, int height)
 
static VRayImagecreateFromBmp (const void *buffer, size_t size=0)
 Takes raw BMP contents including header to create a copy of the data in a new VRayImage.
 
static VRayImagecreateFromBmp (const VRayRenderer &renderer, const void *buffer, size_t size=0)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
static VRayImagecreateFromJpeg (const void *buffer, size_t size)
 Takes raw JPEG contents including header to create a copy of the data in a new VRayImage.
 
static VRayImagecreateFromJpeg (const VRayRenderer &renderer, const void *buffer, size_t size)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
static VRayImagecreateFromPng (const void *buffer, size_t size)
 Takes raw PNG contents including header to create a copy of the data in a new VRayImage.
 
static VRayImagecreateFromPng (const VRayRenderer &renderer, const void *buffer, size_t size)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
static VRayImagecreateFromRawData (const void *buffer, size_t size, IntList_DataType dataType, int width, int height)
 Takes raw pixel contents to create a copy of the data in a new VRayImage.
 
static VRayImageload (const char *fileName)
 
static VRayImageload (const std::string &fileName)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
static void loadSize (const char *fileName, int &width, int &height)
 
static void loadSize (const std::string &fileName, int &width, int &height)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 

Detailed Description

Image helper class containing raw full float32 data that can export to 8-bit formats - BMP, JPEG, PNG. It also supplies some basic image manipulation methods.

Member Enumeration Documentation

◆ DrawMode

Enumerator
DRAW_MODE_COPY 

Overwrite destination image pixels with the source image pixels.

DRAW_MODE_BLEND_FAST 

Alpha-blend using only the source image alpha but keep the original destination image alpha unchanged.

◆ IntList_DataType

These correspond to (some of) the values of RawBitmapBuffer::pixels_type.

Enumerator
rgba_float 

8-bit int BGRA

rgba_16bit 

32-bit float RGBA (sRGB or gamma won't be applied automatically)

bgr_byte 

16-bit unsigned int RGBA

Member Function Documentation

◆ changeGamma()

bool VRay::VRayImage::changeGamma ( float  gamma)

Applies a power curve to pixel values. Note that this is a color correction, not a color space conversion. Output color space conversion is applied automatically according to the value of the gamma property (see setGamma/getGamma) when saving or compressing the image.

◆ changeSRGB()

bool VRay::VRayImage::changeSRGB ( bool  apply = true)

Applies or removes an sRGB correction curve to/from this image. Note that this changes the underlying float data values and it is NOT needed when saving or compressing to 8 or 16-bit formats. Output color space conversion is applied automatically according to the value of the gamma property (see setGamma/getGamma) when saving or compressing the image (sRGB if gamma = 2.2 or any arbitrary gamma).

Parameters
applytrue - apply sRGB, false - remove sRGB.

◆ draw()

bool VRay::VRayImage::draw ( const VRayImage image,
int  x,
int  y,
DrawMode  mode = DRAW_MODE_COPY 
)

Draws the passed image over the current one at the specified position and using the specified drawing mode. If any parts of the source lie outside the current image rectangle, they get cropped.

◆ getCutIn()

VRayImage * VRay::VRayImage::getCutIn ( int  width,
int  height 
) const

Returns a new resized and eventually cropped image with exactly width x height size. Caller has to delete it. Note: The result is similar to chained getFitOut(width, height) and getCropped() calls.

◆ getDownscaled()

VRayImage * VRay::VRayImage::getDownscaled ( int  width,
int  height 
) const

Returns a new downscaled image. Caller has to delete it. Note: getResized() can both downscale and upscale.

◆ getDownscaledCropped()

VRayImage * VRay::VRayImage::getDownscaledCropped ( int  srcX,
int  srcY,
int  srcWidth,
int  srcHeight,
int  dstWidth,
int  dstHeight 
) const

Returns a new cropped and then downscaled image. Caller has to delete it. Note: getResizedCropped() can both downscale and upscale.

◆ getFitIn()

VRayImage * VRay::VRayImage::getFitIn ( int  width,
int  height 
) const

Returns a new resized image that can fit and touch inside a width x height rectangle, preserving the original aspect ratio. Caller has to delete it.

◆ getFitOut()

VRayImage * VRay::VRayImage::getFitOut ( int  width,
int  height 
) const

Returns a new resized image so that a width x height rectangle can fit inside it, and the new image touches the rectangle outside, preserving the original aspect ratio. Caller has to delete it.

◆ getGamma()

float VRay::VRayImage::getGamma ( ) const

Gets the gamma used when converting this image to 8-bit image formats. This gamma value is used by methods like compressToBmp(), compressToJpeg(), etc.

◆ load()

static VRayImage * VRay::VRayImage::load ( const char *  fileName)
static

Creates a new VRayImage from a file Supported formats: png, jpg, bmp, exr, hdr, sgi/rgb/rgba, pic, tiff, tga, psd, dds

◆ loadSize()

static void VRay::VRayImage::loadSize ( const char *  fileName,
int &  width,
int &  height 
)
static

Helper method to get image size from a file. Supported formats: png, jpg, bmp, exr, hdr, sgi/rgb/rgba, pic, tiff, tga, psd, dds

◆ setGamma()

bool VRay::VRayImage::setGamma ( float  gamma)

Sets 8-bit images output gamma. This doesn't change the underlying float data but affects the output of methods like compressToBmp(), compressToJpeg(), etc.

◆ toBitmapData()

MemoryBuffer * VRay::VRayImage::toBitmapData ( size_t &  size,
bool  preserveAlpha = false,
bool  swapChannels = false,
bool  reverseY = false,
int  stride = 0,
int  alphaValue = -1 
) const

Extracts 8-bit bitmap data from this image (without the BMP headers that compressToBmp includes). The data is a copy from this image and the caller is responsible for deleting it. Defaults to channel order BGR, no alpha, top-bottom.

Parameters
size[out] The size of the returned buffer in bytes.
preserveAlpha[in] false - BGR/RGB (bytes_per_pixel = 3), true - BGRA/RGBA (bytes_per_pixel = 4).
swapChannels[in] false - BGR(A) order, true - BRGB(A) order.
reverseY[in] false - fill top-bottom bitmap, true - fill bottom-top bitmap.
stride[in] the byte offset between the beginning of two consecutive rows of the output bitmap. if (stride > 0) use max(stride, width*bytes_per_pixel). if (stride== 0) use width*bytes_per_pixel rounded up to the smallest factor of 4 (this the default for BMP). if (stride < 0) use width*bytes_per_pixel rounded up to the smallest factor of -stride; -stride must be a power of 2.
alphaValueForce the alpha channel to the given value in the [0, 255] range. Forces BGRA/RGBA format.
Returns
A pointer to the BMP pixel data. On error, NULL pointer is returned and size == 0.

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