|
void __fastcall TForm2::Button1Click(TObject *Sender)
{
int a = m_iTextWidth * 4 * m_iTextHeight;
unsigned char *d_Buff = new unsigned char[a];
Graphics::TBitmap *s_Bitmap = new Graphics::TBitmap();
s_Bitmap->LoadFromFile("1234.bmp");//저장된 비트맵 불러오기
FILE *file1 = fopen("2.txt","a");
BitmapToBuff(s_Bitmap,d_Buff);
for(int i = 0; i < (m_iTextWidth *4* m_iTextHeight)-4; i+=4)//색변형을 위한 포문
{
TORGB(d_Buff[i],d_Buff[i+1],d_Buff[i+2]);//색변환함수 호출
Memo1->Lines->Add(d_Buff[i]);
Memo1->Lines->Add(d_Buff[i+1]);
Memo1->Lines->Add(d_Buff[i+2]);
Memo1->Lines->Add("");
}
AnsiString c = Memo1->Text;
int d = c.Length();
fwrite(c.c_str(),d,1,file1);
fclose(file1);
}
short __fastcall TForm2::TORGB(byte blue, byte green , byte red)//비트맵 색 변환
{
return ((blue>>3)<<10) | ((green>>3)<<5) | (red>>3);
}
//---------------------------------------------------------------------------
void __fastcall TForm2::BitmapToBuff( Graphics::TBitmap *s_Bitmap, unsigned char *d_Buff )//비트맵색을 버퍼에 넣기
{
unsigned char *tBuff;
int pos;
for(int y = 0; y < m_iTextHeight; y++)
{
tBuff = (unsigned char *) s_Bitmap->ScanLine[y];
pos = m_iTextWidth * 4 * y;
memcpy( d_Buff+pos, tBuff, ((m_iTextWidth) * 4));
}
}
비트맵에서 색 갈정보만 버퍼로 가져와서 변환 하는 작업입니다.
픽셀포멧을 이용하지 않고요^^
색을 변환시켜주었습니다.
이제 이 색이 변형된 값을 원래 불러온 비트맵에 넣고 싶습니다. 어떻해 해야 할지 막막 합니다.
|