SetWorkingImage

This function is used to set current graphics device.

void SetWorkingImage(IMAGE* pImg = NULL);

Parameters

pImg

The graphics device pointer. If NULL, the graphics device is the default graphics window.

Return Value

None

Remarks

If you need to do a drawing operation on an IMAGE, you can set it as the current drawing device through that function, after which all drawing statements are drawn on the IMAGE. Placing parameters as NULL restores drawing operations to the default graphics window.

Examples

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

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

	// Create an img object for 200x200
	IMAGE img(200, 200);
	
	// Set the drawing target to an img object
	SetWorkingImage(&img);
	// The following drawing operations are drawn on top of the img object
	line(0, 100, 200, 100);
	line(100, 0, 100, 200);
	circle(100, 100, 50);

	// Set the drawing target to the graphics window
	SetWorkingImage();
	// Show img objects in the graphics window
	putimage(220, 140, &img);

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