CreateNewGdPictureImage(Int32,Int32,Int16,Color) Method
In This Topic
Creates a new empty GdPicture image with specific dimensions, bit depth (bits per pixel), and a background color. The newly created image is identified by its unique non-zero image identifier.
Please note that it is your responsibility to release the image resources once you have no use for them.
Syntax
'Declaration
Public Overloads Function CreateNewGdPictureImage( _
ByVal As Integer, _
ByVal As Integer, _
ByVal As Short, _
ByVal As Color _
) As Integer
public int CreateNewGdPictureImage(
int ,
int ,
short ,
Color
)
public function CreateNewGdPictureImage(
: Integer;
: Integer;
: Int16;
: Color
): Integer;
public function CreateNewGdPictureImage(
: int,
: int,
: short,
: Color
) : int;
public: int CreateNewGdPictureImage(
int ,
int ,
short ,
Color
)
public:
int CreateNewGdPictureImage(
int ,
int ,
short ,
Color
)
Parameters
- Width
- The width, in pixels, of the newly created image.
- Height
- The height, in pixels, of the newly created image.
- BitDepth
- The required bit depth of the newly created image.
- BackColor
- A color object that defines the background color of the newly created image. This parameter is ignored for indexed bitmap.
You can obtain a suitable color using the one of the ARGB() overloads.
Return Value
A unique image identifier of the GdPicture image representing the newly created image. The returned value is non-zero if the image is successfully created. Please first of all use the
GdPictureImaging.GetStat method to determine if this method has been successful.
Be aware that you need to release the image resource with the GdPictureImaging.ReleaseGdPictureImage method after being used.
Example
Rendering an image with a circle onto the background image and saving the result into a png file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
Color backColor = gdpictureImaging.ARGB(255, 0, 255, 0); // Green color
Color circleColor = gdpictureImaging.ARGB(255, 255, 0, 0); // Red color
// Create a background image.
int backImage = gdpictureImaging.CreateNewGdPictureImage(320, 200, 32, backColor);
// Create an image used for drawing, and draw a circle on it.
int circleImage = gdpictureImaging.CreateNewGdPictureImage(80, 80, 32, gdpictureImaging.ARGB(0, 0, 0, 0));
gdpictureImaging.DrawFilledCircle(circleImage, 40, 40, 60, circleColor, false);
// Draw an image with a circle onto the background image.
gdpictureImaging.DrawGdPictureImage(circleImage, backImage, 0, 0, 80, 80, System.Drawing.Drawing2D.InterpolationMode.Default);
gdpictureImaging.SaveAsPNG(backImage, "output.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(circleImage);
gdpictureImaging.ReleaseGdPictureImage(backImage);
}
Example
Rendering an image with a circle onto the background image and saving the result into a png file.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
Color backColor = gdpictureImaging.ARGB(255, 0, 255, 0); // Green color
Color circleColor = gdpictureImaging.ARGB(255, 255, 0, 0); // Red color
// Create a background image.
int backImage = gdpictureImaging.CreateNewGdPictureImage(320, 200, 32, backColor);
// Create an image used for drawing, and draw a circle on it.
int circleImage = gdpictureImaging.CreateNewGdPictureImage(80, 80, 32, gdpictureImaging.ARGB(0, 0, 0, 0));
gdpictureImaging.DrawFilledCircle(circleImage, 40, 40, 60, circleColor, false);
// Draw an image with a circle onto the background image.
gdpictureImaging.DrawGdPictureImage(circleImage, backImage, 0, 0, 80, 80, System.Drawing.Drawing2D.InterpolationMode.Default);
gdpictureImaging.SaveAsPNG(backImage, "output.png");
// Release used resources.
gdpictureImaging.ReleaseGdPictureImage(circleImage);
gdpictureImaging.ReleaseGdPictureImage(backImage);
}
See Also