Strange different behaviour between .BMP and jpeg-converted .BMP
Trying to use a function which is able to convert a TBitmap to another
TBitmap, I got a different behaviour between the following to cases:
1) using a .bmp-file directly created from a standard graphics program
2) using a .jpg-file also directly created from a standard graphics
program. This one I tried to convert inside BCB to a .bmp file and use
it with the same function (see code-snippet below)
Result:
tst0.bmp look quite similar in both cases 1) und 2)
tst1.bmp look quite different. The resulting picture's right margin
seems to have been cutted and it seems to have been stretched,
if(ExtractFileExt(article_filename)==".bmp") {
src_bitmap->LoadFromFile(article_filename);
}
else if(ExtractFileExt(article_filename)==".jpg") {
TJPEGImage *src_jpg_image=new TJPEGImage;
src_jpg_image->LoadFromFile(article_filename);
src_bitmap->Width=src_jpg_image->Width;
src_bitmap->Height=src_jpg_image->Height;
src_bitmap->Canvas->Draw(0, 0, src_jpg_image);
TPicture *picture=new TPicture;
picture->Assign(src_bitmap);
TMemoryStream *mem_stream=new TMemoryStream();
picture->Bitmap->SaveToStream(mem_stream);
mem_stream->Position=0;
src_bitmap->LoadFromStream(mem_stream);
delete mem_stream;
}
else
return;
Graphics::TBitmap *dst_bitmap=new Graphics::TBitmap;
MY_FUNC(dst_bitmap, src_bitmap);
src_bitmap->SaveToFile("c:\\tst0.bmp");
dst_bitmap->SaveToFile("c:\\tst1.bmp");
So my question: Is in the conversion in the .jpg-case an obvious
error, so the resulting .bmp-file is a problematic one?
Perhaps there is even a much more easier way to convert a jpeg-file's
bitmap in a .bmp-bitmap. I tried it another way, but MY_FUNC()
contains ScanLine(), which seems to last a half eternity to be
executed for each line of a comperssed picture (, so I decided to
convert it into a uncompressed bitmap for fast processing...)
Thanks a lot,
Michael