VRay SDK for C#
|
Inherits IDisposable, ICloneable, IList< AColor >, and IList.
Classes | |
struct | AColorUinion |
class | VRayImageEnumerator |
Public Types | |
enum | DrawMode |
enum | IntList_DataType |
These correspond to (some of) the values of RawBitmapBuffer::pixels_type. | |
enum | WhiteBalanceMode |
Public Member Functions | |
bool | AddColor (AColor color) |
Adds the given color to every pixel | |
bool | AddColor (Color color) |
Adds the given color to every pixel | |
AColor | CalculateWhiteBalanceMultiplier (WhiteBalanceMode mode) |
Returns a color multiplier to pass to MulColor function. More... | |
bool | ChangeContrast (float contrast) |
Changes pixels' contrast More... | |
bool | ChangeExposure (float ev) |
Changes pixels' intensities More... | |
bool | ChangeGamma (float gamma) |
Applies a power function to pixel values More... | |
bool | ChangeSRGB (bool apply=true) |
Applies or removes an sRGB correction curve to/from this image More... | |
object | Clone () |
byte[] | CompressToBMP (bool preserveAlpha=false, bool swapChannels=false) |
Gets the raw image byte data. More... | |
byte[] | CompressToJPEG (int quality=0) |
Compresses the V-Ray image in JPEG format. More... | |
byte[] | CompressToPNG (bool preserveAlpha=false, int bitsPerChannel=8) |
Compresses the V-Ray image in PNG format. More... | |
void | Dispose () |
bool | Draw (VRayImage image, int x, int y, DrawMode mode=DrawMode.COPY) |
Draws the passed image over the current one at the specified coordinates using the specified drawing mode More... | |
VRayImage | GetCropped (int x, int y, int width, int height) |
Returns a cropped sub-image. More... | |
VRayImage | GetCutIn (int width, int height) |
Resizes the image preserving the image width/height ratio so that one of its sides is equal to the corresponding size passed in and the other is greater or equal to the other passed size. Then the image is cropped to fit the required size. Returns a new image, does not modify the source one. More... | |
VRayImage | GetDownscaled (int width, int height) |
Shrinks the image to the specified size without preserving the width/height ratio. Note that GetResized() can do both downscaling and upscaling. More... | |
VRayImage | GetDownscaledCropped (int srcX, int srcY, int srcWidth, int srcHeight, int dstWidth, int dstHeight) |
Shrinks the image to the specified size without preserving the width/height ratio. More... | |
IEnumerator< AColor > | GetEnumerator () |
VRayImage | GetFitIn (int width, int height) |
Resizes the image to fit and touch inside the width x height rectangle, preserving the image aspect ratio. The actual width and height of the new image may be different from the specified dimensions depending on the ratio. Returns a new image, does not modify the source one. More... | |
VRayImage | GetFitOut (int width, int height) |
Resizes the image preserving the image width/height ratio so that one of its sides is equal to the corresponding size passed in and the other is greater or equal to the other passed size (touch outside the width x height rectangle). Returns a new image, does not modify the source one. More... | |
AColor[] | GetPixelData () |
Returns a copy of the VRayImage pixel data. More... | |
IntPtr | GetRawPixelDataPtr () |
Returns a ponter to the internal unmanged VRayImage pixel data which consists of 4 floats (RGBA order) for each pixel. Use the data with extreme caution and keep the object alive! There is no need to free the memory - it will be automatically freed when Dispose() method is called or when the object is garbage collected. More... | |
VRayImage | GetResized (int width, int height) |
Resizes the image to the specified size without preserving the width/height ratio. More... | |
VRayImage | GetResizedCropped (int srcX, int srcY, int srcWidth, int srcHeight, int dstWidth, int dstHeight) |
Crops and resizes the image to the specified size without preserving the width/height ratio. More... | |
bool | MakeNegative () |
Changes colors to their complementary colors More... | |
bool | MulColor (AColor color) |
Multiplies the given color to every pixel | |
bool | SaveToBMP (string fileName, bool preserveAlpha=false, bool swapChannels=false) |
Saves the V-Ray image to the specified file as a BMP. More... | |
bool | SaveToEXR (string fileName) |
Saves the V-Ray image to the specified file as a EXR. More... | |
bool | SaveToFile (string formatName, string fileName) |
Saves the V-Ray image to the specified file compressed in the specified format. More... | |
bool | SaveToJPEG (string fileName, int quality=0) |
Saves the V-Ray image to the specified file as a JPEG. More... | |
bool | SaveToPNG (string fileName, bool preserveAlpha=false, int bitsPerChannel=8) |
Saves the V-Ray image to the specified file as a PNG. More... | |
bool | SaveToTIFF (string fileName, int bitsPerChannel=16) |
Saves the V-Ray image to the specified file as a TIFF. More... | |
byte[] | ToBitmapData (bool preserveAlpha=false, bool swapChannels=false, bool reverseY=false, int stride=0, int alphaValue=-1) |
Extracts 8-bit bitmap data from this image (without BMP headers). Default channel order is BGR, no alpha, top-bottom. More... | |
Stream | ToBitmapStream (bool preserveAlpha=false) |
Returns a stream from bitmap bytes copy of this image. You can create a Bitmap from it: new System.Drawing.Bitmap(stream); More... | |
IList< int > | ToIntList (IntList_DataType type) |
Static Public Member Functions | |
static VRayImage | Create (int width, int height) |
Allocate memory for an image | |
static VRayImage | CreateFromBuffer (byte[] buffer, string format, VRayRenderer renderer=null) |
Creates a V-Ray from data hold or compressed in the specified format. More... | |
static VRayImage | Load (string fileName) |
Creates a new VRayImage from a file Supported formats: png, jpg, bmp, exr, hdr, sgi/rgb/rgba, pic, tiff, tga, psd, dds More... | |
static void | LoadSize (string fileName, out int width, out int height) |
Helper method to get image size from a file. Supported formats: png, jpg, bmp, exr, hdr, sgi/rgb/rgba, pic, tiff, tga, psd, dds More... | |
Static Public Attributes | |
const string | TypeBMP = "bmp" |
const string | TypeEXR = "exr" |
const string | TypeJPG = "jpg" |
const string | TypePNG = "png" |
const string | TypeTIF = "tif" |
Properties | |
float | Gamma [get, set] |
Gets/Sets 8-bit images output gamma. This doesn't change the underlying float data but affects the output of methods like ToBMP(), ToJPEG(), etc. | |
int | Height [get] |
Gets image height. | |
long | PixelCount [get] |
Gets the number of pixels in this image. | |
AColor | this[int index] [get, set] |
Access internal AColor data directly. More... | |
AColor | this[long index] [get, set] |
Access internal AColor data directly. More... | |
int | Width [get] |
Gets image width. | |
AColor VRay.VRayImage.CalculateWhiteBalanceMultiplier | ( | WhiteBalanceMode | mode | ) |
Returns a color multiplier to pass to MulColor function.
mode |
bool VRay.VRayImage.ChangeContrast | ( | float | contrast | ) |
Changes pixels' contrast
contrast | (-1.0 - +1.0) |
bool VRay.VRayImage.ChangeExposure | ( | float | ev | ) |
Changes pixels' intensities
ev | A relative exposure value |
bool VRay.VRayImage.ChangeGamma | ( | float | gamma | ) |
Applies a power function to pixel values
gamma | Power value |
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 when saving or compressing the image.
bool VRay.VRayImage.ChangeSRGB | ( | bool | apply = true | ) |
Applies or removes an sRGB correction curve to/from this image
apply | true - apply sRGB, false - remove sRGB |
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 when saving or compressing the image (sRGB if gamma=2.2 or any arbitrary gamma).
byte[] VRay.VRayImage.CompressToBMP | ( | bool | preserveAlpha = false , |
bool | swapChannels = false |
||
) |
Gets the raw image byte data.
preserveAlpha | True if the alpha channel (opacity) should be preserved. |
swapChannels | True if the image should be saved as RGB, false for BGR. False by default |
byte[] VRay.VRayImage.CompressToJPEG | ( | int | quality = 0 | ) |
Compresses the V-Ray image in JPEG format.
quality | The quality level of the compression. |
byte[] VRay.VRayImage.CompressToPNG | ( | bool | preserveAlpha = false , |
int | bitsPerChannel = 8 |
||
) |
Compresses the V-Ray image in PNG format.
preserveAlpha | True if the alpha channel (opacity) should be preserved. |
bitsPerChannel | Number of bits for each channel (8 or 16). Default is 8. |
|
static |
Creates a V-Ray from data hold or compressed in the specified format.
buffer | The input data. |
format | The format which holds the data ("bmp", "png", "jpg" or "jpeg"). |
renderer | An optional VRayRenderer instance whose MessageLogged event handler to use. |
bool VRay.VRayImage.Draw | ( | VRayImage | image, |
int | x, | ||
int | y, | ||
DrawMode | mode = DrawMode.COPY |
||
) |
Draws the passed image over the current one at the specified coordinates using the specified drawing mode
image | The image to draw over this one. |
x | The x-coordinate at which to draw. |
y | The y-coordinate at which to draw. |
mode | The drawing mode. |
VRayImage VRay.VRayImage.GetCropped | ( | int | x, |
int | y, | ||
int | width, | ||
int | height | ||
) |
Returns a cropped sub-image.
x | The x-coordinate within the source image. |
y | The y-coordinate within the source image. |
width | The width of the new image. |
height | The height the new image. |
VRayImage VRay.VRayImage.GetCutIn | ( | int | width, |
int | height | ||
) |
Resizes the image preserving the image width/height ratio so that one of its sides is equal to the corresponding size passed in and the other is greater or equal to the other passed size. Then the image is cropped to fit the required size. Returns a new image, does not modify the source one.
width | The target width of the new image. |
height | The target height of the new image. |
VRayImage VRay.VRayImage.GetDownscaled | ( | int | width, |
int | height | ||
) |
Shrinks the image to the specified size without preserving the width/height ratio. Note that GetResized() can do both downscaling and upscaling.
width | The target width of the new image. |
height | The target height of the new image. |
VRayImage VRay.VRayImage.GetDownscaledCropped | ( | int | srcX, |
int | srcY, | ||
int | srcWidth, | ||
int | srcHeight, | ||
int | dstWidth, | ||
int | dstHeight | ||
) |
Shrinks the image to the specified size without preserving the width/height ratio.
srcX | The x-coordinate within the source image. |
srcY | The y-coordinate within the source image. |
srcWidth | The width of the sub-image within the source one. |
srcHeight | The height of the sub-image within the source one. |
dstWidth | The width of the new image. |
dstHeight | The height the new image. |
VRayImage VRay.VRayImage.GetFitIn | ( | int | width, |
int | height | ||
) |
Resizes the image to fit and touch inside the width x height rectangle, preserving the image aspect ratio. The actual width and height of the new image may be different from the specified dimensions depending on the ratio. Returns a new image, does not modify the source one.
width | The target width of the new image. |
height | The target height of the new image. |
VRayImage VRay.VRayImage.GetFitOut | ( | int | width, |
int | height | ||
) |
Resizes the image preserving the image width/height ratio so that one of its sides is equal to the corresponding size passed in and the other is greater or equal to the other passed size (touch outside the width x height rectangle). Returns a new image, does not modify the source one.
width | The target width of the new image. |
height | The target height of the new image. |
AColor[] VRay.VRayImage.GetPixelData | ( | ) |
Returns a copy of the VRayImage pixel data.
Usually (but not always) the data is linear and not sRGB or gamma corrected. This depends on VRayRenderer and the containing scene settings but the default is linear.
IntPtr VRay.VRayImage.GetRawPixelDataPtr | ( | ) |
Returns a ponter to the internal unmanged VRayImage pixel data which consists of 4 floats (RGBA order) for each pixel. Use the data with extreme caution and keep the object alive! There is no need to free the memory - it will be automatically freed when Dispose() method is called or when the object is garbage collected.
Usually (but not always) the data is linear and not sRGB or gamma corrected. This depends on VRayRenderer and the containing scene settings but the default is linear.
VRayImage VRay.VRayImage.GetResized | ( | int | width, |
int | height | ||
) |
Resizes the image to the specified size without preserving the width/height ratio.
width | The target width of the new image. |
height | The target height of the new image. |
VRayImage VRay.VRayImage.GetResizedCropped | ( | int | srcX, |
int | srcY, | ||
int | srcWidth, | ||
int | srcHeight, | ||
int | dstWidth, | ||
int | dstHeight | ||
) |
Crops and resizes the image to the specified size without preserving the width/height ratio.
srcX | The x-coordinate within the source image. |
srcY | The y-coordinate within the source image. |
srcWidth | The width of the sub-image within the source one. |
srcHeight | The height of the sub-image within the source one. |
dstWidth | The width of the new image. |
dstHeight | The height the new image. |
|
static |
|
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
fileName | The source file path. |
width | Width output parameter. |
height | Height output parameter. |
bool VRay.VRayImage.MakeNegative | ( | ) |
Changes colors to their complementary colors
bool VRay.VRayImage.SaveToBMP | ( | string | fileName, |
bool | preserveAlpha = false , |
||
bool | swapChannels = false |
||
) |
Saves the V-Ray image to the specified file as a BMP.
fileName | The destination file path. |
preserveAlpha | True if the alpha channel (opacity) should be preserved. |
swapChannels | True if the image should be saved as RGB, false for BGR. False by default |
bool VRay.VRayImage.SaveToEXR | ( | string | fileName | ) |
Saves the V-Ray image to the specified file as a EXR.
fileName | The destination file path. |
bool VRay.VRayImage.SaveToFile | ( | string | formatName, |
string | fileName | ||
) |
Saves the V-Ray image to the specified file compressed in the specified format.
formatName | The compression type specified as a String ("bmp", "png", "jpg" ("jpeg"), "tif" ("tiff") or "exr"). |
fileName | The destination file path. |
bool VRay.VRayImage.SaveToJPEG | ( | string | fileName, |
int | quality = 0 |
||
) |
Saves the V-Ray image to the specified file as a JPEG.
quality | The quality level of the compression. |
fileName | The destination file path. |
bool VRay.VRayImage.SaveToPNG | ( | string | fileName, |
bool | preserveAlpha = false , |
||
int | bitsPerChannel = 8 |
||
) |
Saves the V-Ray image to the specified file as a PNG.
fileName | The destination file path. |
preserveAlpha | True if the alpha channel (opacity) should be preserved. |
bitsPerChannel | Number of bits for each channel (8 or 16). Default is 8. |
bool VRay.VRayImage.SaveToTIFF | ( | string | fileName, |
int | bitsPerChannel = 16 |
||
) |
Saves the V-Ray image to the specified file as a TIFF.
fileName | The destination file path. |
bitsPerChannel | Number of bits for each channel (8, 16 or 32). Default is 16. |
byte[] VRay.VRayImage.ToBitmapData | ( | bool | preserveAlpha = false , |
bool | swapChannels = false , |
||
bool | reverseY = false , |
||
int | stride = 0 , |
||
int | alphaValue = -1 |
||
) |
Extracts 8-bit bitmap data from this image (without BMP headers). Default channel order is BGR, no alpha, top-bottom.
preserveAlpha | Include the alpha channel in the resultant bitmap. false - BGR/RGB (3 bytes per pixel), true - BGRA/RGBA (4 bytes per pixel) |
swapChannels | Swap red and blue channel. false - BGR(A) order, true - RGB(A) order |
reverseY | Reverse Y-axis. false - fill top-bottom bitmap, true - fill bottom-top bitmap |
stride | 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. |
alphaValue | Force the alpha channel to the given value in the [0, 255] range. Forces BGRA/RGBA format. |
Stream VRay.VRayImage.ToBitmapStream | ( | bool | preserveAlpha = false | ) |
Returns a stream from bitmap bytes copy of this image. You can create a Bitmap from it: new System.Drawing.Bitmap(stream);
|
getset |
Access internal AColor data directly.
Usually (but not always) the data is linear and not sRGB or gamma corrected. This depends on VRayRenderer and the containing scene settings but the default is linear.
index | The index of the pixel |
|
getset |
Access internal AColor data directly.
Usually (but not always) the data is linear and not sRGB or gamma corrected. This depends on VRayRenderer and the containing scene settings but the default is linear.
index | The index of the pixel |