//This file is part of Photon (http://photon.sourceforge.net) //Copyright (C) 2004-2005 James Turk // // Author: // James Turk (jpt2433@rit.edu) // // Version: // $Id: Image.hpp,v 1.3 2005/11/13 07:59:49 cozman Exp $ #ifndef PHOTON_VIDEO_IMAGE_HPP #define PHOTON_VIDEO_IMAGE_HPP #include "video/Texture.hpp" namespace photon { namespace video { // Class: Image // Image is a class which is used to store a single image, for use in 2D games. // // Image is derived from , which is a resource managed class. // An Image simply adds the ability to draw to a quad, as well as some scaling, // rotation, per-vertex tinting, and several other bonuses. // // Since Image is a child of , all memory management is taken // care of. // // Operators: // - Image = Image // - bool : True if texture is loaded, false if not. class Image : public Texture { // Group: (Con/De)structors public: // Function: Image // Default constructor, initalizes internal state of Image. Image(); // Function: Image // Copy constructor, copies another Image. // // Parameters: // rhs - Image to construct copy of. Image(const Image &rhs); // Function: Image // Initializing constructor, loads Image via call to . // // Parameters: // name - Name of the Image to open. // // See Also: // Image(const std::string& name); Image& operator=(const Image &rhs); // Group: General public: // Function: open // Opens an image file, currently supported image types are BMP, GIF, JPEG, // PCX, PNG, and TGA. (Images can be any dimensions) // // Loading is done via Corona () // // Parameters: // name - Name of the Image to open. void open(const std::string& name); // Function: setAlpha // Sets alpha-component for Image to be used when surface is drawn. // // Parameters: // alpha - Desired surface-wide alpha component for Image. void setAlpha(ubyte alpha); // Function: flip // Flips image, horizontally and/or vertically. // // Parameters: // horizontal - True if a flip over horizontal axis is desired. // vertical - True if a flip over vertical axis is desired. void flip(bool horizontal, bool vertical); // Function: stretch // Stretch image by a given factor. // For example: 1 = no change, .5 = 50% current size, 10 = 10 times current // size. // // Parameters: // xFactor - Factor for horizontal stretch. // yFactor - Factor for vertical stretch. void stretch(scalar xFactor, scalar yFactor); // Function: resize // Resize the image to a specific size. // // Parameters: // width - New desired with for image. // height - New desired height for image. void resize(scalar width, scalar height); // Group: Drawing public: // Function: draw // draws image to the screen at a givem positon. // // Parameters: // x - X position to draw image at. // y - Y position to draw image at. void draw(scalar x, scalar y) const; // Function: draw // Draw image to screen at given position. // // This version has an extra parameter, a color vertex option. The 3rd // parameter is an array of 16 defining, // Starting in the top left corner & going counterclockwise, tint colors // for the image. It is possible to make very nice effects with little // effort via this option. Things like shading and lighting can be bluffed // using this technique. // // There are versions of and that have the vc // parameter which works in the same manner. // // Parameters: // x - X position to draw image at. // y - Y position to draw image at. // vc - Array of 16 defining the colors of the 4 vertices in // clockwise order. (Order: R1,G1,B1,A1,...B4,A4) void draw(scalar x, scalar y, ubyte vc[]) const; // Function: drawRotated // Draw image, rotated about it's own center by a specified angle. // // Parameters: // x - X position to draw image at. (before rotation) // y - Y position to draw image at. (before rotation) // angle - Angle (in degrees) to rotate image. void drawRotated(scalar x, scalar y, scalar angle) const; // Function: drawRotated // Draw image, rotated about it's own center by a specified angle. // Includes color vertex option. // // Parameters: // x - X position to draw image at. (before rotation) // y - Y position to draw image at. (before rotation) // angle - Angle (in degrees) to rotate image. // vc - Array of 16 defining the colors of the 4 vertices in // clockwise order. (Order: R1,G1,B1,A1,...B4,A4) void drawRotated(scalar x, scalar y, scalar angle, ubyte vc[]) const; // Group: Accessors public: // Function: getAlpha // Get current surface-wide alpha value for image. // // Returns: // Current surface-wide alpha. // // See Also: // ubyte getAlpha() const; friend std::ostream& operator<<(std::ostream &o, const Image &rhs); private: ubyte alpha_; int texMinX_; int texMinY_; int texMaxX_; int texMaxY_; scalar width_; scalar height_; }; } } #endif //PHOTON_VIDEO_IMAGE_HPP