ImageTool.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 
00033 #ifndef __IMAGETOOL_HEADERFILE__
00034 #define __IMAGETOOL_HEADERFILE__
00035 
00036 #include "PocketKnife.h"
00037 #include "Image.h"
00038 
00039 
00040 namespace PN
00041 {
00042 
00043 
00045 namespace ImageTool
00046 {
00047 
00049 
00053         void flipImageY(unsigned char* nDstBuffer, unsigned const char* nSrcBuffer, int nWidth, int nHeight, int nPixelSize);
00054 
00055 
00057         inline unsigned short convertPixel24To16(int nRed, int nGreen, int nBlue)
00058         {
00059                 return (unsigned short)(((nRed << 8) & RED_MASK) | ((nGreen << 3) & GREEN_MASK) | (nBlue >> 3));
00060         }
00061 
00062 
00064         inline void convertPixel16To24(unsigned short nPixel, unsigned char& nRed, unsigned char& nGreen, unsigned char& nBlue)
00065         {
00066                 nRed =   (unsigned char)((nPixel&RED_MASK) >> 8);
00067                 nGreen = (unsigned char)((nPixel&GREEN_MASK) >> 3);
00068                 nBlue =  (unsigned char)((nPixel&BLUE_MASK) << 3);
00069         }
00070 
00071 
00073         inline unsigned short blendPixel16(unsigned short nSrc, unsigned short nDst, int nOpacity)
00074         {
00075                 // shamelessly stolen from Thierry Tremblay's PocketFrog...
00076                 //
00077                 unsigned short RB1 = (unsigned short)(nDst & (RED_MASK | BLUE_MASK));
00078                 unsigned short G1  = (unsigned short)(nDst & (GREEN_MASK ));
00079                 unsigned short RB2 = (unsigned short)(nSrc & (RED_MASK | BLUE_MASK));
00080                 unsigned short G2  = (unsigned short)(nSrc & (GREEN_MASK));
00081                 unsigned short RB = (unsigned short)(RB1 + (((RB2-RB1) * (nOpacity>>3)) >> 5));
00082                 unsigned short G  = (unsigned short)(G1 + (((G2-G1)*(nOpacity>>2))>>6));
00083 
00084                 RB &= (RED_MASK | BLUE_MASK);
00085                 G  &= (GREEN_MASK);
00086 
00087                 return (unsigned short)(RB | G);
00088         }
00089 
00090 
00092 
00095         bool saveAsTGA(Image* nImage, const char* nFileName);
00096 
00097 
00098 };      // namespace ImageTool
00099 
00100 
00101 }; // namespace PN
00102 
00103 
00104 #endif //__IMAGETOOL_HEADERFILE__


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