Table of Contents

Class GenericImage

Namespace
Alternet.Drawing
Assembly
Alternet.UI.Common.dll

Implements platform independent image.

public class GenericImage : HandledObject<IGenericImageHandler>, IBaseObject, IDisposableObject, IDisposable, INotifyPropertyChanged
Inheritance
GenericImage
Implements

Constructors

GenericImage()

Initializes a new instance of the GenericImage class. Creates an empty image without an alpha channel.

GenericImage(IGenericImageHandler)

Initializes a new instance of the GenericImage class.

GenericImage(SizeI, bool)

Initializes a new instance of the GenericImage class. Creates an image with the given size and clears it if requested. Does not create an alpha channel.

GenericImage(Stream, BitmapType, int)

Initializes a new instance of the GenericImage class. Creates an image from a stream.

GenericImage(Stream, string, int)

Initializes a new instance of the GenericImage class. Creates an image from a stream.

GenericImage(int, int, RGBValue[])

Initializes a new instance of the GenericImage class. Creates an image from data in memory.

GenericImage(int, int, RGBValue[], byte[])

Initializes a new instance of the GenericImage class. Creates an image from data in memory.

GenericImage(int, int, SKColor[])

Initializes a new instance of the GenericImage class. Creates an image from data in memory.

GenericImage(int, int, bool)

Initializes a new instance of the GenericImage class. Creates an image with the given size and clears it if requested. Does not create an alpha channel.

GenericImage(string?, BitmapType, int)

Initializes a new instance of the GenericImage class. Creates an image from a file.

GenericImage(string?, string, int)

Initializes a new instance of the GenericImage class. Creates an image from a file using MIME-types to specify the type.

Fields

AlphaChannelOpaque

Constant used to indicate the alpha value conventionally defined as the complete opacity.

AlphaChannelThreshold

Constant used for default threshold separating transparent pixels from opaque for a few functions dealing with alpha and fully opaque.

AlphaChannelTransparent

Constant used to indicate the alpha value conventionally defined as the complete transparency.

Properties

AlphaData

Gets or sets alpha component of the pixels using array of byte.

BestStrategy

Gets best strategy to access pixels.

Bounds

Returns the bounds of the image in pixels. Result is (0, 0, Width, Height).

HasAlpha

Returns true if this image has alpha channel, false otherwise.

HasMask

Returns true if there is a mask active, false otherwise.

Height

Gets the height of the image in pixels.

IsOk

Returns true if image data is present.

PixelCount

Gets number of pixels in this image (Width * Height).

Pixels

Gets or sets pixels using array of SKColor.

RgbData

Gets or sets pixels using array of RGBValue.

Size

Returns the size of the image in pixels.

Width

Gets the width of the image in pixels.

Methods

Blur(int)

Blurs the image in both horizontal and vertical directions by the specified blurRadius (in pixels).

BlurHorizontal(int)

Blurs the image in the horizontal direction only.

BlurVertical(int)

Blurs the image in the vertical direction only.

CanRead(Stream)

Returns true if at least one of the available image handlers can read the data in the given stream.

CanRead(string?)

Returns true if at least one of the available image handlers can read the file with the given name.

ChangeBrightness(double)

Changes the brightness(value) of each pixel in the image.

ChangeHSV(double, double, double)

Changes the hue, the saturation and the brightness(value) of each pixel in the image.

ChangeLightness(int)

Changes lightness of the each pixel.

ChangeSaturation(double)

Changes the saturation of each pixel in the image.

ChangeToDisabled(byte)

Changes each pixel of this image, making its color disabled.

ChangeToGrayScale()

Makes this image grayscaled.

Clear(byte)

Initialize the image data with zeroes (the default) or with the byte value given as value.

ClearAlpha()

Removes the alpha channel from the image.

ConvertAlphaToMask(RGBValue, byte)

If the image has alpha channel, this method converts it to mask using the specified color as the mask color.

ConvertAlphaToMask(byte)

If the image has alpha channel, this method converts it to mask.

ConvertLightness(int)

Returns a changed version of the image based on the given lightness.

