#include "stdafx.h" #include "TransformAPI.h" #include #include #include #include const int bbp = 4; // byte per pixel // calc the start point of the pixel block in DIB LPSTR WINAPI FindDIBBits(LPSTR lpDIB) { return(lpDIB+*(LPDWORD)lpDIB); } // calc the width of the pixel block DWORD WINAPI DIBWidth(LPSTR lpDIB) { LPBITMAPINFOHEADER lpbmi=(LPBITMAPINFOHEADER)lpDIB; return lpbmi->biWidth; } // calc the height of the pixel block DWORD WINAPI DIBHeight(LPSTR lpDIB) { LPBITMAPINFOHEADER lpbmi=(LPBITMAPINFOHEADER)lpDIB; return lpbmi->biHeight; } // perform the GrayImage BOOL WINAPI GrayImage(LPSTR lpDIBBits, LONG lWidth, LONG lHeight) { unsigned char * lpSrcR; // pointing to red component of a pixel unsigned char * lpSrcG; unsigned char * lpSrcB; BYTE bDst; // in VC++, BYTE equals unsigned char LONG i; LONG j; // calc the real width of the pixel block in RAM, because when the DIB is put in RAM, //the number of bytes of each row must be of times of 4 LONG lLineBytes=WIDTHBYTES(lWidth*bbp*8); for(i=0;icArray[i+1]) { cTemp=cArray[i]; cArray[i]=cArray[i+1]; cArray[i+1]=cTemp; bSorted=false; } } } while(!bSorted); cTemp=cArray[(iLen-1)]; return cTemp; } unsigned char WINAPI GetXDerivative(BYTE * cArray, int iLen, int index) { BYTE cTemp; // in VC++, unsigned char equals BYTE return cTemp=cArray[index]; } unsigned char WINAPI GetMedian(BYTE * cArray, int iLen) { int i; bool bSorted; BYTE cTemp; // in VC++, unsigned char equals BYTE // bubble sort do { bSorted=true; for (i=0; icArray[i+1]) { cTemp=cArray[i]; cArray[i]=cArray[i+1]; cArray[i+1]=cTemp; bSorted=false; } } } while(!bSorted); cTemp=cArray[(iLen-1)/2]; return cTemp; }