19,468
社区成员
发帖
与我相关
我的任务
分享
BOOL Outline24(LPSTR lpDIBBits, LONG lmageWidth, LONG lmageHeight)
{
unsigned char* lpSrc;
unsigned char* lpDst;
LPBYTE lpImage;
int i;
int j;
long lLineBytes = (lmageWidth*24 + 31)/32*4;
lpImage = (LPBYTE) new char[lLineBytes*lmageHeight];
if (lpImage == NULL)
return FALSE;
lpDst = (unsigned char *)lpImage;
memset(lpDst, (BYTE)255, lLineBytes * lmageHeight);
unsigned char r,g,b,r1,g1,b1;
for(j = 1; j <lmageHeight; j++)
{
for(i = 1;i <lmageWidth; i++)
{
lpSrc = (unsigned char *)(lpDIBBits + lLineBytes * j + i*3);
lpDst = (unsigned char *)(lpImage + lLineBytes * j + i*3);
r = (unsigned char)*lpSrc;
lpSrc++;
g = (unsigned char)*lpSrc;
lpSrc++;
b = (unsigned char)*lpSrc;
int I=0;
for(int k=i-1;k <i+2;k++)
for(int l=j-1;l <j+2;l++)//注意这里是l++
{
if(k>=0 && l>=0 && k <lmageWidth && l <lmageHeight)
{
r1=*(lpDIBBits+l*lLineBytes+k*3);
g1=*(lpDIBBits+l*lLineBytes+k*3+1);
b1=*(lpDIBBits+l*lLineBytes+k*3+2);
if(abs(r-r1) <10&&abs(g-g1) <10&&abs(b-b1) <10)
I++;
}
}
if(I!=9)
{
*lpDst=*lpSrc;
*(lpDst+1)=*(lpSrc+1);
*(lpDst+2)=*(lpSrc+2);
}
else
{
*lpDst=255;
*(lpDst+1)=255;
*(lpDst+2)=255;
}
}
}
memcpy(lpDIBBits, lpImage, lLineBytes * lmageHeight);
delete[] lpImage;
return TRUE;
}