00001
00036 #ifdef _WINDOWS
00037 #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
00038 #include <windows.h>
00039 #else
00040 #include <stdio.h>
00041 #endif
00042
00043 #include <string.h>
00044 #include <stdlib.h>
00045
00046 #include "PicCropperRGB24Impl.h"
00047
00048
00049
00050
00051
00052
00062 int PicCropperRGB24Impl::Crop(void* pInImg, void* pImg)
00063 {
00064 if( (pImg == NULL) || (pInImg == NULL) )
00065 return(0);
00066
00068 int writeWidth = _widthIn - _byX1 - _byX2;
00069 int writeHeight = _heightIn - _byY1 - _byY2;
00070 if( (writeWidth < 0) || (writeHeight < 0) )
00071 return(0);
00072 if(writeWidth > _widthOut) writeWidth = _widthOut;
00073 if(writeHeight > _heightOut) writeHeight = _heightOut;
00074
00076 unsigned char* pSrc = (unsigned char*)pInImg + 3*((_byY1*_widthIn) + _byX1);
00077 unsigned char* pDst = (unsigned char*)pImg;
00078
00079 for(int y = 0; y < writeHeight; y++)
00080 {
00081 memcpy((void *)pDst, (const void *)pSrc, 3*writeWidth);
00082 pDst += (3*_widthOut);
00083 pSrc += (3*_widthIn);
00084 }
00085
00086 return(1);
00087 }
00088