ConvertToDisabled(byte)

Returns disabled(dimmed) version of the image.

ConvertToGreyscale()

Returns a greyscale version of the image.

ConvertToGreyscale(double, double, double)

Returns a greyscale version of the image.

ConvertToMono(RGBValue)

Returns monochromatic version of the image.

Copy()

Returns an identical copy of this image.

Create(int, int, Color)

Creates GenericImage with the specified size and fills it with the color.

CreateAlphaData(int, int, byte?)

Creates array of alpha components with the specified size and optionally fills it with the given value.

CreateAlphaDataFromPtr(int, int, IntPtr)

Creates array of alpha components with the specified size and copies alpha component data from the source pointer.

CreateHandler()

Creates handler.

CreatePixels(int, int, SKColor?)

Creates array of SKColor with the specified size and optionally fills it with the color.

CreateRgbData(int, int, RGBValue?)

Creates array of RGBValue with the specified size and optionally fills it with the color.

CreateRgbDataFromPtr(int, int, IntPtr)

Creates array of RGBValue with the specified size and copies pixel data from the source pointer.

CreateSkiaBitmapForImage(int, int, bool)

Creates SKBitmap with the specifies size.

FillAlphaData(SKColor[], byte)

Fills alpha component of the colors with the specified value.

FillAlphaData(byte[], byte)

Fills array with alpha component data with the specified alpha value.

FillPixels(SKColor[], SKColor)

Fills array of SKColor with the specified color.

FillRgbData(RGBValue[], RGBValue)

Fills array with RGBValue with the specified color.

FindFirstUnusedColor(RGBValue?)

Finds the first color that is never used in the image.

ForEachPixel<T>(ActionRef<RGBValue, T>, T)

Executes specified action for the each pixel of the image.

ForEachPixel<T>(ActionRef<SKColor, T>, T)

Executes specified action for the each pixel of the image.

FromSkia(SKBitmap)

Converts SKBitmap to GenericImage.

GetAlpha(int, int)

Return alpha value at given pixel location.

GetAlphaValues(SKColor[])

Creates array of alpha components from the array of SKColor.

GetBlue(int, int)

Returns the blue intensity at the given coordinate.

GetDefaultLoadFlags()

Returns the currently used default file load flags.

GetGreen(int, int)

Returns the green intensity at the given coordinate.

GetImageCount(Stream, BitmapType)

If the image stream contains more than one image and the image handler is capable of retrieving these individually, this function will return the number of available images.

GetImageCount(string?, BitmapType)

If the image file contains more than one image and the image handler is capable of retrieving these individually, this function will return the number of available images.

GetImageExtWildcard()

Iterates all registered image handlers, and returns a string containing file extension masks suitable for passing to file open/save dialog boxes.

GetImageType()

Gets the type of image found when image was loaded or specified when image was saved.

GetLoadFlags()

Returns the file load flags used for this object.

GetMaskBlue()

Gets the blue value of the mask color.

GetMaskGreen()

Gets the green value of the mask color.

GetMaskRGB()

Gets the RGBValue value of the mask color.

GetMaskRed()

Gets the red value of the mask color.

GetOptionAsInt(string)

Gets a user-defined integer-valued option.

GetOptionAsString(string)

Gets a user-defined string-valued option.

GetPixel(int, int, bool)

Gets Color at given pixel location.

GetRGB(int, int)

Gets RGBValue at given pixel location.

GetRGBValues(SKColor[])

Converts array of SKColor to array of RGBValue.

GetRed(int, int)

Returns the red intensity at the given coordinate.

GetSubImage(RectI)

Returns a sub image of the current one as long as the rect belongs entirely to the image.

HasOption(string)

Returns true if the given option is present.

InitAlpha()

Initializes the image alpha channel data.

IsTransparent(int, int, byte)

Returns true if the given pixel is transparent, i.e. either has the mask color if this image has a mask or if this image has alpha channel and alpha value of this pixel is strictly less than threshold.

LoadFromFile(string?, BitmapType, int)

Loads an image from a file.

LoadFromFile(string?, string, int)

