Windows Dev Center

Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Bitmap.Clone(INT, INT, INT, INT, PixelFormat) method

Applies to: desktop apps only

The Bitmap::Clone method creates a new Bitmap object by copying a portion of this bitmap.

Syntax

Bitmap* Clone(
  [in]  INT x,
  [in]  INT y,
  [in]  INT width,
  [in]  INT height,
  [in]  PixelFormat format
);

Parameters

x [in]

Type: INT

Integer that specifies the x-coordinate of the upper-left corner of the rectangle that specifies the portion of this bitmap to copy.

y [in]

Type: INT

Integer that specifies the y-coordinate of the upper-left corner of the rectangle that specifies the portion of this bitmap to copy.

width [in]

Type: INT

Integer that specifies the width of the rectangle that specifies the portion of this bitmap to copy.

height [in]

Type: INT

Integer that specifies the height of the rectangle that specifies the portion of this image to copy.

format [in]

Type: PixelFormat

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:

Type: Bitmap*

This method returns a pointer to the new Bitmap object.

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_Clone3(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(0, 0, 100, 100, PixelFormatDontCare);

   // Draw the clone.
   graphics.DrawImage(clone, 0, 0);
   
   delete clone;
}

Requirements

Minimum supported client

Windows XP, Windows 2000 Professional

Minimum supported server

Windows 2000 Server

Product

GDI+ 1.0

Header

Gdiplusheaders.h (include Gdiplus.h)

Library

Gdiplus.lib

DLL

Gdiplus.dll

See also

Bitmap
Bitmap Constructors
Clone
Image
Image Pixel Format Constants
Using Images, Bitmaps, and Metafiles
Images, Bitmaps, and Metafiles

 

 

Send comments about this topic to Microsoft

Build date: 3/6/2012

Community Additions

Show:
© 2015 Microsoft