|
JPG는 아마도 바로 처리가 안될껍니다. BMP로 변경을 해주셔야 Bitmap으로 접근을 하실 수 있습니다. JPG를 BMP로 바꾸는 방법은 (꼭 바꾸지 않아도 로딩 시점에서 따로 Bitmap을 만들어 작업을 하셔도 됩니다) 이 곳 게시판에 정말 많습니다. ^^;
아래는 Scanline으로 비교한 예제입니다. Pixels은 쉽고 편리하겠지만, 엄청나게 느리다는 단점이 있어, Scanline으로 구현해 보았습니다.
첨부 파일은 프로젝트 입니다. 문제가 있다면, jpg를 제가 bmp로 바꿀때 픽셀이 조금씩 변경된 것 같네요. 그래서 결과가 생각보다 조금 틀리게 나옵니다.
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
RGBTRIPLE *rtColorFirst, *rtColorSecond;
int itX, itY, itColorFirst, itColorSecond;
Image1->Picture->Bitmap->PixelFormat = pf24bit;
Image2->Picture->Bitmap->PixelFormat = pf24bit;
for(itY = 0; itY < Image1->Picture->Height; itY ++) {
rtColorFirst = (RGBTRIPLE *)Image1->Picture->Bitmap->ScanLine[itY];
rtColorSecond = (RGBTRIPLE *)Image2->Picture->Bitmap->ScanLine[itY];
for(itX = 0; itX < Image1->Picture->Width; itX ++) {
itColorFirst = (int)RGB(rtColorFirst->rgbtRed, rtColorFirst->rgbtGreen, rtColorFirst->rgbtBlue);
itColorSecond = (int)RGB(rtColorSecond->rgbtRed, rtColorSecond->rgbtGreen, rtColorSecond->rgbtBlue);
if(itColorFirst != itColorSecond)
Image3->Canvas->Pixels[itX][itY] = (TColor)(itColorFirst & itColorSecond);
rtColorFirst ++;
rtColorSecond ++;
}
}
}
//---------------------------------------------------------------------------
권기식 님이 쓰신 글 :
: 안녕하세요?
: 이미지 처리를 해야 할 일이 생겼습니다.
:
: 배경이 같은 두 그림에서 그 차이를 보여주어야 하는데요..
: 포토샵에서 할 경우 레이어간의 difference를 보여주는 모드가 있던데...
: 이런걸 구현하려면 어떤걸 공부해야 할까요?
: 참고할 만한 사이트를 아시는 분은 좀 가르쳐 주세요~
:
: 전혀 바닥지식이 없는데 이런걸 시키네요.. ㅠ.ㅠ
:
: 첨부 파일의 압축을 푸시면 무슨 말인지 이해가 되실껍니다..
:
: 그럼..
|