Loads an image from a file.

LoadFromStream(Stream, BitmapType, int)

Loads an image from an input stream.

LoadFromStream(Stream, string, int)

Loads an image from an input stream.

LockSurface(ImageLockMode)

Locks pixels data and gets ISkiaSurface to access it.

Mirror(bool)

Returns a mirrored copy of the image.

Paste(GenericImage, int, int, GenericImageAlphaBlendMode)

Copy the data of the given image to the specified position in this image.

Replace(RGBValue, RGBValue)

Replaces the color specified by (r1.R, r1.G, r1.B) by the color (r2.R, r2.G, r2.B).

Rescale(int, int, GenericImageResizeQuality)

Changes the size of the image in-place by scaling it: after a call to this function,the image will have the given width and height.

Reset()

Destroys the image data.

Reset(int, int, bool)

Creates a fresh image.

ResizeNoScale(SizeI, PointI, RGBValue?)

Changes the size of the image in-place without scaling it by adding either a border with the given color or cropping as necessary.

Rotate180()

Returns a copy of the image rotated by 180 degrees.

Rotate90(bool)

Returns a copy of the image rotated 90 degrees in the direction indicated by clockwise.

RotateHue(double)

Rotates the hue of each pixel in the image by angle, which is a double in the range [-1.0..+1.0], where -1.0 corresponds to -360 degrees and +1.0 corresponds to +360 degrees.

SaveToFile(string)

Saves an image in the named file.

SaveToFile(string, BitmapType)

Saves an image in the named file.

SaveToFile(string, string)

Saves an image in the named file.

SaveToStream(Stream, BitmapType)

Saves an image in the given stream.

SaveToStream(Stream, string)

Saves an image in the given stream.

Scale(int, int, GenericImageResizeQuality)

Returns a scaled version of the image. This is also useful for scaling bitmaps in general as the only other way to scale bitmaps is to blit a MemoryDC into another MemoryDC.

SeparateAlphaData(SKColor[], out RGBValue[], out byte[])

Converts array of SKColor into array of RGBValue and array of alpha components.

SetAlpha(byte)

Sets the alpha value for the each pixel.

SetAlpha(int, int, byte)

Sets the alpha value for the given pixel.

SetAlphaValuesFromPtr(SKColor[], byte*)

Copies alpha components from source to data.

SetDefaultLoadFlags(GenericImageLoadFlags)

Sets the default value for the flags used for loading image files.

SetImageType(BitmapType)

Sets the type of image returned by GetType().

SetLoadFlags(GenericImageLoadFlags)

Sets the flags used for loading image files by this object.

SetMask(bool)

Specifies whether there is a mask or not.

SetMaskColor(RGBValue)

Sets the mask color for this image(and tells the image to use the mask).

SetMaskFromImage(GenericImage, RGBValue)

Sets image's mask so that the pixels that have RGB value of mr,mg,mb in mask will be masked in the image.

SetOptionAsInt(string, int)

Sets a user-defined option.

SetOptionAsString(string, string)

Sets a user-defined option.

SetPixel(int, int, Color, bool)

Sets the color of the pixel at the given x and y coordinate.

SetRGB(int, int, RGBValue)

Sets the color of the pixel at the given x and y coordinate.

SetRGBRect(RGBValue, RectI?)

Sets the color of the pixels within the given rectangle.

SetRgbValuesFromPtr(SKColor[], RGBValue*)

Copies pixel data from source to data.

SizeNoScale(SizeI, PointI, RGBValue?)

Returns a resized version of this image without scaling it by adding either a border with the given color or cropping as necessary.

ToSkia(GenericImage, bool)

Converts GenericImage to SKBitmap. Optionally copies pixel data.

ToSkia(IGenericImageHandler, bool)

Converts image specified with IGenericImageHandler to SKBitmap. Optionally copies pixel data.

Operators

explicit operator SKBitmap(GenericImage)

Converts the specified SKBitmap to a GenericImage.

explicit operator GenericImage(SKBitmap)

Converts the specified SKBitmap to a GenericImage.