Method CopyFromBitmap
- Namespace
- PaintDotNet
- Assembly
- PaintDotNet.Core.dll
CopyFromBitmap(Bitmap)
Calls CopyFromBitmap(bitmap, true).
public static Surface CopyFromBitmap(Bitmap bitmap)
Parameters
bitmap
Bitmap
Returns
CopyFromBitmap(Bitmap, bool)
Creates a new Surface and copies the pixels from a Bitmap to it.
public static Surface CopyFromBitmap(Bitmap bitmap, bool detectDishonestAlpha)
Parameters
bitmap
BitmapThe Bitmap to duplicate.
detectDishonestAlpha
boolIf the bitmap has a PixelFormat of PixelFormat.Format32bppRgb, and all alpha values are zero, then the alpha channel will be converted to opaque (all 255). If any alpha values are non-zero, then the alpha channel is retained as-is (the bitmap is treated as if PixelFormat were equal to PixelFormat.Format32bppArgb). The assumption is that an alpha channel that is all-zero or all-255 is "honest", whereas varying alpha values are "dishonest" with respect to the PixelFormat. In the all-zero case, the the alpha channel must be converted to all-255. In the all-255 case, this conversion is unnecessary. With the varying alpha case, it must be assumed that the source of the pixel values was supposed to specify PixelFormat.Format32bppArgb but did not. This will not detect if PixelFormat.Format32bppPArgb should have been specified.
Returns
- Surface
A new Surface that is the same size as the given Bitmap and that has the same pixel values (subject to alpha channel interpretation if detectDishonestAlpha is true, or if the PixelFormat is PixelFormat.Format32bppPArgb).
Remarks
If the bitmap has a PixelFormat of PixelFormat.Format32bppPArgb, then the color values will be converted from premultiplied alpha to straight alpha.