GetImageHDC

This function is used to get the graphics device handle.

HDC GetImageHDC(IMAGE* pImg = NULL);

Parameters

pImg

The drawing device pointer. If NULL, represents the default graphics window.

Return Value

The graphics device handle (HDC).

Remarks

Get stake in the HDC handle that can be used in the Windows GDI function.

Each IMAGE object has an HDC handle that allows you to perform GDI function operations on the IMAGE. In the same IMAGE device, do not mix easyX drawing functions with GDI drawing functions.

Examples

#include <graphics.h>
#include <conio.h>

int main()
{
	// Initialize the graphics window
	initgraph(640, 480);


	// Get the HDC handle to the default graphics window
	HDC hdc = GetImageHDC();

	// Perform ingress ingress functions of Windows GDI
	MoveToEx(hdc, 10, 10, NULL);
	LineTo(hdc, 100, 100);

	// Create an img object with a size 200x200
	IMAGE img(200, 200);

	// Get the HDC handle for the img object
	hdc = GetImageHDC(&img);

	// Perform ingress ingress functions of Windows GDI
	Ellipse(hdc, 0, 50, 199, 150);

	// Show img objects above the graphics window
	putimage(100, 0, &img);


	// Press any key to exit
	_getch();
	closegraph();
}
(贡献者:Krissi  编辑