Class GdiPlusExtensions
Extension methods to use GDI+ System.Drawing bitmaps with IGorgonImage
Inherited Members
Namespace: Gorgon.Graphics.Imaging.GdiPlus
Assembly: Gorgon.Graphics.Imaging.dll
Syntax
public static class GdiPlusExtensions
Methods
| Edit this page View SourceCopyTo(IGorgonImageBuffer, Bitmap)
Function to copy the contents of an individual IGorgonImageBuffer to a GDI+ bitmap object.
Declaration
public static void CopyTo(this IGorgonImageBuffer buffer, Bitmap bitmap)
Parameters
Type | Name | Description |
---|---|---|
IGorgonImageBuffer | buffer | The buffer to convert. |
Bitmap | bitmap | The bitmap that will receive the image data. |
Remarks
This method will take a IGorgonImageBuffer and copy its data into a new 2D Bitmap. The buffer
and the bitmap
must have
an identical width and height. Otherwise, an exception will be thrown.
Some format conversion is performed on the buffer
when it is imported. The format conversion will always convert to a pixel format of Format32bppArgb
or
Format24bppRgb
. The following formats are supported for 32 bit conversion:
- R8G8B8A8_UNorm
- R8G8B8A8_UNorm_SRgb
- R8G8B8A8_SInt
- R8G8B8A8_SNorm
- R8G8B8A8_UInt
- R8G8B8A8_Typeless
- B8G8R8A8_UNorm
- B8G8R8A8_UNorm_SRgb
- B8G8R8A8_Typeless
- B8G8R8X8_UNorm
- B8G8R8X8_UNorm_SRgb
- B8G8R8X8_Typeless
If the source buffer
does not support any of the formats on the lists, then an exception will be thrown.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
ArgumentException | Thrown if the |
GorgonException | Thrown if the -or- Thrown when the |
CopyTo(Bitmap, IGorgonImageBuffer)
Function to copy the contents of a GDI+ bitmap object to an individual IGorgonImageBuffer.
Declaration
public static void CopyTo(this Bitmap bitmap, IGorgonImageBuffer buffer)
Parameters
Type | Name | Description |
---|---|---|
Bitmap | bitmap | The bitmap to convert. |
IGorgonImageBuffer | buffer | The buffer to that will receive the image data. |
Remarks
This method will take a IGorgonImageBuffer and copy its data into a new 2D Bitmap. The buffer
and the bitmap
must have
an identical width and height. Otherwise, an exception will be thrown.
Some format conversion is performed on the buffer
when it is imported. The format conversion will always convert to a pixel format of Format32bppArgb
or
Format24bppRgb
. The following formats are supported for 32 bit conversion:
- R8G8B8A8_UNorm
- R8G8B8A8_UNorm_SRgb
- R8G8B8A8_SInt
- R8G8B8A8_SNorm
- R8G8B8A8_UInt
- R8G8B8A8_Typeless
- B8G8R8A8_UNorm
- B8G8R8A8_UNorm_SRgb
- B8G8R8A8_Typeless
- B8G8R8X8_UNorm
- B8G8R8X8_UNorm_SRgb
- B8G8R8X8_Typeless
If the source buffer
does not support any of the formats on the lists, then an exception will be thrown.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
ArgumentException | Thrown if the |
GorgonException | Thrown if the -or- Thrown when the |
ToBitmap(IGorgonImageBuffer)
Function to convert an individual IGorgonImageBuffer to a GDI+ bitmap object.
Declaration
public static Bitmap ToBitmap(this IGorgonImageBuffer buffer)
Parameters
Type | Name | Description |
---|---|---|
IGorgonImageBuffer | buffer | The buffer to convert. |
Returns
Type | Description |
---|---|
Bitmap | A new GDI+ bitmap object. |
Remarks
This method will take a IGorgonImageBuffer and copy its data into a new 2D Bitmap.
Some format conversion is performed on the buffer
when it is imported. The format conversion will always convert to a pixel format of Format32bppArgb
or
Format24bppRgb
. The following formats are supported for 32 bit conversion:
- R8G8B8A8_UNorm
- R8G8B8A8_UNorm_SRgb
- R8G8B8A8_SInt
- R8G8B8A8_SNorm
- R8G8B8A8_UInt
- R8G8B8A8_Typeless
- B8G8R8A8_UNorm
- B8G8R8A8_UNorm_SRgb
- B8G8R8A8_Typeless
If the source buffer
does not support any of the formats on the lists, then an exception will be thrown.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
GorgonException | Thrown if the |
ToGorgonImage(Bitmap)
Function to convert a Bitmap into a IGorgonImage.
Declaration
public static IGorgonImage ToGorgonImage(this Bitmap bitmap)
Parameters
Type | Name | Description |
---|---|---|
Bitmap | bitmap | The Bitmap to convert. |
Returns
Type | Description |
---|---|
IGorgonImage | A new IGorgonImage containing the data from the Bitmap. |
Remarks
This method will take a 2D Bitmap and copy its data into a new 2D IGorgonImage. The resulting IGorgonImage will only contain 1 array level, and no mip map levels.
Some format conversion is performed on the bitmap
when it is imported. The format conversion will always convert to the image format of
R8G8B8A8_UNorm. Only the following GDI+ pixel formats are supported for conversion:
bitmap
does not support any of the formats on the list, then an exception will be thrown.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown when the |
GorgonException | Thrown if the |