Cximage에 필터와 bmp함수에 대해 자세한 설명 부탁드립니다
새콤이
CximageBMP함수 입니다class CxImageBMP: public CxImage
{
public:
CxImageBMP(): CxImage(CXIMAGE_FORMAT_BMP) {};
bool Decode(CxFile * hFile);
bool Decode(FILE *hFile) { CxIOFile file(hFile); return Decode(&file); }
bool Encode(CxFile * hFile);
bool Encode(FILE *hFile) { CxIOFile file(hFile); return Encode(&file); }
protected:
bool DibReadBitmapInfo(CxFile* fh, BITMAPINFOHEADER *pdib);
};
--------------------------------------------------------------------------------------------------------
Cximage Filter함수입니다
bool CxImage::Filter(long* kernel, long Ksize, long Kfactor, long Koffset)
{
if (!pDib) return false;
long k2 = Ksize/2;
long kmax= Ksize-k2;
long r,g,b,i;
RGBQUAD c;
CxImage tmp(*this,pSelection!=0,true,true);
long xmin,xmax,ymin,ymax;
if (pSelection){
xmin = info.rSelectionBox.left; xmax = info.rSelectionBox.right;
ymin = info.rSelectionBox.bottom; ymax = info.rSelectionBox.top;
} else {
xmin = ymin = 0;
xmax = head.biWidth; ymax=head.biHeight;
}
for(long y=ymin; yymax; y++){
info.nProgress = (long)(100*y/head.biHeight);
if (info.nEscape) break;
for(long x=xmin; xxmax; x++){
#if CXIMAGE_SUPPORT_SELECTION
if (SelectionIsInside(x,y))
#endif //CXIMAGE_SUPPORT_SELECTION
{
r=b=g=0;
for(long j=-k2;jkmax;j++){
for(long k=-k2;kkmax;k++){
c=GetPixelColor(x+j,y+k);
i=kernel[(j+k2)+Ksize*(k+k2)];
r += c.rgbRed * i;
g += c.rgbGreen * i;
b += c.rgbBlue * i;
}
}
if (Kfactor==0){
c.rgbRed = (BYTE)min(255, max(0,(int)(r + Koffset)));
c.rgbGreen = (BYTE)min(255, max(0,(int)(g + Koffset)));
c.rgbBlue = (BYTE)min(255, max(0,(int)(b + Koffset)));
} else {
c.rgbRed = (BYTE)min(255, max(0,(int)(r/Kfactor + Koffset)));
c.rgbGreen = (BYTE)min(255, max(0,(int)(g/Kfactor + Koffset)));
c.rgbBlue = (BYTE)min(255, max(0,(int)(b/Kfactor + Koffset)));
}
tmp.SetPixelColor(x,y,c);
}
}
}
Transfer(tmp);
return true;
}