Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2006.02.26;
Скачать: 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 вся ветка

Текущий архив: 2006.02.26;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.035 c
2-1139688097
Руслан
2006-02-11 23:01
2006.02.26
как использовать widechar


1-1138092276
Владислав
2006-01-24 11:44
2006.02.26
Хеш-функция.


2-1139610999
Child
2006-02-11 01:36
2006.02.26
Почему когда вписываю в uses QStdCtrls и QCheckLst, то перестаёт


15-1139283950
Логин
2006-02-07 06:45
2006.02.26
FastReport 3.20


2-1139259790
san6
2006-02-07 00:03
2006.02.26
можно ли передавать dbf таблицы в функцию, в качестве параметров