SimpleCxxLib packageclass GImage : public GObjectGImage
containing the Stanford tree at the center of the window, assuming
that the image file StanfordTree.png exists, either in
the current directory or an images subdirectory:
int main() {
GWindow gw;
cout << "This program draws the Stanford tree." << endl;
GImage *tree = new GImage("StanfordTree.png");
double x = (gw.getWidth() - tree->getWidth()) / 2;
double y = (gw.getHeight() - tree->getHeight()) / 2;
gw.add(tree, x, y);
return 0;
}
| Constructor | |
GImage(filename, x, y) | Constructs a new image by loading the image from the specified file, which is either in the current directory or a subdirectory named images. |
GImage(string filename); GImage(string filename, double x, double y);
images. By default, the upper left corner of the image
appears at the origin; the second form automatically sets the location
to the point (x, y).
Usage:
GImage *image = new GImage(filename); GImage *image = new GImage(filename, x, y);