Главная страница
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.043 c
1-1138122133
integeri
2006-01-24 20:02
2006.02.26
робота со шрифтом


5-1125764301
TStas
2005-09-03 20:18
2006.02.26
Работает в рантайме, но не хочет в дизайнтайме


15-1138357010
Kerk
2006-01-27 13:16
2006.02.26
Переход на Linux


5-1125933078
TStas
2005-09-05 19:11
2006.02.26
НЕ публикация свойства


8-1126809916
-keks-
2005-09-15 22:45
2006.02.26
bmp в jpg