Skip to content

Latest commit

 

History

History
268 lines (217 loc) · 7.58 KB

nf-winuser-copyimage.md

File metadata and controls

268 lines (217 loc) · 7.58 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist ms.custom f1_keywords dev_langs topic_type api_type api_location api_name req.apiset
NF:winuser.CopyImage
CopyImage function (winuser.h)
Creates a new image (icon, cursor, or bitmap) and copies the attributes of the specified image to the new one. If necessary, the function stretches the bits to fit the desired size of the new image.
CopyImage
CopyImage function [Menus and Other Resources]
IMAGE_BITMAP
IMAGE_CURSOR
IMAGE_ICON
LR_COPYDELETEORG
LR_COPYFROMRESOURCE
LR_COPYRETURNORG
LR_CREATEDIBSECTION
LR_DEFAULTSIZE
LR_MONOCHROME
_win32_CopyImage
_win32_copyimage_cpp
menurc.copyimage
winui._win32_copyimage
winuser/CopyImage
menurc\copyimage.htm
menurc
VS|winui|~\winui\windowsuserinterface\resources\introductiontoresources\resourcereference\resourcefunctions\copyimage.htm
12/05/2018
CopyImage, CopyImage function [Menus and Other Resources], IMAGE_BITMAP, IMAGE_CURSOR, IMAGE_ICON, LR_COPYDELETEORG, LR_COPYFROMRESOURCE, LR_COPYRETURNORG, LR_CREATEDIBSECTION, LR_DEFAULTSIZE, LR_MONOCHROME, _win32_CopyImage, _win32_copyimage_cpp, menurc.copyimage, winui._win32_copyimage, winuser/CopyImage
winuser.h
Windows.h
Windows
Windows 2000 Professional [desktop apps only]
Windows 2000 Server [desktop apps only]
User32.lib
User32.dll
Windows
19H1
CopyImage
winuser/CopyImage
c++
APIRef
kbSyntax
DllExport
User32.dll
ext-ms-win-ntuser-gui-l1-2-1.dll
Ext-MS-Win-NTUser-Gui-L1-3-0.dll
CopyImage
ext-ms-win-ntuser-gui-l1-3-0 (introduced in Windows 10, version 10.0.10240)

CopyImage function

-description

Creates a new image (icon, cursor, or bitmap) and copies the attributes of the specified image to the new one. If necessary, the function stretches the bits to fit the desired size of the new image.

-parameters

-param h [in]

Type: HANDLE

A handle to the image to be copied.

-param type [in]

Type: UINT

The type of image to be copied. This parameter can be one of the following values.

Value Meaning
IMAGE_BITMAP
0
Copies a bitmap.
IMAGE_CURSOR
2
Copies a cursor.
IMAGE_ICON
1
Copies an icon.

-param cx [in]

Type: int

The desired width, in pixels, of the image. If this is zero, then the returned image will have the same width as the original hImage.

-param cy [in]

Type: int

The desired height, in pixels, of the image. If this is zero, then the returned image will have the same height as the original hImage.

-param flags [in]

Type: UINT

This parameter can be one or more of the following values.

Value Meaning
LR_COPYDELETEORG
0x00000008
Deletes the original image after creating the copy.
LR_COPYFROMRESOURCE
0x00004000
Tries to reload an icon or cursor resource from the original resource file rather than simply copying the current image. This is useful for creating a different-sized copy when the resource file contains multiple sizes of the resource. Without this flag, CopyImage stretches the original image to the new size. If this flag is set, CopyImage uses the size in the resource file closest to the desired size. This will succeed only if hImage was loaded by LoadIcon or LoadCursor, or by LoadImage with the LR_SHARED flag.
LR_COPYRETURNORG
0x00000004
Returns the original hImage if it satisfies the criteria for the copy—that is, correct dimensions and color depth—in which case the LR_COPYDELETEORG flag is ignored. If this flag is not specified, a new object is always created.
LR_CREATEDIBSECTION
0x00002000
If this is set and a new bitmap is created, the bitmap is created as a DIB section. Otherwise, the bitmap image is created as a device-dependent bitmap. This flag is only valid if uType is IMAGE_BITMAP.
LR_DEFAULTCOLOR
0x00000000
Uses the default color format.
LR_DEFAULTSIZE
0x00000040
Uses the width or height specified by the system metric values for cursors or icons, if the cxDesired or cyDesired values are set to zero. If this flag is not specified and cxDesired and cyDesired are set to zero, the function uses the actual resource size. If the resource contains multiple images, the function uses the size of the first image.
LR_MONOCHROME
0x00000001
Creates a new monochrome image.

-returns

Type: HANDLE

If the function succeeds, the return value is the handle to the newly created image.

If the function fails, the return value is NULL. To get extended error information, call GetLastError.

-remarks

When you are finished using the resource, you can release its associated memory by calling one of the functions in the following table.

Resource Release function
Bitmap DeleteObject
Cursor DestroyCursor
Icon DestroyIcon
 

The system automatically deletes the resource when its process terminates, however, calling the appropriate function saves memory and decreases the size of the process's working set.

-see-also

Conceptual

LoadImage

Reference

Resources