|
int ImageWidth = Image1->Width;
int ImageHeight = Image1->Height;
BYTE* SourcePtr = new BYTE[ImageWidth*ImageHeight];
BYTE* ResultPtr = new BYTE[ImageWidth*ImageHeight];
RGBTRIPLE * rtColor;
for (int y=0; y<ImageHeight; y++)
{
rtColor = (RGBTRIPLE *) Image1->Picture->Bitmap->ScanLine[y];
for (int x=0; x<ImageWidth; x++)
{
SourcePtr[y*ImageWidth +x]=(rtColor[x].rgbtRed +
rtColor[x].rgbtBlue +
rtColor[x].rgbtGreen)/3;
}
}
for(int x=1; x<ImageWidth-1; x++)
{
for(int y=1; y<ImageHeight-1; y++)
{
if(SourcePtr[y*ImageWidth +x]==255)
{
if(SourcePtr[(y-1)*ImageWidth +x-1]==0||
SourcePtr[(y-1)*ImageWidth +x ]==0||
SourcePtr[(y-1)*ImageWidth +x+1]==0||
SourcePtr[(y )*ImageWidth +x-1]==0||
SourcePtr[(y )*ImageWidth +x ]==0||
SourcePtr[(y )*ImageWidth +x+1]==0||
SourcePtr[(y+1)*ImageWidth +x-1]==0||
SourcePtr[(y+1)*ImageWidth +x ]==0||
SourcePtr[(y+1)*ImageWidth +x+1]==0 )
ResultPtr[y*ImageWidth +x] = 255;
else ResultPtr[y*ImageWidth +x] = 0;
}
else ResultPtr[y*ImageWidth +x] = 0;
}
}
for (int y=1; y<ImageHeight-1; y++)
{
rtColor = (RGBTRIPLE *) Image1->Picture->Bitmap->ScanLine[y];
for (int x=1; x<ImageWidth-1; x++)
{
if(ResultPtr[y*ImageWidth+x]==255)
{
rtColor[x].rgbtRed = 255;
rtColor[x].rgbtBlue = 0;
rtColor[x].rgbtGreen = 0;
}
}
}
Image1->Invalidate();
delete SourcePtr;
delete ResultPtr;
정구일 님이 쓰신 글 :
: 이렇게 관심 가져 주셔서 정말 감사합니다 ^^;
:
: 우선 어려운 소스는 제가 #include <vcl.h> 해더 파일을 처음 보는거라서요.
:
: #pragma package(smart_init)
: #pragma resource "*.dfm"
: TForm1 *Form1;
: __fastcall TForm1::TForm1(TComponent* Owner)
: : TForm(Owner)
: 제가 C를 하면서 이건 본적이 없거든요^^;
: 그래서 어렵게 느껴졌습니다.
:
: 그리고 어떻게 컴파일을 시켜야 하는지...
: 어떤 걸로 해도 #include <vcl.h> 해더 파일이 존재 하지 않다고 나와서요^^;
: 완전 초보라서요^^:
: 제가 아는건 C 와 API 뿐이거든요^^:
: 아무리 봐도 C와 API 가 아닌 다른것 같아서 어렵네요^^:
:
: 이렇게 신경써주셔서 정말 감사합니다^^*
|