WriteableBitmapExtensions
Collection of draw extension methods for the Silverlight WriteableBitmap class.
Methods
public static int AlphaBlend(int sa, int sr, int sg, int sb, int destPixel)
result = WriteableBitmapExtensions.AlphaBlend(sa, sr, sg, sb, destPixel)
Alpha blends 2 premultiplied colors with each other
- sa
- Source alpha color component
- sr
- Premultiplied source red color component
- sg
- Premultiplied source green color component
- sb
- Premultiplied source blue color component
- destPixel
- Premultiplied destination color
Returns: Premultiplied blended color value
private static void AlphaBlendNormalOnPremultiplied(Int32* pixels, int index, int sa, uint srb, uint sg)
WriteableBitmapExtensions.AlphaBlendNormalOnPremultiplied(pixels, index, sa, srb, sg)
Blends a specific source color on top of a destination premultiplied color
- pixels
- pixels array
- index
- Index of destination pixel
- sa
- Source alpha (0..255)
- srb
- Source non-premultiplied red and blue component in the format 0x00rr00bb
- sg
- Source green component (0..255)
internal static void Blit(WriteableBitmap bmp, Rect destRect, WriteableBitmap source, Rect sourceRect, Color color, BlendMode BlendMode)
WriteableBitmapExtensions.Blit(bmp, destRect, source, sourceRect, color, BlendMode)
Copies (blits) the pixels from the WriteableBitmap source to the destination WriteableBitmap (this).
- bmp
- The destination WriteableBitmap.
- destRect
- The rectangle that defines the destination region.
- source
- The source WriteableBitmap.
- sourceRect
- The rectangle that will be copied from the source to the destination.
- color
- If not Colors.White, will tint the source image. A partially transparent color and the image will be drawn partially transparent. If the BlendMode is ColorKeying, this color will be used as color key to mask all pixels with this value out.
- BlendMode
- The blending mode BlendMode.
internal static void Blit(WriteableBitmap bmp, Point destPosition, WriteableBitmap source, Rect sourceRect, Color color, BlendMode BlendMode)
WriteableBitmapExtensions.Blit(bmp, destPosition, source, sourceRect, color, BlendMode)
Copies (blits) the pixels from the WriteableBitmap source to the destination WriteableBitmap (this).
- bmp
- The destination WriteableBitmap.
- destPosition
- The destination position in the destination bitmap.
- source
- The source WriteableBitmap.
- sourceRect
- The rectangle that will be copied from the source to the destination.
- color
- If not Colors.White, will tint the source image. A partially transparent color and the image will be drawn partially transparent.
- BlendMode
- The blending mode BlendMode.
internal static void Blit(WriteableBitmap bmp, Rect destRect, WriteableBitmap source, Rect sourceRect)
WriteableBitmapExtensions.Blit(bmp, destRect, source, sourceRect)
Copies (blits) the pixels from the WriteableBitmap source to the destination WriteableBitmap (this).
- bmp
- The destination WriteableBitmap.
- destRect
- The rectangle that defines the destination region.
- source
- The source WriteableBitmap.
- sourceRect
- The rectangle that will be copied from the source to the destination.
internal static void Blit(WriteableBitmap bmp, Rect destRect, WriteableBitmap source, Rect sourceRect, BlendMode BlendMode)
WriteableBitmapExtensions.Blit(bmp, destRect, source, sourceRect, BlendMode)
Copies (blits) the pixels from the WriteableBitmap source to the destination WriteableBitmap (this).
- bmp
- The destination WriteableBitmap.
- destRect
- The rectangle that defines the destination region.
- source
- The source WriteableBitmap.
- sourceRect
- The rectangle that will be copied from the source to the destination.
- BlendMode
- The blending mode BlendMode.
internal static void Clear(WriteableBitmap bmp, Color color)
WriteableBitmapExtensions.Clear(bmp, color)
Fills the whole WriteableBitmap with a color.
- bmp
- The WriteableBitmap.
- color
- The color used for filling.
internal static void Clear(WriteableBitmap bmp)
WriteableBitmapExtensions.Clear(bmp)
Fills the whole WriteableBitmap with an empty color (0).
- bmp
- The WriteableBitmap.
internal static WriteableBitmap Clone(WriteableBitmap bmp)
result = WriteableBitmapExtensions.Clone(bmp)
Clones the specified WriteableBitmap.
- bmp
- The WriteableBitmap.
Returns: A copy of the WriteableBitmap.
internal static bool CohenSutherlandLineClip(Rect extents, double x0, double y0, double x1, double y1)
result = WriteableBitmapExtensions.CohenSutherlandLineClip(extents, x0, y0, x1, y1)
Cohen–Sutherland clipping algorithm clips a line from P0 = (x0, y0) to P1 = (x1, y1) against a rectangle with diagonal from (xmin, ymin) to (xmax, ymax).
Returns: a list of two points in the resulting clipped line, or zero
private static List<int> ComputeBezierPoints(int x1, int y1, int cx1, int cy1, int cx2, int cy2, int x2, int y2, int color, BitmapContext context, int w, int h)
result = WriteableBitmapExtensions.ComputeBezierPoints(x1, y1, cx1, cy1, cx2, cy2, x2, y2, color, context, w, h)
Draws a filled, cubic Beziйr spline defined by start, end and two control points.
- x1
- The x-coordinate of the start point.
- y1
- The y-coordinate of the start point.
- cx1
- The x-coordinate of the 1st control point.
- cy1
- The y-coordinate of the 1st control point.
- cx2
- The x-coordinate of the 2nd control point.
- cy2
- The y-coordinate of the 2nd control point.
- x2
- The x-coordinate of the end point.
- y2
- The y-coordinate of the end point.
- color
- The color.
- context
- The bitmap context.
- w
- The width of the bitmap.
- h
- The height of the bitmap.
private static byte ComputeOutCode(Rect extents, double x, double y)
result = WriteableBitmapExtensions.ComputeOutCode(extents, x, y)
Compute the bit code for a point (x, y) using the clip rectangle bounded diagonally by (xmin, ymin), and (xmax, ymax) ASSUME THAT xmax , xmin , ymax and ymin are global constants.
- extents
- The extents.
- x
- The x.
- y
- The y.
private static List<int> ComputeSegmentPoints(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4, float tension, int color, BitmapContext context, int w, int h)
result = WriteableBitmapExtensions.ComputeSegmentPoints(x1, y1, x2, y2, x3, y3, x4, y4, tension, color, context, w, h)
Computes the discrete segment points of a Cardinal spline (cubic) defined by four control points.
- x1
- The x-coordinate of the 1st control point.
- y1
- The y-coordinate of the 1st control point.
- x2
- The x-coordinate of the 2nd control point.
- y2
- The y-coordinate of the 2nd control point.
- x3
- The x-coordinate of the 3rd control point.
- y3
- The y-coordinate of the 3rd control point.
- x4
- The x-coordinate of the 4th control point.
- y4
- The y-coordinate of the 4th control point.
- tension
- The tension of the curve defines the shape. Usually between 0 and 1. 0 would be a straight line.
- color
- The color.
- context
- The context containing the pixels array.
- w
- The width of the bitmap.
- h
- The height of the bitmap.
Convolute(WriteableBitmap, Int32[0:,0:]) : WriteableBitmap
Creates a new filtered WriteableBitmap.
- bmp
- The WriteableBitmap.
- kernel
- The kernel used for convolution.
Returns: A new WriteableBitmap that is a filtered version of the input.
Convolute(WriteableBitmap, Int32[0:,0:], int, int) : WriteableBitmap
Creates a new filtered WriteableBitmap.
- bmp
- The WriteableBitmap.
- kernel
- The kernel used for convolution.
- kernelFactorSum
- The factor used for the kernel summing.
- kernelOffsetSum
- The offset used for the kernel summing.
Returns: A new WriteableBitmap that is a filtered version of the input.
internal static void DrawBezier(WriteableBitmap bmp, int x1, int y1, int cx1, int cy1, int cx2, int cy2, int x2, int y2, Color color)
WriteableBitmapExtensions.DrawBezier(bmp, x1, y1, cx1, cy1, cx2, cy2, x2, y2, color)
Draws a cubic Beziér spline defined by start, end and two control points.
- bmp
- The WriteableBitmap.
- x1
- The x-coordinate of the start point.
- y1
- The y-coordinate of the start point.
- cx1
- The x-coordinate of the 1st control point.
- cy1
- The y-coordinate of the 1st control point.
- cx2
- The x-coordinate of the 2nd control point.
- cy2
- The y-coordinate of the 2nd control point.
- x2
- The x-coordinate of the end point.
- y2
- The y-coordinate of the end point.
- color
- The color.
internal static void DrawBezier(WriteableBitmap bmp, int x1, int y1, int cx1, int cy1, int cx2, int cy2, int x2, int y2, int color)
WriteableBitmapExtensions.DrawBezier(bmp, x1, y1, cx1, cy1, cx2, cy2, x2, y2, color)
Draws a cubic Beziér spline defined by start, end and two control points.
- bmp
- The WriteableBitmap.
- x1
- The x-coordinate of the start point.
- y1
- The y-coordinate of the start point.
- cx1
- The x-coordinate of the 1st control point.
- cy1
- The y-coordinate of the 1st control point.
- cx2
- The x-coordinate of the 2nd control point.
- cy2
- The y-coordinate of the 2nd control point.
- x2
- The x-coordinate of the end point.
- y2
- The y-coordinate of the end point.
- color
- The color.
internal static void DrawBeziers(WriteableBitmap bmp, int[] points, int color)
WriteableBitmapExtensions.DrawBeziers(bmp, points, color)
Draws a series of cubic Beziér splines each defined by start, end and two control points. The ending point of the previous curve is used as starting point for the next. Therfore the inital curve needs four points and the subsequent 3 (2 control and 1 end point).
- bmp
- The WriteableBitmap.
- points
- The points for the curve in x and y pairs, therefore the array is interpreted as (x1, y1, cx1, cy1, cx2, cy2, x2, y2, cx3, cx4 ..., xn, yn).
- color
- The color for the spline.
internal static void DrawBeziers(WriteableBitmap bmp, int[] points, Color color)
WriteableBitmapExtensions.DrawBeziers(bmp, points, color)
Draws a series of cubic Beziér splines each defined by start, end and two control points. The ending point of the previous curve is used as starting point for the next. Therfore the inital curve needs four points and the subsequent 3 (2 control and 1 end point).
- bmp
- The WriteableBitmap.
- points
- The points for the curve in x and y pairs, therefore the array is interpreted as (x1, y1, cx1, cy1, cx2, cy2, x2, y2, cx3, cx4 ..., xn, yn).
- color
- The color for the spline.
internal static void DrawCurve(WriteableBitmap bmp, int[] points, float tension, int color)
WriteableBitmapExtensions.DrawCurve(bmp, points, tension, color)
Draws a Cardinal spline (cubic) defined by a point collection. The cardinal spline passes through each point in the collection.
- bmp
- The WriteableBitmap.
- points
- The points for the curve in x and y pairs, therefore the array is interpreted as (x1, y1, x2, y2, x3, y3, x4, y4, x1, x2 ..., xn, yn).
- tension
- The tension of the curve defines the shape. Usually between 0 and 1. 0 would be a straight line.
- color
- The color for the spline.
internal static void DrawCurve(WriteableBitmap bmp, int[] points, float tension, Color color)
WriteableBitmapExtensions.DrawCurve(bmp, points, tension, color)
Draws a Cardinal spline (cubic) defined by a point collection. The cardinal spline passes through each point in the collection.
- bmp
- The WriteableBitmap.
- points
- The points for the curve in x and y pairs, therefore the array is interpreted as (x1, y1, x2, y2, x3, y3, x4, y4, x1, x2 ..., xn, yn).
- tension
- The tension of the curve defines the shape. Usually between 0 and 1. 0 would be a straight line.
- color
- The color for the spline.
internal static void DrawCurveClosed(WriteableBitmap bmp, int[] points, float tension, int color)
WriteableBitmapExtensions.DrawCurveClosed(bmp, points, tension, color)
Draws a closed Cardinal spline (cubic) defined by a point collection. The cardinal spline passes through each point in the collection.
- bmp
- The WriteableBitmap.
- points
- The points for the curve in x and y pairs, therefore the array is interpreted as (x1, y1, x2, y2, x3, y3, x4, y4, x1, x2 ..., xn, yn).
- tension
- The tension of the curve defines the shape. Usually between 0 and 1. 0 would be a straight line.
- color
- The color for the spline.
internal static void DrawCurveClosed(WriteableBitmap bmp, int[] points, float tension, Color color)
WriteableBitmapExtensions.DrawCurveClosed(bmp, points, tension, color)
Draws a closed Cardinal spline (cubic) defined by a point collection. The cardinal spline passes through each point in the collection.
- bmp
- The WriteableBitmap.
- points
- The points for the curve in x and y pairs, therefore the array is interpreted as (x1, y1, x2, y2, x3, y3, x4, y4, x1, x2 ..., xn, yn).
- tension
- The tension of the curve defines the shape. Usually between 0 and 1. 0 would be a straight line.
- color
- The color for the spline.
private static void DrawCurveSegment(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4, float tension, int color, BitmapContext context, int w, int h)
WriteableBitmapExtensions.DrawCurveSegment(x1, y1, x2, y2, x3, y3, x4, y4, tension, color, context, w, h)
Draws a segment of a Cardinal spline (cubic) defined by four control points.
- x1
- The x-coordinate of the 1st control point.
- y1
- The y-coordinate of the 1st control point.
- x2
- The x-coordinate of the 2nd control point.
- y2
- The y-coordinate of the 2nd control point.
- x3
- The x-coordinate of the 3rd control point.
- y3
- The y-coordinate of the 3rd control point.
- x4
- The x-coordinate of the 4th control point.
- y4
- The y-coordinate of the 4th control point.
- tension
- The tension of the curve defines the shape. Usually between 0 and 1. 0 would be a straight line.
- color
- The color.
- context
- The context containing the pixels array.
- w
- The width of the bitmap.
- h
- The height of the bitmap.
internal static void DrawEllipse(WriteableBitmap bmp, int x1, int y1, int x2, int y2, int color, int thickness)
WriteableBitmapExtensions.DrawEllipse(bmp, x1, y1, x2, y2, color, thickness)
A Fast Bresenham Type Algorithm For Drawing Ellipses http://homepage.smc.edu/kennedy_john/belipse.pdf x2 has to be greater than x1 and y2 has to be greater than y1.
- bmp
- The WriteableBitmap.
- x1
- The x-coordinate of the bounding rectangle's left side.
- y1
- The y-coordinate of the bounding rectangle's top side.
- x2
- The x-coordinate of the bounding rectangle's right side.
- y2
- The y-coordinate of the bounding rectangle's bottom side.
- color
- The color for the line.
- thickness
- The thickness for the line
internal static void DrawEllipseCentered(WriteableBitmap bmp, int xc, int yc, int xr, int yr, Color color)
WriteableBitmapExtensions.DrawEllipseCentered(bmp, xc, yc, xr, yr, color)
A Fast Bresenham Type Algorithm For Drawing Ellipses http://homepage.smc.edu/kennedy_john/belipse.pdf Uses a different parameter representation than DrawEllipse().
- bmp
- The WriteableBitmap.
- xc
- The x-coordinate of the ellipses center.
- yc
- The y-coordinate of the ellipses center.
- xr
- The radius of the ellipse in x-direction.
- yr
- The radius of the ellipse in y-direction.
- color
- The color for the line.
internal static void DrawEllipseCentered(WriteableBitmap bmp, int xc, int yc, int xr, int yr, int color)
WriteableBitmapExtensions.DrawEllipseCentered(bmp, xc, yc, xr, yr, color)
A Fast Bresenham Type Algorithm For Drawing Ellipses http://homepage.smc.edu/kennedy_john/belipse.pdf Uses a different parameter representation than DrawEllipse().
- bmp
- The WriteableBitmap.
- xc
- The x-coordinate of the ellipses center.
- yc
- The y-coordinate of the ellipses center.
- xr
- The radius of the ellipse in x-direction.
- yr
- The radius of the ellipse in y-direction.
- color
- The color for the line.
internal static void DrawLine(WriteableBitmap bmp, int x1, int y1, int x2, int y2, int color)
WriteableBitmapExtensions.DrawLine(bmp, x1, y1, x2, y2, color)
Draws a colored line by connecting two points using an optimized DDA.
- bmp
- The WriteableBitmap.
- x1
- The x-coordinate of the start point.
- y1
- The y-coordinate of the start point.
- x2
- The x-coordinate of the end point.
- y2
- The y-coordinate of the end point.
- color
- The color for the line.
internal static void DrawLine(BitmapContext context, int pixelWidth, int pixelHeight, int x1, int y1, int x2, int y2, int color)
WriteableBitmapExtensions.DrawLine(context, pixelWidth, pixelHeight, x1, y1, x2, y2, color)
Draws a colored line by connecting two points using an optimized DDA. Uses the pixels array and the width directly for best performance.
- context
- A context containing the pixels as int RGBA value.
- pixelWidth
- The width of one scanline in the pixels array.
- pixelHeight
- The height of the bitmap.
- x1
- The x-coordinate of the start point.
- y1
- The y-coordinate of the start point.
- x2
- The x-coordinate of the end point.
- y2
- The y-coordinate of the end point.
- color
- The color for the line.
internal static void DrawLine(WriteableBitmap bmp, int x1, int y1, int x2, int y2, Color color)
WriteableBitmapExtensions.DrawLine(bmp, x1, y1, x2, y2, color)
Draws a colored line by connecting two points using an optimized DDA.
- bmp
- The WriteableBitmap.
- x1
- The x-coordinate of the start point.
- y1
- The y-coordinate of the start point.
- x2
- The x-coordinate of the end point.
- y2
- The y-coordinate of the end point.
- color
- The color for the line.
internal static void DrawLineAa(WriteableBitmap bmp, int x1, int y1, int x2, int y2, Color color)
WriteableBitmapExtensions.DrawLineAa(bmp, x1, y1, x2, y2, color)
Draws an anti-aliased line, using an optimized version of Gupta-Sproull algorithm From http://nokola.com/blog/post/2010/10/14/Anti-aliased-Lines-And-Optimizing-Code-for-Windows-Phone-7e28093First-Look.aspx The WriteableBitmap.The x-coordinate of the start point.The y-coordinate of the start point.The x-coordinate of the end point.The y-coordinate of the end point.The color for the line.
internal static void DrawLineAa(BitmapContext context, int pixelWidth, int pixelHeight, int x1, int y1, int x2, int y2, int color, bool skipFirstPixel)
WriteableBitmapExtensions.DrawLineAa(context, pixelWidth, pixelHeight, x1, y1, x2, y2, color, skipFirstPixel)
Draws an anti-aliased line, using an optimized version of Gupta-Sproull algorithm From http://nokola.com/blog/post/2010/10/14/Anti-aliased-Lines-And-Optimizing-Code-for-Windows-Phone-7e28093First-Look.aspx A context containing the pixels as int RGBA value.The width of one scanline in the pixels array.The height of the bitmap.The x-coordinate of the start point.The y-coordinate of the start point.The x-coordinate of the end point.The y-coordinate of the end point.The color for the line.
internal static void DrawLineAa(WriteableBitmap bmp, int x1, int y1, int x2, int y2, int color)
WriteableBitmapExtensions.DrawLineAa(bmp, x1, y1, x2, y2, color)
Draws an anti-aliased line, using an optimized version of Gupta-Sproull algorithm From http://nokola.com/blog/post/2010/10/14/Anti-aliased-Lines-And-Optimizing-Code-for-Windows-Phone-7e28093First-Look.aspx The WriteableBitmap.The x-coordinate of the start point.The y-coordinate of the start point.The x-coordinate of the end point.The y-coordinate of the end point.The color for the line.
internal static void DrawLineBresenham(WriteableBitmap bmp, int x1, int y1, int x2, int y2, int color)
WriteableBitmapExtensions.DrawLineBresenham(bmp, x1, y1, x2, y2, color)
Draws a colored line by connecting two points using the Bresenham algorithm.
- bmp
- The WriteableBitmap.
- x1
- The x-coordinate of the start point.
- y1
- The y-coordinate of the start point.
- x2
- The x-coordinate of the end point.
- y2
- The y-coordinate of the end point.
- color
- The color for the line.
internal static void DrawLineBresenham(WriteableBitmap bmp, int x1, int y1, int x2, int y2, Color color)
WriteableBitmapExtensions.DrawLineBresenham(bmp, x1, y1, x2, y2, color)
Draws a colored line by connecting two points using the Bresenham algorithm.
- bmp
- The WriteableBitmap.
- x1
- The x-coordinate of the start point.
- y1
- The y-coordinate of the start point.
- x2
- The x-coordinate of the end point.
- y2
- The y-coordinate of the end point.
- color
- The color for the line.
internal static void DrawLineDDA(WriteableBitmap bmp, int x1, int y1, int x2, int y2, int color)
WriteableBitmapExtensions.DrawLineDDA(bmp, x1, y1, x2, y2, color)
Draws a colored line by connecting two points using a DDA algorithm (Digital Differential Analyzer).
- bmp
- The WriteableBitmap.
- x1
- The x-coordinate of the start point.
- y1
- The y-coordinate of the start point.
- x2
- The x-coordinate of the end point.
- y2
- The y-coordinate of the end point.
- color
- The color for the line.
internal static void DrawLineDDA(WriteableBitmap bmp, int x1, int y1, int x2, int y2, Color color)
WriteableBitmapExtensions.DrawLineDDA(bmp, x1, y1, x2, y2, color)
Draws a colored line by connecting two points using a DDA algorithm (Digital Differential Analyzer).
- bmp
- The WriteableBitmap.
- x1
- The x-coordinate of the start point.
- y1
- The y-coordinate of the start point.
- x2
- The x-coordinate of the end point.
- y2
- The y-coordinate of the end point.
- color
- The color for the line.
internal static void DrawPolyline(WriteableBitmap bmp, int[] points, Color color)
WriteableBitmapExtensions.DrawPolyline(bmp, points, color)
Draws a polyline. Add the first point also at the end of the array if the line should be closed.
- bmp
- The WriteableBitmap.
- points
- The points of the polyline in x and y pairs, therefore the array is interpreted as (x1, y1, x2, y2, ..., xn, yn).
- color
- The color for the line.
internal static void DrawPolyline(WriteableBitmap bmp, int[] points, int color)
WriteableBitmapExtensions.DrawPolyline(bmp, points, color)
Draws a polyline. Add the first point also at the end of the array if the line should be closed.
- bmp
- The WriteableBitmap.
- points
- The points of the polyline in x and y pairs, therefore the array is interpreted as (x1, y1, x2, y2, ..., xn, yn).
- color
- The color for the line.
internal static void DrawQuad(WriteableBitmap bmp, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4, Color color)
WriteableBitmapExtensions.DrawQuad(bmp, x1, y1, x2, y2, x3, y3, x4, y4, color)
Draws a quad.
- bmp
- The WriteableBitmap.
- x1
- The x-coordinate of the 1st point.
- y1
- The y-coordinate of the 1st point.
- x2
- The x-coordinate of the 2nd point.
- y2
- The y-coordinate of the 2nd point.
- x3
- The x-coordinate of the 3rd point.
- y3
- The y-coordinate of the 3rd point.
- x4
- The x-coordinate of the 4th point.
- y4
- The y-coordinate of the 4th point.
- color
- The color.
internal static void DrawQuad(WriteableBitmap bmp, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4, int color)
WriteableBitmapExtensions.DrawQuad(bmp, x1, y1, x2, y2, x3, y3, x4, y4, color)
Draws a quad.
- bmp
- The WriteableBitmap.
- x1
- The x-coordinate of the 1st point.
- y1
- The y-coordinate of the 1st point.
- x2
- The x-coordinate of the 2nd point.
- y2
- The y-coordinate of the 2nd point.
- x3
- The x-coordinate of the 3rd point.
- y3
- The y-coordinate of the 3rd point.
- x4
- The x-coordinate of the 4th point.
- y4
- The y-coordinate of the 4th point.
- color
- The color.
internal static void DrawRectangle(WriteableBitmap bmp, int x1, int y1, int x2, int y2, int color)
WriteableBitmapExtensions.DrawRectangle(bmp, x1, y1, x2, y2, color)
Draws a rectangle. x2 has to be greater than x1 and y2 has to be greater than y1.
- bmp
- The WriteableBitmap.
- x1
- The x-coordinate of the bounding rectangle's left side.
- y1
- The y-coordinate of the bounding rectangle's top side.
- x2
- The x-coordinate of the bounding rectangle's right side.
- y2
- The y-coordinate of the bounding rectangle's bottom side.
- color
- The color.
internal static void DrawRectangle(WriteableBitmap bmp, int x1, int y1, int x2, int y2, Color color)
WriteableBitmapExtensions.DrawRectangle(bmp, x1, y1, x2, y2, color)
Draws a rectangle. x2 has to be greater than x1 and y2 has to be greater than y1.
- bmp
- The WriteableBitmap.
- x1
- The x-coordinate of the bounding rectangle's left side.
- y1
- The y-coordinate of the bounding rectangle's top side.
- x2
- The x-coordinate of the bounding rectangle's right side.
- y2
- The y-coordinate of the bounding rectangle's bottom side.
- color
- The color.
internal static void DrawTriangle(WriteableBitmap bmp, int x1, int y1, int x2, int y2, int x3, int y3, Color color)
WriteableBitmapExtensions.DrawTriangle(bmp, x1, y1, x2, y2, x3, y3, color)
Draws a triangle.
- bmp
- The WriteableBitmap.
- x1
- The x-coordinate of the 1st point.
- y1
- The y-coordinate of the 1st point.
- x2
- The x-coordinate of the 2nd point.
- y2
- The y-coordinate of the 2nd point.
- x3
- The x-coordinate of the 3rd point.
- y3
- The y-coordinate of the 3rd point.
- color
- The color.
internal static void DrawTriangle(WriteableBitmap bmp, int x1, int y1, int x2, int y2, int x3, int y3, int color)
WriteableBitmapExtensions.DrawTriangle(bmp, x1, y1, x2, y2, x3, y3, color)
Draws a triangle.
- bmp
- The WriteableBitmap.
- x1
- The x-coordinate of the 1st point.
- y1
- The y-coordinate of the 1st point.
- x2
- The x-coordinate of the 2nd point.
- y2
- The y-coordinate of the 2nd point.
- x3
- The x-coordinate of the 3rd point.
- y3
- The y-coordinate of the 3rd point.
- color
- The color.
public static void DrawWuLine(BitmapContext context, int pixelWidth, int pixelHeight, short X0, short Y0, short X1, short Y1, int sa, int sr, int sg, int sb)
WriteableBitmapExtensions.DrawWuLine(context, pixelWidth, pixelHeight, X0, Y0, X1, Y1, sa, sr, sg, sb)
Draws an anti-aliased, alpha blended, colored line by connecting two points using Wu's antialiasing algorithm Uses the pixels array and the width directly for best performance.
- context
- An array containing the pixels as int RGBA value.
- pixelWidth
- The width of one scanline in the pixels array.
- pixelHeight
- The height of the bitmap.
- X0
- The x0.
- Y0
- The y0.
- X1
- The x1.
- Y1
- The y1.
- sa
- Alpha color component
- sr
- Premultiplied red color component
- sg
- Premultiplied green color component
- sb
- Premultiplied blue color component
internal static void FillBeziers(WriteableBitmap bmp, int[] points, Color color)
WriteableBitmapExtensions.FillBeziers(bmp, points, color)
Draws a series of filled, cubic Beziйr splines each defined by start, end and two control points. The ending point of the previous curve is used as starting point for the next. Therfore the inital curve needs four points and the subsequent 3 (2 control and 1 end point).
- bmp
- The WriteableBitmap.
- points
- The points for the curve in x and y pairs, therefore the array is interpreted as (x1, y1, cx1, cy1, cx2, cy2, x2, y2, cx3, cx4 ..., xn, yn).
- color
- The color for the spline.
internal static void FillBeziers(WriteableBitmap bmp, int[] points, int color)
WriteableBitmapExtensions.FillBeziers(bmp, points, color)
Draws a series of filled, cubic Beziйr splines each defined by start, end and two control points. The ending point of the previous curve is used as starting point for the next. Therfore the inital curve needs four points and the subsequent 3 (2 control and 1 end point).
- bmp
- The WriteableBitmap.
- points
- The points for the curve in x and y pairs, therefore the array is interpreted as (x1, y1, cx1, cy1, cx2, cy2, x2, y2, cx3, cx4 ..., xn, yn).
- color
- The color for the spline.
internal static void FillCurve(WriteableBitmap bmp, int[] points, float tension, int color)
WriteableBitmapExtensions.FillCurve(bmp, points, tension, color)
Draws a filled Cardinal spline (cubic) defined by a point collection. The cardinal spline passes through each point in the collection.
- bmp
- The WriteableBitmap.
- points
- The points for the curve in x and y pairs, therefore the array is interpreted as (x1, y1, x2, y2, x3, y3, x4, y4, x1, x2 ..., xn, yn).
- tension
- The tension of the curve defines the shape. Usually between 0 and 1. 0 would be a straight line.
- color
- The color for the spline.
internal static void FillCurve(WriteableBitmap bmp, int[] points, float tension, Color color)
WriteableBitmapExtensions.FillCurve(bmp, points, tension, color)
Draws a filled Cardinal spline (cubic) defined by a point collection. The cardinal spline passes through each point in the collection.
- bmp
- The WriteableBitmap.
- points
- The points for the curve in x and y pairs, therefore the array is interpreted as (x1, y1, x2, y2, x3, y3, x4, y4, x1, x2 ..., xn, yn).
- tension
- The tension of the curve defines the shape. Usually between 0 and 1. 0 would be a straight line.
- color
- The color for the spline.
internal static void FillCurveClosed(WriteableBitmap bmp, int[] points, float tension, Color color)
WriteableBitmapExtensions.FillCurveClosed(bmp, points, tension, color)
Draws a filled, closed Cardinal spline (cubic) defined by a point collection. The cardinal spline passes through each point in the collection.
- bmp
- The WriteableBitmap.
- points
- The points for the curve in x and y pairs, therefore the array is interpreted as (x1, y1, x2, y2, x3, y3, x4, y4, x1, x2 ..., xn, yn).
- tension
- The tension of the curve defines the shape. Usually between 0 and 1. 0 would be a straight line.
- color
- The color for the spline.
internal static void FillCurveClosed(WriteableBitmap bmp, int[] points, float tension, int color)
WriteableBitmapExtensions.FillCurveClosed(bmp, points, tension, color)
Draws a filled, closed Cardinal spline (cubic) defined by a point collection. The cardinal spline passes through each point in the collection.
- bmp
- The WriteableBitmap.
- points
- The points for the curve in x and y pairs, therefore the array is interpreted as (x1, y1, x2, y2, x3, y3, x4, y4, x1, x2 ..., xn, yn).
- tension
- The tension of the curve defines the shape. Usually between 0 and 1. 0 would be a straight line.
- color
- The color for the spline.
internal static void FillEllipse(WriteableBitmap bmp, int x1, int y1, int x2, int y2, Color color)
WriteableBitmapExtensions.FillEllipse(bmp, x1, y1, x2, y2, color)
A Fast Bresenham Type Algorithm For Drawing filled ellipses http://homepage.smc.edu/kennedy_john/belipse.pdf x2 has to be greater than x1 and y2 has to be greater than y1.
- bmp
- The WriteableBitmap.
- x1
- The x-coordinate of the bounding rectangle's left side.
- y1
- The y-coordinate of the bounding rectangle's top side.
- x2
- The x-coordinate of the bounding rectangle's right side.
- y2
- The y-coordinate of the bounding rectangle's bottom side.
- color
- The color for the line.
internal static void FillEllipse(WriteableBitmap bmp, int x1, int y1, int x2, int y2, int color)
WriteableBitmapExtensions.FillEllipse(bmp, x1, y1, x2, y2, color)
A Fast Bresenham Type Algorithm For Drawing filled ellipses http://homepage.smc.edu/kennedy_john/belipse.pdf x2 has to be greater than x1 and y2 has to be greater than y1.
- bmp
- The WriteableBitmap.
- x1
- The x-coordinate of the bounding rectangle's left side.
- y1
- The y-coordinate of the bounding rectangle's top side.
- x2
- The x-coordinate of the bounding rectangle's right side.
- y2
- The y-coordinate of the bounding rectangle's bottom side.
- color
- The color for the line.
internal static void FillEllipseCentered(WriteableBitmap bmp, int xc, int yc, int xr, int yr, int color)
WriteableBitmapExtensions.FillEllipseCentered(bmp, xc, yc, xr, yr, color)
A Fast Bresenham Type Algorithm For Drawing filled ellipses http://homepage.smc.edu/kennedy_john/belipse.pdf Uses a different parameter representation than DrawEllipse().
- bmp
- The WriteableBitmap.
- xc
- The x-coordinate of the ellipses center.
- yc
- The y-coordinate of the ellipses center.
- xr
- The radius of the ellipse in x-direction.
- yr
- The radius of the ellipse in y-direction.
- color
- The color for the line.
internal static void FillEllipseCentered(WriteableBitmap bmp, int xc, int yc, int xr, int yr, Color color)
WriteableBitmapExtensions.FillEllipseCentered(bmp, xc, yc, xr, yr, color)
A Fast Bresenham Type Algorithm For Drawing filled ellipses http://homepage.smc.edu/kennedy_john/belipse.pdf Uses a different parameter representation than DrawEllipse().
- bmp
- The WriteableBitmap.
- xc
- The x-coordinate of the ellipses center.
- yc
- The y-coordinate of the ellipses center.
- xr
- The radius of the ellipse in x-direction.
- yr
- The radius of the ellipse in y-direction.
- color
- The color for the line.
internal static void FillPolygon(WriteableBitmap bmp, int[] points, Func<int, int, int> colorCb, BlendMode blendMode)
WriteableBitmapExtensions.FillPolygon(bmp, points, colorCb, blendMode)
Draws a filled polygon. Add the first point also at the end of the array if the line should be closed.
- bmp
- The WriteableBitmap.
- points
- The points of the polygon in x and y pairs, therefore the array is interpreted as (x1, y1, x2, y2, ..., xn, yn).
- colorCb
- The color for the fill.
- blendMode
- The blend mode. Default is Alpha
internal static void FillPolygon(WriteableBitmap bmp, int[] points, int color, BlendMode blendMode)
WriteableBitmapExtensions.FillPolygon(bmp, points, color, blendMode)
Draws a filled polygon. Add the first point also at the end of the array if the line should be closed.
- bmp
- The WriteableBitmap.
- points
- The points of the polygon in x and y pairs, therefore the array is interpreted as (x1, y1, x2, y2, ..., xn, yn).
- color
- The color for the line.
- blendMode
- The blend mode. Default is Alpha
internal static void FillPolygon(WriteableBitmap bmp, int[] points, Color color)
WriteableBitmapExtensions.FillPolygon(bmp, points, color)
Draws a filled polygon. Add the first point also at the end of the array if the line should be closed.
- bmp
- The WriteableBitmap.
- points
- The points of the polygon in x and y pairs, therefore the array is interpreted as (x1, y1, x2, y2, ..., xn, yn).
- color
- The color for the line.
internal static void FillQuad(WriteableBitmap bmp, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4, int color)
WriteableBitmapExtensions.FillQuad(bmp, x1, y1, x2, y2, x3, y3, x4, y4, color)
Draws a filled quad.
- bmp
- The WriteableBitmap.
- x1
- The x-coordinate of the 1st point.
- y1
- The y-coordinate of the 1st point.
- x2
- The x-coordinate of the 2nd point.
- y2
- The y-coordinate of the 2nd point.
- x3
- The x-coordinate of the 3rd point.
- y3
- The y-coordinate of the 3rd point.
- x4
- The x-coordinate of the 4th point.
- y4
- The y-coordinate of the 4th point.
- color
- The color.
internal static void FillQuad(WriteableBitmap bmp, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4, Color color)
WriteableBitmapExtensions.FillQuad(bmp, x1, y1, x2, y2, x3, y3, x4, y4, color)
Draws a filled quad.
- bmp
- The WriteableBitmap.
- x1
- The x-coordinate of the 1st point.
- y1
- The y-coordinate of the 1st point.
- x2
- The x-coordinate of the 2nd point.
- y2
- The y-coordinate of the 2nd point.
- x3
- The x-coordinate of the 3rd point.
- y3
- The y-coordinate of the 3rd point.
- x4
- The x-coordinate of the 4th point.
- y4
- The y-coordinate of the 4th point.
- color
- The color.
internal static void FillRectangle(WriteableBitmap bmp, int x1, int y1, int x2, int y2, Color color)
WriteableBitmapExtensions.FillRectangle(bmp, x1, y1, x2, y2, color)
Draws a filled rectangle. x2 has to be greater than x1 and y2 has to be greater than y1.
- bmp
- The WriteableBitmap.
- x1
- The x-coordinate of the bounding rectangle's left side.
- y1
- The y-coordinate of the bounding rectangle's top side.
- x2
- The x-coordinate of the bounding rectangle's right side.
- y2
- The y-coordinate of the bounding rectangle's bottom side.
- color
- The color.
internal static void FillRectangle(WriteableBitmap bmp, int x1, int y1, int x2, int y2, int color, BlendMode blendMode)
WriteableBitmapExtensions.FillRectangle(bmp, x1, y1, x2, y2, color, blendMode)
Draws a filled rectangle. x2 has to be greater than x1 and y2 has to be greater than y1.
- bmp
- The WriteableBitmap.
- x1
- The x-coordinate of the bounding rectangle's left side.
- y1
- The y-coordinate of the bounding rectangle's top side.
- x2
- The x-coordinate of the bounding rectangle's right side.
- y2
- The y-coordinate of the bounding rectangle's bottom side.
- color
- The color.
- blendMode
- The blend mode.
internal static void FillRectangle(WriteableBitmap bmp, int x1, int y1, int x2, int y2, Func<int, int, int> colorCb, BlendMode blendMode)
WriteableBitmapExtensions.FillRectangle(bmp, x1, y1, x2, y2, colorCb, blendMode)
Draws a filled rectangle. x2 has to be greater than x1 and y2 has to be greater than y1.
- bmp
- The WriteableBitmap.
- x1
- The x-coordinate of the bounding rectangle's left side.
- y1
- The y-coordinate of the bounding rectangle's top side.
- x2
- The x-coordinate of the bounding rectangle's right side.
- y2
- The y-coordinate of the bounding rectangle's bottom side.
- colorCb
- The color.
- blendMode
- The blend mode.
internal static void FillTriangle(WriteableBitmap bmp, int x1, int y1, int x2, int y2, int x3, int y3, int color)
WriteableBitmapExtensions.FillTriangle(bmp, x1, y1, x2, y2, x3, y3, color)
Draws a filled triangle.
- bmp
- The WriteableBitmap.
- x1
- The x-coordinate of the 1st point.
- y1
- The y-coordinate of the 1st point.
- x2
- The x-coordinate of the 2nd point.
- y2
- The y-coordinate of the 2nd point.
- x3
- The x-coordinate of the 3rd point.
- y3
- The y-coordinate of the 3rd point.
- color
- The color.
internal static void FillTriangle(WriteableBitmap bmp, int x1, int y1, int x2, int y2, int x3, int y3, Color color)
WriteableBitmapExtensions.FillTriangle(bmp, x1, y1, x2, y2, x3, y3, color)
Draws a filled triangle.
- bmp
- The WriteableBitmap.
- x1
- The x-coordinate of the 1st point.
- y1
- The y-coordinate of the 1st point.
- x2
- The x-coordinate of the 2nd point.
- y2
- The y-coordinate of the 2nd point.
- x3
- The x-coordinate of the 3rd point.
- y3
- The y-coordinate of the 3rd point.
- color
- The color.
internal static WriteableBitmap Flip(WriteableBitmap bmp, FlipMode flipMode)
result = WriteableBitmapExtensions.Flip(bmp, flipMode)
Flips (reflects the image) eiter vertical or horizontal.
- bmp
- The WriteableBitmap.
- flipMode
- The flip mode.
Returns: A new WriteableBitmap that is a flipped version of the input.
internal static void ForEach(WriteableBitmap bmp, Func<int, int, Color> func)
WriteableBitmapExtensions.ForEach(bmp, func)
Applies the given function to all the pixels of the bitmap in order to set their color.
- bmp
- The WriteableBitmap.
- func
- The function to apply. With parameters x, y and a color as a result
internal static void ForEach(WriteableBitmap bmp, Func<int, int, Color, Color> func)
WriteableBitmapExtensions.ForEach(bmp, func)
Applies the given function to all the pixels of the bitmap in order to set their color.
- bmp
- The WriteableBitmap.
- func
- The function to apply. With parameters x, y, source color and a color as a result
internal static WriteableBitmap FromByteArray(WriteableBitmap bmp, byte[] buffer)
result = WriteableBitmapExtensions.FromByteArray(bmp, buffer)
Copies all the color information from an ARGB byte array into this WriteableBitmap.
- bmp
- The WriteableBitmap.
- buffer
- The color buffer as byte ARGB values.
Returns: The WriteableBitmap that was passed as parameter.
internal static WriteableBitmap FromByteArray(WriteableBitmap bmp, byte[] buffer, int count)
result = WriteableBitmapExtensions.FromByteArray(bmp, buffer, count)
Copies color information from an ARGB byte array into this WriteableBitmap.
- bmp
- The WriteableBitmap.
- count
- The number of bytes to copy from the buffer.
- buffer
- The color buffer as byte ARGB values.
Returns: The WriteableBitmap that was passed as parameter.
internal static WriteableBitmap FromByteArray(WriteableBitmap bmp, byte[] buffer, int offset, int count)
result = WriteableBitmapExtensions.FromByteArray(bmp, buffer, offset, count)
Copies color information from an ARGB byte array into this WriteableBitmap starting at a specific buffer index.
- bmp
- The WriteableBitmap.
- offset
- The starting index in the buffer.
- count
- The number of bytes to copy from the buffer.
- buffer
- The color buffer as byte ARGB values.
Returns: The WriteableBitmap that was passed as parameter.
internal static WriteableBitmap FromContent(WriteableBitmap bmp, string relativePath)
result = WriteableBitmapExtensions.FromContent(bmp, relativePath)
Loads an image from the applications content and fills this WriteableBitmap with it.
- bmp
- The WriteableBitmap.
- relativePath
- Only the relative path to the content file.
Returns: The WriteableBitmap that was passed as parameter.
internal static WriteableBitmap FromResource(WriteableBitmap bmp, string relativePath)
result = WriteableBitmapExtensions.FromResource(bmp, relativePath)
Loads an image from the applications resource file and fills this WriteableBitmap with it.
- bmp
- The WriteableBitmap.
- relativePath
- Only the relative path to the resource file. The assembly name is retrieved automatically.
Returns: The WriteableBitmap that was passed as parameter.
internal static byte GetBrightness(WriteableBitmap bmp, int x, int y)
result = WriteableBitmapExtensions.GetBrightness(bmp, x, y)
Gets the brightness / luminance of the pixel at the x, y coordinate as byte.
- bmp
- The WriteableBitmap.
- x
- The x coordinate of the pixel.
- y
- The y coordinate of the pixel.
Returns: The brightness of the pixel at x, y.
internal static Color GetPixel(WriteableBitmap bmp, int x, int y)
result = WriteableBitmapExtensions.GetPixel(bmp, x, y)
Gets the color of the pixel at the x, y coordinate as a Color struct. For best performance this method should not be used in iterative real-time scenarios. Implement the code directly inside a loop.
- bmp
- The WriteableBitmap.
- x
- The x coordinate of the pixel.
- y
- The y coordinate of the pixel.
Returns: The color of the pixel at x, y as a Color struct.
internal static int GetPixeli(WriteableBitmap bmp, int x, int y)
result = WriteableBitmapExtensions.GetPixeli(bmp, x, y)
Gets the color of the pixel at the x, y coordinate as integer. For best performance this method should not be used in iterative real-time scenarios. Implement the code directly inside a loop.
- bmp
- The WriteableBitmap.
- x
- The x coordinate of the pixel.
- y
- The y coordinate of the pixel.
Returns: The color of the pixel at x, y.
internal static WriteableBitmap Invert(WriteableBitmap bmp)
result = WriteableBitmapExtensions.Invert(bmp)
Creates a new inverted WriteableBitmap and returns it.
- bmp
- The WriteableBitmap.
Returns: The new inverted WriteableBitmap.
internal static int[] Resize(BitmapContext srcContext, int widthSource, int heightSource, int width, int height, Interpolation interpolation)
result = WriteableBitmapExtensions.Resize(srcContext, widthSource, heightSource, width, height, interpolation)
Creates a new resized bitmap.
- srcContext
- The source context.
- widthSource
- The width of the source pixels.
- heightSource
- The height of the source pixels.
- width
- The new desired width.
- height
- The new desired height.
- interpolation
- The interpolation method that should be used.
Returns: A new bitmap that is a resized version of the input.
internal static WriteableBitmap Resize(WriteableBitmap bmp, int width, int height, Interpolation interpolation)
result = WriteableBitmapExtensions.Resize(bmp, width, height, interpolation)
Creates a new resized WriteableBitmap.
- bmp
- The WriteableBitmap.
- width
- The new desired width.
- height
- The new desired height.
- interpolation
- The interpolation method that should be used.
Returns: A new WriteableBitmap that is a resized version of the input.
internal static WriteableBitmap Rotate(WriteableBitmap bmp, int angle)
result = WriteableBitmapExtensions.Rotate(bmp, angle)
Rotates the bitmap in 90° steps clockwise and returns a new rotated WriteableBitmap.
- bmp
- The WriteableBitmap.
- angle
- The angle in degress the bitmap should be rotated in 90° steps clockwise.
Returns: A new WriteableBitmap that is a rotated version of the input.
internal static WriteableBitmap RotateFree(WriteableBitmap bmp, double angle, bool crop)
result = WriteableBitmapExtensions.RotateFree(bmp, angle, crop)
Rotates the bitmap in any degree returns a new rotated WriteableBitmap.
- bmp
- The WriteableBitmap.
- angle
- Arbitrary angle in 360 Degrees (positive = clockwise).
- crop
- if true: keep the size, false: adjust canvas to new size
Returns: A new WriteableBitmap that is a rotated version of the input.
internal static void SetPixel(WriteableBitmap bmp, int x, int y, int color)
WriteableBitmapExtensions.SetPixel(bmp, x, y, color)
Sets the color of the pixel. For best performance this method should not be used in iterative real-time scenarios. Implement the code directly inside a loop.
- bmp
- The WriteableBitmap.
- x
- The x coordinate (row).
- y
- The y coordinate (column).
- color
- The color.
internal static void SetPixel(WriteableBitmap bmp, int x, int y, byte a, Color color)
WriteableBitmapExtensions.SetPixel(bmp, x, y, a, color)
Sets the color of the pixel using an extra alpha value. For best performance this method should not be used in iterative real-time scenarios. Implement the code directly inside a loop.
- bmp
- The WriteableBitmap.
- x
- The x coordinate (row).
- y
- The y coordinate (column).
- a
- The alpha value of the color.
- color
- The color.
internal static void SetPixel(WriteableBitmap bmp, int x, int y, Color color)
WriteableBitmapExtensions.SetPixel(bmp, x, y, color)
Sets the color of the pixel. For best performance this method should not be used in iterative real-time scenarios. Implement the code directly inside a loop.
- bmp
- The WriteableBitmap.
- x
- The x coordinate (row).
- y
- The y coordinate (column).
- color
- The color.
internal static void SetPixel(WriteableBitmap bmp, int x, int y, byte a, byte r, byte g, byte b)
WriteableBitmapExtensions.SetPixel(bmp, x, y, a, r, g, b)
Sets the color of the pixel including the alpha value. For best performance this method should not be used in iterative real-time scenarios. Implement the code directly inside a loop.
- bmp
- The WriteableBitmap.
- x
- The x coordinate (row).
- y
- The y coordinate (column).
- a
- The alpha value of the color.
- r
- The red value of the color.
- g
- The green value of the color.
- b
- The blue value of the color.
internal static void SetPixel(WriteableBitmap bmp, int x, int y, byte r, byte g, byte b)
WriteableBitmapExtensions.SetPixel(bmp, x, y, r, g, b)
Sets the color of the pixel. For best performance this method should not be used in iterative real-time scenarios. Implement the code directly inside a loop.
- bmp
- The WriteableBitmap.
- x
- The x coordinate (row).
- y
- The y coordinate (column).
- r
- The red value of the color.
- g
- The green value of the color.
- b
- The blue value of the color.
internal static void SetPixeli(WriteableBitmap bmp, int index, byte r, byte g, byte b)
WriteableBitmapExtensions.SetPixeli(bmp, index, r, g, b)
Sets the color of the pixel using a precalculated index (faster). For best performance this method should not be used in iterative real-time scenarios. Implement the code directly inside a loop.
- bmp
- The WriteableBitmap.
- index
- The coordinate index.
- r
- The red value of the color.
- g
- The green value of the color.
- b
- The blue value of the color.
internal static void SetPixeli(WriteableBitmap bmp, int index, byte a, Color color)
WriteableBitmapExtensions.SetPixeli(bmp, index, a, color)
Sets the color of the pixel using an extra alpha value and a precalculated index (faster). For best performance this method should not be used in iterative real-time scenarios. Implement the code directly inside a loop.
- bmp
- The WriteableBitmap.
- index
- The coordinate index.
- a
- The alpha value of the color.
- color
- The color.
internal static void SetPixeli(WriteableBitmap bmp, int index, byte a, byte r, byte g, byte b)
WriteableBitmapExtensions.SetPixeli(bmp, index, a, r, g, b)
Sets the color of the pixel including the alpha value and using a precalculated index (faster). For best performance this method should not be used in iterative real-time scenarios. Implement the code directly inside a loop.
- bmp
- The WriteableBitmap.
- index
- The coordinate index.
- a
- The alpha value of the color.
- r
- The red value of the color.
- g
- The green value of the color.
- b
- The blue value of the color.
internal static void SetPixeli(WriteableBitmap bmp, int index, Color color)
WriteableBitmapExtensions.SetPixeli(bmp, index, color)
Sets the color of the pixel using a precalculated index (faster). For best performance this method should not be used in iterative real-time scenarios. Implement the code directly inside a loop.
- bmp
- The WriteableBitmap.
- index
- The coordinate index.
- color
- The color.
internal static void SetPixeli(WriteableBitmap bmp, int index, int color)
WriteableBitmapExtensions.SetPixeli(bmp, index, color)
Sets the color of the pixel using a precalculated index (faster). For best performance this method should not be used in iterative real-time scenarios. Implement the code directly inside a loop.
- bmp
- The WriteableBitmap.
- index
- The coordinate index.
- color
- The color.
internal static byte[] ToByteArray(WriteableBitmap bmp, int count)
result = WriteableBitmapExtensions.ToByteArray(bmp, count)
Copies the Pixels from the WriteableBitmap into a ARGB byte array.
- bmp
- The WriteableBitmap.
- count
- The number of pixels to copy.
Returns: The color buffer as byte ARGB values.
internal static byte[] ToByteArray(WriteableBitmap bmp)
result = WriteableBitmapExtensions.ToByteArray(bmp)
Copies all the Pixels from the WriteableBitmap into a ARGB byte array.
- bmp
- The WriteableBitmap.
Returns: The color buffer as byte ARGB values.
internal static byte[] ToByteArray(WriteableBitmap bmp, int offset, int count)
result = WriteableBitmapExtensions.ToByteArray(bmp, offset, count)
Copies the Pixels from the WriteableBitmap into a ARGB byte array starting at a specific Pixels index.
- bmp
- The WriteableBitmap.
- offset
- The starting Pixels index.
- count
- The number of Pixels to copy, -1 for all
Returns: The color buffer as byte ARGB values.
internal static void WriteTga(WriteableBitmap bmp, Stream destination)
WriteableBitmapExtensions.WriteTga(bmp, destination)
Writes the WriteableBitmap as a TGA image to a stream. Used with permission from Nokola: http://nokola.com/blog/post/2010/01/21/Quick-and-Dirty-Output-of-WriteableBitmap-as-TGA-Image.aspx
- bmp
- The WriteableBitmap.
- destination
- The destination stream.
Fields
private const byte INSIDE
value = WriteableBitmapExtensions.INSIDE
Bitfields used to partition the space into 9 regiond
internal static int[] KernelGaussianBlur3x3
value = WriteableBitmapExtensions.KernelGaussianBlur3x3
Gaussian blur kernel with the size 3x3
internal static int[] KernelGaussianBlur5x5
value = WriteableBitmapExtensions.KernelGaussianBlur5x5
Gaussian blur kernel with the size 5x5
internal static int[] KernelSharpen3x3
value = WriteableBitmapExtensions.KernelSharpen3x3
Sharpen kernel with the size 3x3