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

C++빌더 Q&A
C++Builder Programming Q&A
[8789] [질문] 24bpp bitmap을 8bpp Indexed color로 변환시 문제
초짜 [syleejin] 1266 읽음    2001-07-06 11:30
24bpp의 bitmap(In24bpp)을 8bpp(indexed color,Out8bppNOED)로 저장하려고 합니다.
이때 팔레트는 Ref8bpp의 bitmap에서 가져오구요.
아래처럼 했더니 칼라가 제대로 안나오는군요.
아무래도 팔레트 처리를 잘못한듯한데
팔레트를 읽어서 기록하는 방법을 좀 알려주세요.

*****************************************************************
구조체정의:
    struct IO{
        AnsiString filename;
        Graphics::TBitmap *pBitmap;
        LPPALETTEENTRY lppe;
    }In24bpp,Ref8bpp,Out8bppNOED,Out8bppED;
*****************************************************************

void __fastcall TmainForm::N24bpp8bpp1Click(TObject *Sender)
{
    Out8bppNOED.pBitmap->Width = In24bpp.pBitmap->Width;
    Out8bppNOED.pBitmap->Height = In24bpp.pBitmap->Height;
    Out8bppNOED.pBitmap->PixelFormat = pf8bit;

    HPALETTE hpal;
    hpal = Ref8bpp.pBitmap->Palette;
    GetPaletteEntries(hpal,0,256,Out8bppNOED.lppe);

    hpal = Out8bppNOED.pBitmap->Palette;
    SetPaletteEntries(hpal,0,256,Out8bppNOED.lppe);

    Byte     *bPtr, *oPtr, *rPtr;
    for (int y = 0 ; y < Out8bppNOED.pBitmap->Height ; y++)
    {
        oPtr = (Byte *)Out8bppNOED.pBitmap->ScanLine[y];
        //rPtr = (Byte *)Ref8bpp.pBitmap->ScanLine[y];
        for (int x = 0; x < Out8bppNOED.pBitmap->Width ; x++)
        {
            //search the best matching Color in LUT
            oPtr[x] = GetNearestPaletteIndex(hpal,In24bpp.pBitmap->Canvas->Pixels[x][y]);
        }
    }
    Out8bppNOED.pBitmap->Transparent = true;
    Out8bppNOED.pBitmap->TransparentMode = tmAuto;
    Image1->Canvas->Draw(0,0,Out8bppNOED.pBitmap);
}
*****************************************************************

+ -

관련 글 리스트
8789 [질문] 24bpp bitmap을 8bpp Indexed color로 변환시 문제 초짜 1266 2001/07/06
8799     Re:[질문] 24bpp bitmap을 8bpp Indexed color로 변환시 문제 방태윤 1732 2001/07/06
8867         Re:Re:[질문] 24bpp bitmap을 8bpp Indexed color로 변환시 문제 초짜 1626 2001/07/09
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.