Вниз
Скачать: CL | DM;

Масштабирование Printer.Canvas налету   Найти похожие ветки 

 
SergeyRocker ©   (2005-12-06 11:48) [0]

Есть проблема:
есть код

Printer.BeginDoc;
//
//Здесь формируется Printer.Canvas
//Здесь надо его смасштабировать
//
Printer.EndDoc;

Возможно ли как-то это сделать?

//Размеры страниц в пикселях
 TPageFormats = record
   A4: TPoint;
   A5: TPoint;
 end;

...
//установка размеров
   //А5
   Printer.GetPrinter(Device, Driver, Port, HDMode);
   pDMode := GlobalLock(hDMode);
   pDMode^.dmPaperLength := 2100;
   pDMode^.dmPaperWidth := 1480;
   GlobalUnLock(hDMode);
   Printer.SetPrinter(Device, Driver, Port, HDMode);
 
   PageFormats.A5.X := Printer.PageWidth;
   PageFormats.A5.Y := Printer.PageHeight;

   //А4
   Printer.GetPrinter(Device, Driver, Port, HDMode);
   pDMode := GlobalLock(hDMode);
   pDMode^.dmPaperLength := 2970;
   pDMode^.dmPaperWidth := 2100;
   GlobalUnLock(hDMode);
   Printer.SetPrinter(Device, Driver, Port, HDMode);

   PageFormats.A4.X := Printer.PageWidth;
   PageFormats.A4.Y := Printer.PageHeight;

//масштабирование
var
 compDC: HDC;
 bmp: HBITMAP;
begin
   compDC := CreateCompatibleDC(printer.Handle);
   bmp := CreateCompatibleBitmap(compDC, printer.PageWidth, printer.PageHeight);
   SelectObject(compDC, bmp);
   BitBlt(
     compDC, // handle to destination device context
     0, // x-coordinate of destination rectangle"s upper-left corner
     0, // y-coordinate of destination rectangle"s upper-left corner
     PageFormats.A5.X, // width of destination rectangle
     PageFormats.A5.Y, // height of destination rectangle
     Printer.Canvas.Handle, // handle to source device context
     0, // x-coordinate of source rectangle"s upper-left corner
     0, // y-coordinate of source rectangle"s upper-left corner
     SRCCOPY // raster operation code
     );

   StretchBlt(
     Printer.Canvas.Handle, // handle of destination device context
     0, // x-coordinate of upper-left corner of dest. rect.
     0, // y-coordinate of upper-left corner of dest. rect.
     PageFormats.A4.X, // width of destination rectangle
     PageFormats.A4.Y, // height of destination rectangle
     compDC, // handle of source device context
     0, // x-coordinate of upper-left corner of source rectangle
     0, // y-coordinate of upper-left corner of source rectangle
     PageFormats.A5.X, // width of source rectangle
     PageFormats.A5.Y, // height of source rectangle
     SRCCOPY // raster operation code
     );
   StretchBlt(
     Printer.Handle, // handle of destination device context
     0, // x-coordinate of upper-left corner of dest. rect.
     0, // y-coordinate of upper-left corner of dest. rect.
     PageFormats.A4.X, // width of destination rectangle
     PageFormats.A4.Y, // height of destination rectangle
     compDC, // handle of source device context
     0, // x-coordinate of upper-left corner of source rectangle
     0, // y-coordinate of upper-left corner of source rectangle
     PageFormats.A5.X, // width of source rectangle
     PageFormats.A5.Y, // height of source rectangle
     SRCCOPY // raster operation code
   DeleteObject(bmp);
end;

Если это невозможно, то как можно сохранить Printer.Canvas и потом загрузить в него большого размера BMP из файла?



 
Сергей Бастрыгин ©   (2005-12-07 10:49) [1]

А масштабирование из какого в какой формат


 
SergeyRocker ©   (2005-12-07 22:27) [2]

Из А5 в А4.



Страницы: 1 вся ветка

Скачать: CL | DM;



Память: 0.46 MB
Время: 0.033 c
2-1139199972
TimScorp
2006-02-06 07:26
2006.02.26
DLL.


15-1138982087
Loginov Dmitry
2006-02-03 18:54
2006.02.26
Зацените страничку :)


2-1139316559
san6
2006-02-07 15:49
2006.02.26
существуют две таблицы


2-1139216457
san6
2006-02-06 12:00
2006.02.26
Как поделить строку


2-1139742665
13
2006-02-12 14:11
2006.02.26
модуль




   Наверх