|
RAW 데이터를 읽어와서
화면에 표출해줄려고 하는데
영상이 이상하게 나타나고 있습니다.
도와주세요
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "frmMainFTP.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
//
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormShow(TObject *Sender)
{
//
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
AnsiString szFileNamePath;
BITMAPFILEHEADER bmfh;
BITMAPINFOHEADER bmih;
int nBitmapHeaderSize;
long nLength = 0;
long nWidth = 1624;
long nHeight = 1232;
PBYTE pRawImageTemp = NULL;
int nFileHandle, nFileCreHandle;
long lBytesRead;
long lDataSize;
if(OpenDialog1->Execute())
{
szFileNamePath = OpenDialog1->FileName;
TMemoryStream *m_pBitmapStream = new TMemoryStream();
nBitmapHeaderSize = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);
nLength = (long)nWidth * (long)nHeight;
pRawImageTemp = new BYTE[nWidth * nHeight];
if( (nFileHandle = FileOpen(szFileNamePath, fmOpenRead)) != -1)
{
lBytesRead = FileRead(nFileHandle, pRawImageTemp, nLength);
if (nLength == lBytesRead)
{
bmih.biSize=sizeof(BITMAPINFOHEADER);
bmih.biWidth =(unsigned long)nWidth;
bmih.biHeight =(unsigned long)nHeight;
bmih.biPlanes =(UINT)1;
bmih.biBitCount = (UINT)8;
bmih.biCompression = (UINT)BI_RGB;
bmih.biSizeImage =(long)nLength;
bmih.biXPelsPerMeter =0;
bmih.biYPelsPerMeter =0;
bmih.biClrUsed =0;
bmih.biClrImportant =0;
bmfh.bfType = 0x4d42; // 'BM'
bmfh.bfSize = nBitmapHeaderSize + nLength;
bmfh.bfReserved1 = 0;
bmfh.bfReserved2 = 0;
bmfh.bfOffBits = nBitmapHeaderSize;
m_pBitmapStream->Position = 0L;
m_pBitmapStream->WriteBuffer(&bmfh, sizeof(BITMAPFILEHEADER));
m_pBitmapStream->WriteBuffer(&bmih, sizeof(BITMAPINFOHEADER));
m_pBitmapStream->WriteBuffer(pRawImageTemp, nLength);
m_pBitmapStream->Position = 0L;
Image1->Picture->Bitmap->LoadFromStream(m_pBitmapStream);
}
}
delete m_pBitmapStream;
delete pRawImageTemp;
}
}
//---------------------------------------------------------------------------
|