SetWorkingImage

The function is used to set the current drawing device.

void SetWorkingImage(IMAGE* pImg = NULL);

Parameters

pImg

The drawing device pointer. If NULL, the drawing 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();
}