Image.h
Go to the documentation of this file.
00001 /* ========================================================================
00002  * Copyright (C) 2004-2005  Graz University of Technology
00003  *
00004  * This framework is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 2 of the License, or
00007  * (at your option) any later version.
00008  *
00009  * This framework is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this framework; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017  *
00018  * For further information please contact Dieter Schmalstieg under
00019  * <schmalstieg@icg.tu-graz.ac.at> or write to Dieter Schmalstieg,
00020  * Graz University of Technology, Institut für Maschinelles Sehen und Darstellen,
00021  * Inffeldgasse 16a, 8010 Graz, Austria.
00022  * ========================================================================
00023  * PROJECT: PocketKnife
00024  * ======================================================================== */
00029 /* ======================================================================== */
00030 
00031 
00032 #ifndef __IMAGE_HEADERFILE__
00033 #define __IMAGE_HEADERFILE__
00034 
00035 #include "PocketKnife.h"
00036 
00037 
00038 namespace PN {
00039 
00041 
00042 class Image
00043 {
00044 public:
00046 
00050         static Image* createFromPixelBuffer(int nWidth, int nHeight, unsigned short* nPixels, bool nOwner);
00051 
00052         virtual ~Image()
00053         {
00054                 if( pixelsOwner )
00055                         delete[] pixels;
00056         }
00057 
00059         int getWidth() const  {  return width;  }
00060 
00062         int getHeight() const  {  return height;  }
00063 
00065         void setTransparentColor(int nRed, int nGreen, int nBlue);
00066 
00068         void clear(int nRed, int nGreen, int nBlue);
00069 
00071         void clear(unsigned short nColor);
00072 
00074 
00081         void drawImage(int nX, int nY, const Image* nImage,
00082                                    int nSx0, int nSy0, int nSx1, int nSy1,
00083                                    bool nTransparent=false);
00084 
00086 
00091         void drawImage(int nX, int nY, const Image* nImage, bool nTransparent=false);
00092 
00093 
00095 
00099         void fillRect(int nX0, int nY0, int nX1, int nY1, int nRed, int nGreen, int nBlue, int nTransparency=0);
00100 
00102 
00106         void fillRect(int nX0, int nY0, int nX1, int nY1, unsigned short nColor, int nTransparency=0);
00107 
00109 
00112         void drawLine(int x1, int y1, int x2, int y2, unsigned short col);
00113 
00115 
00118         void drawLine(int x1, int y1, int x2, int y2, int r, int g, int b);
00119 
00121 
00124         void setPixel(int x, int y, unsigned short col);
00125 
00127 
00130         void setPixel(int x, int y, int r, int g, int b);
00131 
00133         unsigned short*                 getPixels()                     { return pixels; }
00134 
00136         const unsigned short*   getPixels() const       { return pixels; }
00137 
00139 
00142         unsigned short getPixel(int nX, int nY) const  {  return pixels[nY*width+nX];  }
00143 
00145 
00149         void setPixels(int nWidth, int nHeight, unsigned short* nPixels, bool nPixelsOwner);
00150 
00151         unsigned short  getColorKey() const  {  return colorKey;  }
00152 
00153 protected:
00154         Image(int nWidth, int nHeight, unsigned short* nPixels, bool nPixelsOwner)
00155           : width(nWidth), height(nHeight), pixels(nPixels), pixelsOwner(nPixelsOwner)
00156         {}
00157 
00158         // used by Font, initialize from passed Image
00159         Image(Image* nImage)
00160           : width(nImage->width), height(nImage->height), pixels(nImage->pixels), pixelsOwner(true)
00161         {
00162                 nImage->pixelsOwner = false;
00163         }
00164         
00165         int                             width, height;
00166         unsigned short* pixels;
00167         bool                    pixelsOwner;
00168 
00169         unsigned short  colorKey;
00170 };
00171 
00172 }       //namespace PN
00173 
00174 
00175 #endif //__IMAGE_HEADERFILE__


v4r_artoolkitplus
Author(s): Markus Bader
autogenerated on Wed Aug 26 2015 16:41:52