#include "gobjects.h"

class GImage : public GObject

This graphical object subclass represents an image from a file. For example, the following code displays a GImage 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)
GImage(filenamexy) 
Constructs a new image by loading the image from the specified file, which is either in the current directory or a subdirectory named images.

Constructor detail


GImage(string filename);
GImage(string filename, double x, double 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. 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);