C# Class QualityBot.Util.ImageUtil

Datei anzeigen Open project: Ancestry/quality-bot

Public Methods

Method Description
Base64ToBytes ( string base64 ) : byte[]

Converts a base 64 encoded string to a byte array.

Base64ToImage ( string base64 ) : Image

Converts a base 64 encoded string to an image.

BitmapDiff ( Bitmap bitmapA, Bitmap bitmapB, ImageAttributes ia, decimal &percentageDifferent ) : Bitmap

Compares two bitmaps pixel-by-pixel and returns a bitmap mask of the difference.

BytesToBase64 ( byte bytes ) : string

Converts a byte array to a base 64 encoded string.

BytesToImage ( byte imageBytes ) : Image

Converts a byte array to an image.

CropImage ( Image image, Rectangle cropArea ) : Image

Crops the image to the specified rectangle.

DrawRegionAsMasks ( Size size, Region region, Image image, ImageAttributes ia ) : Bitmap

Draws the region as green, and the inverted region as red.

GetClippedImage ( Size size, Image image, Region region ) : Bitmap

Clips an image to the specified region.

GetClippedRegion ( Rectangle rectangle, IEnumerable potentialIntersections ) : Region

Calculates the region of the rectangle that is not overlapped by siblings or children.

ImageToBase64 ( Image image, ImageFormat format ) : string

Converts an image to a base 64 encoded string.

ImageToBytes ( Image image, ImageFormat format ) : byte[]

Converts an image to a byte array.

IsColorMatch ( Color color1, Color color2 ) : bool

Determines if two colors are equivalent.

SaveImageToDisc ( string outputDir, string base64Image, string imageSuffix ) : string

Saves the specified image to disc.

Method Details

Base64ToBytes() public static method

Converts a base 64 encoded string to a byte array.
public static Base64ToBytes ( string base64 ) : byte[]
base64 string The base 64 encoded image.
return byte[]

Base64ToImage() public static method

Converts a base 64 encoded string to an image.
public static Base64ToImage ( string base64 ) : Image
base64 string The base 64 encoded image.
return Image

BitmapDiff() public static method

Compares two bitmaps pixel-by-pixel and returns a bitmap mask of the difference.
public static BitmapDiff ( Bitmap bitmapA, Bitmap bitmapB, ImageAttributes ia, decimal &percentageDifferent ) : Bitmap
bitmapA System.Drawing.Bitmap The first bitmap.
bitmapB System.Drawing.Bitmap The second bitmap.
ia System.Drawing.Imaging.ImageAttributes The image attributes.
percentageDifferent decimal The difference between the two images as a percentage.
return System.Drawing.Bitmap

BytesToBase64() public static method

Converts a byte array to a base 64 encoded string.
public static BytesToBase64 ( byte bytes ) : string
bytes byte The byte array.
return string

BytesToImage() public static method

Converts a byte array to an image.
public static BytesToImage ( byte imageBytes ) : Image
imageBytes byte The byte array.
return Image

CropImage() public static method

Crops the image to the specified rectangle.
public static CropImage ( Image image, Rectangle cropArea ) : Image
image Image The image.
cropArea System.Drawing.Rectangle The cropping rectangle.
return Image

DrawRegionAsMasks() public static method

Draws the region as green, and the inverted region as red.
public static DrawRegionAsMasks ( Size size, Region region, Image image, ImageAttributes ia ) : Bitmap
size System.Drawing.Size The size of the image.
region System.Drawing.Region The clipping region.
image Image The image.
ia System.Drawing.Imaging.ImageAttributes The iamge attributes (such as alpha blending) to use when drawing the masks.
return System.Drawing.Bitmap

GetClippedImage() public static method

Clips an image to the specified region.
public static GetClippedImage ( Size size, Image image, Region region ) : Bitmap
size System.Drawing.Size The size of the image.
image Image The image.
region System.Drawing.Region The region to clip.
return System.Drawing.Bitmap

GetClippedRegion() public static method

Calculates the region of the rectangle that is not overlapped by siblings or children.
public static GetClippedRegion ( Rectangle rectangle, IEnumerable potentialIntersections ) : Region
rectangle System.Drawing.Rectangle The rectangle.
potentialIntersections IEnumerable An array of potentially intersecting rectangles.
return System.Drawing.Region

ImageToBase64() public static method

Converts an image to a base 64 encoded string.
public static ImageToBase64 ( Image image, ImageFormat format ) : string
image Image The image.
format System.Drawing.Imaging.ImageFormat The image format.
return string

ImageToBytes() public static method

Converts an image to a byte array.
public static ImageToBytes ( Image image, ImageFormat format ) : byte[]
image Image The image.
format System.Drawing.Imaging.ImageFormat The image format.
return byte[]

IsColorMatch() public static method

Determines if two colors are equivalent.
public static IsColorMatch ( Color color1, Color color2 ) : bool
color1 Color The first color.
color2 Color The second color.
return bool

SaveImageToDisc() public static method

Saves the specified image to disc.
public static SaveImageToDisc ( string outputDir, string base64Image, string imageSuffix ) : string
outputDir string The target directory.
base64Image string The image as a base64 encoded string.
imageSuffix string The filename suffix.
return string