Tip 게시판에 예제를 올려 놓았습니다. (GDI를 이용한 Palette 적용이 있습니다.)
약간 추가해서 다시 올립니다.
//User-Defined ColorMap (임의의 16 색상)
static BYTE bcA[16][3] =
{
120,9,80,
0,200,255,
63,180,179,
10,200,10,
0,100,120,
180,40,10,
255,0,255,
255,255,0,
192,0,192,
10,100,200,
100,50,120,
50,90,230,
200,10,50,
40,80,10,
33,21,100,
200,55,55
};
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Graphics::TBitmap *bmp = new Graphics::TBitmap();
Graphics::TBitmap *bmp1 = new Graphics::TBitmap();
bmp->Width = this->ClientWidth;
bmp->Height = this->ClientHeight;
try
{
// Bitmap에 색상별로 사각형을 그립니다. (16 색상과 사각형)
for (int i=0; i<16; i++)
{
bmp->Canvas->Brush->Color = TColor(RGB(bcA[i][0],bcA[i][1],bcA[i][2]));
bmp->Canvas->Rectangle(Rect(0,i*10,300,i*10+15));
}
bmp1->Width = 100;
bmp1->Height = 50;
bmp1->Canvas->CopyRect(Rect(0,0,100,50),bmp->Canvas,Rect(0,0,100,50));
//아주 중요.(이걸 생각 못해서 GDI API로 삽질을 했었습니다.)
bmp1->PixelFormat = pf4bit;
// Save Bitmap to a file
bmp1->SaveToFile("test.bmp");
// Draw Bitmap onto the canvas of this form
this->Canvas->Draw(0,0,bmp);
}
__finally
{
delete bmp1;
delete bmp;
}
}
건승을 빕니다.
짐승이지롱 님이 쓰신 글 :
:
http://mfiles.naver.net/9440a0786d3658ebc193/data12/2005/6/14/50/Untitled-1.bmp
:
: 이곳에 16색 bmp 를 올려 두었습니다....
:
: 분명히 윈도우 기본 16색이 아닌데요.....
:
: 빌더에서 저장하면 색들이 변해서 저장이 되더라구요 ㅠ_ㅠ
:
: bmp 를 아예 처음부터 조립하는방법도 있겠습니다만....
:
: 일단 다른방법이 있지 않을까 알아보는 중이지요
:
: 답변 감사 합니다 ^_^