The following code returns this error when it trys to print a jpg image: Cannot assign a TPicture to a Bitmap.void __fastcall TForm1:
rintphotoClick(TObject *Sender)
{
unsigned int BitmapInfoSize, BitmapImageSize;
long DIBWidth, DIBHeight;
PChar BitmapImage;
Windows:
BitmapInfo BitmapInfo;
Graphics::TBitmap *Bitmap;
Bitmap = new Graphics::TBitmap();
TImage *pImage;
pImage = Image1;
Printer()->BeginDoc();
Bitmap->Assign(pImage->Picture);
GetDIBSizes(Bitmap->Handle, BitmapInfoSize, BitmapImageSize);
BitmapInfo = (PBitmapInfo) new char[BitmapInfoSize];
BitmapImage = (PChar) new char [BitmapImageSize];
GetDIB(Bitmap->Handle, 0, BitmapInfo, BitmapImage);
DIBWidth = BitmapInfo->bmiHeader.biWidth;
DIBHeight = BitmapInfo->bmiHeader.biHeight;
StretchDIBits(Printer()->Canvas->Handle,
0, 0, DIBWidth, DIBHeight,
0, 0, DIBWidth, DIBHeight,
BitmapImage, BitmapInfo,
DIB_RGB_COLORS, SRCCOPY);
Printer()->EndDoc();
delete [] BitmapImage;
delete [] BitmapInfo;
delete Bitmap;
}
So how do I print a jpg image that is in Image1?
pImage = Image1; prints if it is a bmp but not if it is a jpg.
And how do I convert a jpg to a bitmap?
Please help me out.
Thanks
{
unsigned int BitmapInfoSize, BitmapImageSize;
long DIBWidth, DIBHeight;
PChar BitmapImage;
Windows:
Graphics::TBitmap *Bitmap;
Bitmap = new Graphics::TBitmap();
TImage *pImage;
pImage = Image1;
Printer()->BeginDoc();
Bitmap->Assign(pImage->Picture);
GetDIBSizes(Bitmap->Handle, BitmapInfoSize, BitmapImageSize);
BitmapInfo = (PBitmapInfo) new char[BitmapInfoSize];
BitmapImage = (PChar) new char [BitmapImageSize];
GetDIB(Bitmap->Handle, 0, BitmapInfo, BitmapImage);
DIBWidth = BitmapInfo->bmiHeader.biWidth;
DIBHeight = BitmapInfo->bmiHeader.biHeight;
StretchDIBits(Printer()->Canvas->Handle,
0, 0, DIBWidth, DIBHeight,
0, 0, DIBWidth, DIBHeight,
BitmapImage, BitmapInfo,
DIB_RGB_COLORS, SRCCOPY);
Printer()->EndDoc();
delete [] BitmapImage;
delete [] BitmapInfo;
delete Bitmap;
}
So how do I print a jpg image that is in Image1?
pImage = Image1; prints if it is a bmp but not if it is a jpg.
And how do I convert a jpg to a bitmap?
Please help me out.
Thanks