Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
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
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 };
00099
00100
00101 };
00102
00103
00104 #endif //__IMAGETOOL_HEADERFILE__