Bitmap::Clone(constRect&,PixelFormat) method (gdiplusheaders.h)
The Bitmap::Clone method creates a new Bitmap object by copying a portion of this bitmap.
Syntax
Bitmap * Clone(
const Rect & rect,
PixelFormat format
);
Parameters
rect
Reference to a rectangle that specifies the portion of this bitmap to be copied.
format
Integer that specifies the pixel format of the new bitmap. The PixelFormat data type and constants that represent various pixel formats are defined in Gdipluspixelformats.h. For more information about pixel format constants, see Image Pixel Format Constants.
Return value
Type: Bitmap*
This method returns a pointer to the new Bitmap object.
Remarks
Examples
The following example creates a Bitmap object from an image file, clones the upper-left portion of the image, and then draws the cloned image.
VOID Example_Clone(HDC hdc)
{
Graphics graphics(hdc);
// Create a Bitmap object from a JPEG file.
Bitmap bitmap(L"Climber.jpg");
// Clone a portion of the bitmap.
Bitmap* clone = bitmap.Clone(Rect(0, 0, 100, 100), PixelFormatDontCare);
// Draw the clone.
graphics.DrawImage(clone, 0, 0);
delete clone;
}
Requirements
Requirement | Value |
---|---|
Header | gdiplusheaders.h |