Home > Back-end >  Print the image problem
Print the image problem

Time:10-01

Downloaded from a local image in the image, in connect the printer to print the image section, the following is I wrote, first, load the picture can't fail, second, don't know how to print the image only part, a great god glad, I am new to the near novice, please don't spray I
Void __fastcall TForm1: : Image1Click (TObject * Sender)
{
Graphics: : TBitmap * pic_default;
Pic_default=new Graphics: : TBitmap;
Pic_default - & gt; LoadFromFile (BMP_DEFAULT);
Image1 - & gt; Picture - & gt; Bitmap=pic_default;
}
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Void __fastcall TForm1: : Button1Click (TObject * Sender)
{

For the - & gt; Hide ();
Form1 - & gt; Print ();
TPrinter * Prntr=Printer ();//create a printer
TRect r=the Rect (200200, Prntr - & gt; PageWidth - 200, Prntr - & gt; PageHeight - 200);
Prntr - & gt; Copies=PrintDialog1 - & gt; Copies;
Prntr - & gt; BeginDoc ();//print
Prntr - & gt; Canvas - & gt; Handle;
Prntr - & gt; EndDoc ();


}

CodePudding user response:

In print and the secret method, the original poster is arcane to eat all over the world image print:

 # include & lt; Jpeg. Hpp> 
#include
#include
Void __fastcall TForm1: : Button1Click (TObject * Sender)
{//load the image
If (OpenPictureDialog1 - & gt; The Execute ()!=true)
{
return;
}
String FilePath=OpenPictureDialog1 - & gt; The FileName.
Image1 - & gt; Picture - & gt; LoadFromFile (FilePath);
}
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Void __fastcall TForm1: : Button2Click (TObject * Sender)
{
TPrinter * Prn=Printer ();
Prn - & gt; BeginDoc ();
TRect the rect=Image1 - & gt; ClientRect;
Prn - & gt; Canvas - & gt; StretchDraw (the Rect (0, 0, Image1 - & gt; Picture - & gt; Width * 6.00, Image1 - & gt; Picture - & gt; Height * 6.00), Image1 - & gt; Picture - & gt; Graphic);
Prn - & gt; EndDoc ();
}
  • Related