//////////////////////////////////////////////////////////////////////////// // PGimage.hh // // Paul McCartney, January 1996 // // Copyright 1996, Washington University Computer Science Department // All Rights Reserved // // RCS: $Id: PGimage.hh,v 1.4 1996/08/22 19:03:00 paul Exp paul $ // // This defines the PGimage class. The purpose of PGimage is to be a wrapper // to manage the sending and receiving of an image using Playground data // structures. Internally, memory blocks are is used to store the images, // since this is the most efficient way to send and receive data. // // A pixel value represents an index into a color table, rather than an // actual color value. Each pixel of an image is represented as an unsigned // char, so the images are restricted to 8-bit color values. // // Unlike other Playground data types, I/O is handled explicitly by the // programmer. That is, current working data is local and is only sent // out to external module when the "SendImage" and "SendColorTable" methods // are invoked. Similarly, values are only received when the "Receive" // method is invoked. This ensures efficient, atomic operations. //////////////////////////////////////////////////////////////////////////// #ifndef PGIMAGE_HH #define PGIMAGE_HH #include "PG.hh" class PGimage; class PGimage : public PGtuple { public: PGimage(); PGimage(const PGimage& image); PGimage& operator=(const PGimage& image); // *** FIELDS *** PGint id; // ID, for use with a series of images PGint width, height; // size of the image PGint options; PGmemoryBlock pixels; // pixel data of the image PGmemoryBlock colors; // color table, containing rgb pixel values // *** ACCESSORS: WRITE *** void SetSize(int w, int h); void SetColorTableSize(int size); int ColorTableSize(); void SetPixel(int x, int y, unsigned char pixel); void SetColorEntry(int index, int red, int green, int blue); // *** ACCESSORS: READ *** unsigned char GetPixel(int x, int y); void GetColorEntry(int index, int& red, int& green, int& blue); // *** Playground I/O *** void Send(); }; #endif