C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 팁&트릭
C++Builder Programming Tip&Tricks
[368] [팁] ScanLine을 사용한 이미지의 gray톤, blue톤, red톤, yellow톤 처리
이기주 [lkj900] 8255 읽음    2002-09-27 14:01
ScanLine을 사용하여 간단히
이미지의 gray톤, blue톤, red톤, yellow톤 처리입니다.


//* 먼저 Image 두개, PaintBox 1개를 만들고 두개의 이미지에는 BMP그림을 불러와 있어야 합니다.
// 모두 동일한 사각형 영역

void __fastcall TForm1::Button1Click(TObject *Sender)
{
RGBTRIPLE *rtColor,*rtColor2;
int x,y;
TColor avgcolor;

TMemoryStream* pms = new TMemoryStream();

Image1->Picture->Bitmap->SaveToStream(pms);
pms->Position = 0;
Image2->Picture->Bitmap->LoadFromStream(pms);

    for(y=30;y<Image1->Height-30;y++)
    {
    rtColor=(RGBTRIPLE*)Image1->Picture->Bitmap->ScanLine[y];    // Image1에서 읽어
    rtColor2=(RGBTRIPLE*)Image2->Picture->Bitmap->ScanLine[y];   // Image2로 변환

        for(x=0;x<Image1->Width;x++)
        {
            avgcolor=(TColor)(rtColor[x].rgbtRed*3
               +rtColor[x].rgbtGreen*9
                     +rtColor[x].rgbtBlue)/13;
               rtColor2[x].rgbtRed=avgcolor;   // R, G, B중 값을 0로 하면 Blue톤
               rtColor2[x].rgbtGreen=avgcolor; // Red톤, Yellow톤 등 다양한 톤을 만들 수 있습니다.
               rtColor2[x].rgbtBlue=avgcolor;
        }
    }

    PaintBox1->Canvas->Draw(0,0,Image2->Picture->Bitmap);    // 최종 PaintBox로 복사
}


1. Red톤
   rtColor2[x].rgbtRed=avgcolor;
   rtColor2[x].rgbtGreen=0;
   rtColor2[x].rgbtBlue=0;

2. Green톤
   rtColor2[x].rgbtRed=0;
   rtColor2[x].rgbtGreen=avgcolor;
   rtColor2[x].rgbtBlue=0;

3. Blue톤
   rtColor2[x].rgbtRed=0;
   rtColor2[x].rgbtGreen=0;
   rtColor2[x].rgbtBlue=avgclolor;

4. Yellow톤
   rtColor2[x].rgbtRed=avgcolor;
   rtColor2[x].rgbtGreen=avgcolor;
   rtColor2[x].rgbtBlue=0;

+ -

관련 글 리스트
368 [팁] ScanLine을 사용한 이미지의 gray톤, blue톤, red톤, yellow톤 처리 이기주 8255 2002/09/27
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.