Image class

From Solid Graphics Wiki

(Redirected from Image)
Jump to: navigation, search
Image class
Namespace: SKL
Base type: (None)
Include: SklImage.h
Lib (Release): SKL.lib
Lib (Debug): SKL_D.lib


The Image class represents and holds data of a 2D raster image. It provides capability to load the image object from a JPEG, GIF, PNG or BMP file, to save the image object into a JPEG, GIF, PNG or BMP file, to provide access to the image pixels data to use it as OpenGL texture or Windows bitmap. The class also provides image manipulation functions, such as image resizing or replacing pixel colors.


Constructors

The class provides only basic constructors - a constructor with no parameters and a copy constructor.

Fields

Field name Type Description
defaultPixelFormat PixelFormat This is static field which defines default pixel format to be used by the Image class objects. The field value is copied into Image objects during objects construction. Individual object's pixel format can then be later changed by the SetPixelFormat method.
defaultRowOrder RowOrder This is static field which defines row order to be used by the Image class objects. The field value is copied into Image objects during objects construction. Individual object's row order can then be later changed by the SetRowOrder method.
defaultRowAlignment unsigned int This is static field which defines alignment of image row data to be used by the Image class objects. The field value is copied into Image objects during objects construction. Individual object's row alignment can then be later changed by the SetRowAlignment method.

Methods

Method name Description
Create Allocates and initializes memory for the image of specified pixel width and height.
Load Loads image data from a JPEG, BMP, GIF or a PNG file, or from memory pointer pointing to binary data in JPEG, BMP, GIF or a PNG format.
LoadThumbnail Loads thumbnail image of specified size from of a JPEG, BMP, GIF or a PNG file, or from memory pointer pointing to binary data in JPEG, BMP, GIF or a PNG format. Loading thumbnail by the LoadThumbnail method is usually several times faster than loading whole image and then resizing it to specified thumbnail size.
LoadAlphaChannel Converts data from another Image class object into alpha channel values of Image class object instance.
Save Saves image data to a file or memory using JPEG, BMP, GIF or PNG format.
Clear Releases image data memory held by the object.
Rotate Rotates image by 90, -90, 180, -180, 270 or -270 degrees.
Resize Resizes image to specified pixel width and height and saves result to another Image class object.
Copy Copies specified portion of image to another Image class object.
Paste Pastes another Image class object's content into current object's image data.
GetPixel Retrieves specified pixel data.
SetPixel Sets specified pixel data.
FillBackgroundColor Mixes specified color into the image. The image must have alpha channel specified. Fully transparent pixels will be filled with specified background color, opaque pixels will be left untouched. Color for not fully transparent/opaque pixels will be mixed with the background color depending with background color intensity dependent on the pixel transparancy value. The method then sets alpha value for each pixel to 255 (opaque).
ReplaceColor Replaces color values for pixels with specified color (or colors in specified range) to another specified color.
AdjustColorRange Adjust color range of all pixel colors in image to be between specified min and max color.
ScaleToPowerOfTwo Scales the width and height of the image to closest power of two width and height and saves the result to another Image class object.
IsEmpty Returns true if image is "empty", otherwise returns false. The image is empty after being constructed or the Clear method is called on the image object. If the image is empty it's width and height is defined as -1.
Width Returns width of the image data in pixels. If the image is "empty" then the width returned is -1.
Height Returns height of the image data in pixels. If the image is "empty" then the height returned is -1.
PixelSize Returns number of bytes used by the image object per pixel. This can be 3 for RGB or BGR pixel format, or 4 for RGBA or BGRA pixel formats.
RowSize Returns number of bytes used by the image object to store one row of image data. The returned size includes the current row allignment value (see SetRowAlignment method).
HasPowerOfTwoSize Returns true if image width and height are multiples of power of two number. Otherwise returns false.
HasAlphaChannel Returns true if the image object hase alpha channel.
Data Returns pointer to raw image data.
GetPixelFormat Returns information about pixel format currently used by the image object. This can be RGB, RGBA, BGR or BGRA..
SetPixelFormat Sets image's pixel format. If image data is already loaded into the image object then the function converts current data's pixel format to specified pixel format.
GetRowOrder Gets row order currently used by the image object. This can be either FromBottomToTop, or FromTopToBottom, or Undefined.
SetRowOrder Sets row order for current image object. If image data are already loaded into the image object then the method changes current row order to match specified row order.
GetRowAlignment Returns row allignment value currently used by the image object.
SetRowAlignment Sets row allignment value to be used by the image object. If image data are already loaded into the image object then the method modifies the image data to match specified row alignment value.
CompressionFromFileName Returns Image::Compression enum value for given file name extension.
CreateWindowsBitmap Creates Windows bitmap from the current image data.
IsWindowsBitmap Returns true if the image object is also defined as Windows bitmap. Otherwise returns false.
LoadFromDIBSection Loads the image data from specified Windows bitmap.
Draw Draws the image onto specified position of window. To use this method the application must call CreateWindowsBitmap method first.
DrawTiled Draws the image onto specified position of window as tiled image. To use this method the application must call CreateWindowsBitmap method first.

Helper functions

Method name Description
BGR Macro for creating pixel color values in BGR format from specified reg, green, blue components.
RGBtoBGR Macro to converts pixel color value from RGB to BGR format. The macro preserves the Alpha component value (if any).

Operators

= Copies one image class object to another.

See Also

   


SolidKit Library Documentation

Personal tools