Table of Contents

Class Surface

Namespace
PaintDotNet
Assembly
PaintDotNet.Core.dll

Implements a BGRA32 bitmap used by classic/legacy plugins.

public sealed class Surface : RefTrackedObject, ISerializable, ISurfaceRef<ColorBgra>, IObjectRef, ISurface<ColorBgra>, IRenderer<ColorBgra>, IIsDisposed, IDisposable, ICloneable
Inheritance
Surface
Implements
Inherited Members
Extension Methods

Constructors

Surface(SizeInt32)
Surface(SizeInt32, SurfaceCreationFlags)
Surface(Size)

Creates a new instance of the Surface class.

Surface(Size, SurfaceCreationFlags)
Surface(int, int)
Surface(int, int, SurfaceCreationFlags)

Creates a new instance of the Surface class.

Properties

Bounds

Gets the bounds of this Surface, in pixels.

Height

Gets the height, in pixels, of this Surface.

this[Point]

Gets or sets the pixel value at the requested offset.

this[int, int]

Gets or sets the pixel value at the requested offset.

Scan0

Gets a MemoryBlock which is the buffer holding the pixels associated with this Surface.

Size

Gets the size, in pixels, of this Surface.

Stride

Gets the stride, in bytes, for this Surface.

Width

Gets the width, in pixels, of this Surface.

Methods

Clear()

Clears the surface to transparent black (BGRA = [0, 0, 0, 0]).

ClearWithCheckerboardPattern()
ClearWithCheckerboardPattern(int, int)
Clone()

Creates a new surface with the same dimensions and pixel values as this one.

CopyFromBitmap(Bitmap)

Calls CopyFromBitmap(bitmap, true).

CopyFromBitmap(Bitmap, bool)

Creates a new Surface and copies the pixels from a Bitmap to it.

CopyFromGdipBitmap(Bitmap, bool)
CopyFromGdipImage(Image)
CopyFromGdipImage(Image, bool)
CopySurface(ISurface<ColorBgra>)
CopySurface(ISurface<ColorBgra>, PdnRegion)
CopySurface(ISurface<ColorBgra>, Point2Int32)
CopySurface(ISurface<ColorBgra>, Point2Int32, RectInt32)
CopySurface(ISurface<ColorBgra>, RectInt32)
CopySurface(ISurface<ColorBgra>, RectInt32[])
CopySurface(ISurface<ColorBgra>, RectInt32[], int, int)
CopySurface(ISurface<ColorBgra>, Point)
CopySurface(ISurface<ColorBgra>, Point, Rectangle)
CopySurface(ISurface<ColorBgra>, Rectangle)

Copies the contents of the given surface to the upper left of this surface.

CopySurface(ISurface<ColorBgra>, Rectangle[])
CopySurface(ISurface<ColorBgra>, Rectangle[], int, int)
CopySurface(Surface)

Copies the contents of the given surface to the upper left corner of this surface.

CopySurface(Surface, PdnRegion)

Copies a region of the given surface to this surface.

CopySurface(Surface, Point2Int32)
CopySurface(Surface, Point2Int32, RectInt32)
CopySurface(Surface, RectInt32)
CopySurface(Surface, RectInt32[])
CopySurface(Surface, RectInt32[], int, int)
CopySurface(Surface, Point)

Copies the contents of the given surface to a location within this surface.

CopySurface(Surface, Point, Rectangle)

Copies a rectangular region of the given surface to a specific location on this surface.

CopySurface(Surface, Rectangle)

Copies the contents of the given surface to the upper left of this surface.

CopySurface(Surface, Rectangle[])
CopySurface(Surface, Rectangle[], int, int)

Copies a region of the given surface to this surface.

CreateAliasedBitmap()

Helper function. Same as calling CreateAliasedBounds(Bounds).

CreateAliasedBitmap(RectInt32)
CreateAliasedBitmap(bool)
CreateAliasedBitmap(Rectangle)

Helper function. Same as calling CreateAliasedBounds(bounds, true).

CreateAliasedBitmap(Rectangle, bool)

Creates a GDI+ Bitmap object that aliases the same memory that this Surface does. Then you can use GDI+ to draw on to this surface. Note: Since the Bitmap does not hold a reference to this Surface object, nor to the MemoryBlock that it contains, you must hold a reference to the Surface object for as long as you wish to use the aliased Bitmap. Otherwise the memory may be freed and the Bitmap will look corrupt or cause other errors. You may use the RenderArgs class to help manage this lifetime instead.

CreateSharedBitmap()
CreateWindow(RectInt32)

Creates a Surface that aliases a portion of this Surface.

CreateWindow(Rectangle)

Creates a Surface that aliases a portion of this Surface.

CreateWindow(int, int, int, int)
DetectAndFixDishonestAlpha()

Examines the pixels of this Surface and detects if its contents should be reprocessed.
If all alpha values are 255, then no processing is performed.
If all alpha values are greater than or equal to the color values, then the image is converted from premultiplied alpha.
Otherwise, all alpha values are set to 255 and the color values are untouched.

Dispose(bool)
Fill(ColorBgra)
Fill(PdnRegion, ColorBgra)
Fill(RectInt32, ColorBgra)
Fill(RectInt32[], ColorBgra)
Fill(RectInt32[], int, int, ColorBgra)
Fill(Rectangle, ColorBgra)

Fills the given rectangular region within the surface with the given color value.

FitSurface(ResamplingAlgorithm, Surface)
FitSurface(ResamplingAlgorithm, Surface, FitSurfaceOptions)
FitSurface(ResamplingAlgorithm, Surface, Rectangle)

Fits the source surface to this surface using the given algorithm.

FitSurface(ResamplingAlgorithm, Surface, Rectangle, FitSurfaceOptions)

Fits the source surface to this surface using the given algorithm and options.

GetBilinearSample(float, float)

Gets a bilinear sample from the image.

GetBilinearSampleClamped(float, float)
GetBilinearSampleWrapped(float, float)
GetColumnByteOffset(int)

Gets the number of bytes from the beginning of a row to the requested column.

GetColumnByteOffsetUnchecked(int)

Gets the number of bytes from the beginning of a row to the requested column.

GetPoint(int, int)

Gets the color at a specified point in the surface.

GetPointByteOffset(int, int)

Gets the number of bytes from the beginning of the surface's buffer to the requested point.

GetPointByteOffsetUnchecked(int, int)

Gets the number of bytes from the beginning of the surface's buffer to the requested point.

GetPointPointer(int, int)
GetPointPointerUnchecked(int, int)
GetPointReference(int, int)

Gets the reference of the requested point.

GetPointReferenceUnchecked(int, int)

Gets the reference of the requested point.

GetPointUnchecked(int, int)

Gets the color at a specified point in the surface.

GetRowByteOffset(int)

Gets the offset, in bytes, of the requested row from the start of the surface.

GetRowByteOffsetUnchecked(int)

Gets the offset, in bytes, of the requested row from the start of the surface.

GetRowPointer(int)
GetRowPointerUnchecked(int)
GetRowReference(int)

Gets a reference to the beginning of the requested row in the surface.

GetRowReferenceUnchecked(int)

Gets a reference to the beginning of the requested row in the surface.

IsColumnVisible(int)

Determines if the requested column offset is within bounds.

IsRowVisible(int)

Determines if the requested row offset is within bounds.

IsVisible(Point)

Determines if the requested pixel coordinate is within bounds.

IsVisible(int, int)

Determines if the requested pixel coordinate is within bounds.

Render(RegionPtr<ColorBgra>, Point2Int32)