IMAGE

The image object.

class IMAGE(int width = 0, int height = 0);

Public members

int getwidth();

Returns the width of the IMAGE object, in pixels.

int getheight();

Returns the height of the IMAGE object, in pixels.

operator =

Implements a direct assignment of an IMAGE object. This operation only copies the contents of the source image, no graphics environment.

Examples

The following snippet creates two objects, img1, img2, then loads the picture test.jpg to img1 and copies the contents of img1 to img2 by assignment:

IMAGE img1, img2;
loadimage(&img1, _T("test.jpg"));
img2 = img1;

The following snippet creates the img object, then loads the picture test.jpg and assigns the width and height of the picture to the variables w, h:

IMAGE img;
loadimage(&img, _T("test.jpg"));
int w, h;
w = img.getwidth();
h = img.getheight();

For more examples, refer to the putimage function example.

(贡献者:Krissi  编辑