Sign in Join
Wiki copytemporary

Print Bitmap/ru: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11## Как отправить изображение на принтер
22
33``` pascal
44// uses Printers; // необходимо подключить модуль
55var
66 Scale :LongInt;
77begin
88 with Printer do
99 begin
1010 BeginDoc;
1111 Scale := Min(
1212 Printer.PageWidth div Image1.Picture.Bitmap.Width,
1313 Printer.PageHeight div Image1.Picture.Bitmap.Height);
1414
1515 Printer.Canvas.StretchDraw(
1616 Rect(0, 0, Image1.Picture.Bitmap.Width*Scale, Image1.Picture.Bitmap.Height*Scale),
1717 Image1.Picture.Bitmap);
1818
1919 EndDoc;
2020 end;
2121end;
2222```
2323
24-\
2524**Печать jpeg картинки с масштабированием через Bitmap на лист А4**
2625
2726``` pascal
2827// uses Printers; // необходимо подключить модуль
2928procedure PrintImage(Image: TImage);
3029var
3130 TempImageBMP: Graphics.TBitmap;
3231 TempImageJPEG: TImage;
3332 ScaleX, ScaleY: Double;
3433 RectLeft,RectTop,RectRight,RectBottom: Integer;
3534begin
3635
3736TempImageBMP := Graphics.TBitmap.Create;
3837TempImageBMP.Assign(Image.Picture.Graphic);
3938TempImageJPEG := TImage.Create(Self);
4039TempImageJPEG.Picture.Bitmap := TempImageBMP;
4140
4241Printer.BeginDoc;
4342// Расчет соотношение сторон
4443ScaleX := Printer.PageWidth / TempImageJPEG.Picture.Bitmap.Width;
4544ScaleY := Printer.PageHeight / TempImageJPEG.Picture.Bitmap.Height;
4645
4746RectLeft:=0;
4847RectTop:=0;
4948RectRight := trunc(TempImageJPEG.Picture.Bitmap.Width * scaleX);
5049RectBottom := trunc(TempImageJPEG.Picture.Bitmap.Height * scaleY);
5150Printer.Canvas.StretchDraw(
5251 Rect(RectLeft,RectTop,RectRight,RectBottom),
5352 TempImageJPEG.Picture.Bitmap);
5453Printer.EndDoc;
5554
5655TempImageBMP.Free;
5756TempImageJPEG.Free;
5857end;
5958```
6059
6160---
6261*From the Free Pascal wiki, page "Print Bitmap/ru", as it stood on 2020-02-23 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history