因为从扫描仪得到的是像素矩阵,所以试验了下面的代码:
Graphics::TBitmap *orig = new Graphics::TBitmap();
Graphics::TBitmap *dest = new Graphics::TBitmap();
TMemoryStream *stream;
BYTE *rowin, *rowout;
int i, j; orig->LoadFromFile("CHESS11.BMP");
dest->Width = orig->Width;
dest->Height = orig->Height;
dest->PixelFormat = orig->PixelFormat;
for ( i=0; i<dest->Height; i++)
{
rowout = (BYTE *)orig->ScanLine[i];
rowin = (BYTE *)dest->ScanLine[i];
for ( j=0; j<dest->Width; j++ )
{
rowout[j] = rowin[j];
} // strcpy( (char*)out, (char*)orig->ScanLine[i] );
}
dest->SaveToFile("test.bmp");
}
为什么最后test.bmp是空的?还有,为什么调用savetostream总是出错?access violation ...rlt60.bpl
Graphics::TBitmap *orig = new Graphics::TBitmap();
Graphics::TBitmap *dest = new Graphics::TBitmap();
TMemoryStream *stream;
BYTE *rowin, *rowout;
int i, j; orig->LoadFromFile("CHESS11.BMP");
dest->Width = orig->Width;
dest->Height = orig->Height;
dest->PixelFormat = orig->PixelFormat;
for ( i=0; i<dest->Height; i++)
{
rowout = (BYTE *)orig->ScanLine[i];
rowin = (BYTE *)dest->ScanLine[i];
for ( j=0; j<dest->Width; j++ )
{
rowout[j] = rowin[j];
} // strcpy( (char*)out, (char*)orig->ScanLine[i] );
}
dest->SaveToFile("test.bmp");
}
为什么最后test.bmp是空的?还有,为什么调用savetostream总是出错?access violation ...rlt60.bpl
rowout = (BYTE *)orig->ScanLine[i];
rowin = (BYTE *)dest->ScanLine[i];
->
rowin = (BYTE *)orig->ScanLine[i];
rowout = (BYTE *)dest->ScanLine[i];另外savetostream的代码在哪?是不是stream没有创建?