Bitmap位图绘制打印空白???
以下代码是写的一个Bitmap的绘图,绘制以后,打印出来,这个好像打印出来以后是空白的,但是把位图保存到硬盘上,却是有内容的,请高手们看一下什么情况
Graphics::TBitmap *Bmp = new Graphics::TBitmap();
Bmp->Width = 600;
Bmp->Height = 600;
Bmp->Canvas->Pen->Color = clRed;
Bmp->Canvas->Pen->Width=1;
for(int i=1;i<=30;i++)
{
Bmp->Canvas->Rectangle(i*10, i*10, Bmp->Width-i*10, Bmp->Height-i*10);
}
TPrinter * pPrinter=Printer();
pPrinter->BeginDoc();
int nScaleX = GetDeviceCaps(pPrinter->Canvas->Handle, LOGPIXELSX)/PixelsPerInch;
int nScaleY = GetDeviceCaps(pPrinter->Canvas->Handle, LOGPIXELSX)/PixelsPerInch;
TRect TheRect= TRect(0,0,Bmp->Width*nScaleX,Bmp->Height*nScaleY);
Bmp->SaveToFile("c:\\333.bmp");
DIBSECTION DibSec;
GetObject(lpBitmap->Handle, sizeof(DibSec), &DibSec);
StretchDIBits(pPrinter->Canvas->Handle,TheRect.Left, TheRect.Top,
(TheRect.Right-TheRect.Left), (TheRect.Bottom-TheRect.Top),
0, 0,Bmp->Width, Bmp->Height,DibSec.dsBm.bmBits,
(BITMAPINFO*)&DibSec.dsBmih,DIB_RGB_COLORS,SRCCOPY);
pPrinter->EndDoc();
delete Bmp;
Graphics::TBitmap *Bmp = new Graphics::TBitmap();
Bmp->Width = 600;
Bmp->Height = 600;
Bmp->Canvas->Pen->Color = clRed;
Bmp->Canvas->Pen->Width=1;
for(int i=1;i<=30;i++)
{
Bmp->Canvas->Rectangle(i*10, i*10, Bmp->Width-i*10, Bmp->Height-i*10);
}
Bmp->SaveToFile("c:\\333.bmp");
TPrinter * pPrinter=Printer();
pPrinter->BeginDoc();
int nScaleX = GetDeviceCaps(pPrinter->Canvas->Handle, LOGPIXELSX)/PixelsPerInch;
int nScaleY = GetDeviceCaps(pPrinter->Canvas->Handle, LOGPIXELSX)/PixelsPerInch;
TRect TheRect= TRect(0,0,Bmp->Width*nScaleX,Bmp->Height*nScaleY);
DIBSECTION DibSec;
GetObject(Bmp->Handle, sizeof(DibSec), &DibSec);//此处贴错了
StretchDIBits(pPrinter->Canvas->Handle,TheRect.Left, TheRect.Top,
(TheRect.Right-TheRect.Left), (TheRect.Bottom-TheRect.Top),
0, 0,Bmp->Width, Bmp->Height,DibSec.dsBm.bmBits,
(BITMAPINFO*)&DibSec.dsBmih,DIB_RGB_COLORS,SRCCOPY);
TRect myrect(0,0,600,600);//少了这句话
pPrinter->Canvas->StretchDraw(myrect,Bmp);//少了这句话
pPrinter->EndDoc();
delete Bmp;