void Ati1X(HDC hdc,wchar_t *szFileName)
{
/*
Starting from this pattern:
A B C
D E F
G H I
The central pixel E is expanded in 4 new pixels:
E0 E1
E2 E3
*/
COLORREF A,B,C,D,E,F,G,H,I,E0,E1,E2,E3;
static CImage imgsrc,imgdes;
static HRESULT isLoad = 1;
COLORREF color;
if(isLoad)
{
isLoad = imgsrc.Load(szFileName);
if(isLoad)assert(0);
imgdes.Create(imgsrc.GetWidth(),imgsrc.GetHeight(),32);
for(int y = 0; y < imgsrc.GetHeight(); y++)
{
for(int x = 0; x < imgsrc.GetWidth(); x++)
{
A = imgsrc.GetPixel(max(0,x-1), max(0,y-1));
B = imgsrc.GetPixel(x, max(0,y-1));
C = imgsrc.GetPixel( min(x+1,imgsrc.GetWidth()-1), max(0,y-1) );
D = imgsrc.GetPixel( max(0,x-1), y );
E = imgsrc.GetPixel( x, y );
F = imgsrc.GetPixel( min(x+1,imgsrc.GetWidth()-1), y );
G = imgsrc.GetPixel( max(0,x-1), min(y+1,imgsrc.GetHeight()-1) );
H = imgsrc.GetPixel( x, min(y+1,imgsrc.GetHeight()-1) );
I = imgsrc.GetPixel( min(x+1,imgsrc.GetWidth()-1), min(y+1,imgsrc.GetHeight()-1) );
E0 = E;
//if( E == 0)
{
if(E != A)
{
if(D == A && A == B)
E0 = A;
}
if( E != C)
{
if(F == C && C == B)
E0 = C;
}
if(E != G)
{
if( D == G && G == H)
E0 = G;
}
if(E != I)
{
if(H == I && I == F)
E0 = I;
}
}
imgdes.SetPixel(x,y,E0);
}
}
wchar_t wszSaveFileName[50] = {0};
wsprintf(wszSaveFileName,L"D://ATI 1X_%ld_%ld.bmp",1,1);
imgdes.Save(wszSaveFileName);
}
imgdes.Draw(hdc,10,10,imgdes.GetWidth(),imgdes.GetHeight());
}