|
질문 의도에 맞는지 모르겠지만요,,
s_Bitmap->LoadFromFile("123.bmp");
한후
s_Bitmap->PixelFormat=pf16bit;
해주면 이미지 버퍼는 16bit 로 형태로 바뀌죠,
일부로 따로 연산해줄거 없이요,
그냥 바로 SaveToFile 하면 16bit bmp 로 저장되고요,
공부중 님이 쓰신 글 :
: void __fastcall TForm2::Button1Click(TObject *Sender)
: {
: int a = m_iTextWidth * 3 * m_iTextHeight;
: unsigned char *d_Buff = new unsigned char[a];
: Graphics::TBitmap *s_Bitmap = new Graphics::TBitmap();
: s_Bitmap->LoadFromFile("123.bmp");
:
: FILE *file1 = fopen("2.txt","a");
:
:
:
:
: BitmapToBuff(s_Bitmap,d_Buff);
:
: for(int i = 0; i < (m_iTextWidth *3* m_iTextHeight); i+=3)
: {
: TORGB(d_Buff[i],d_Buff[i+1],d_Buff[i+2]);
: //TORGB(d_Buff[0],d_Buff[1],d_Buff[2]);
: Memo1->Lines->Add(d_Buff[i]);
: Memo1->Lines->Add(d_Buff[i+1]);
: Memo1->Lines->Add(d_Buff[i+2]);
: }
:
: 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 * 3 * y;
: memcpy( d_Buff+pos, tBuff, ((m_iTextWidth) * 3));
: }
:
: }
: 분리되어 변환된 색갈을 원래 비트맵에 적용 하여 저장하고싶습니다. 어떻해 해야 할지 궁금합니다
|