Top.Mail.Ru
Мастера DELPHI, Delphi programming community Титульная страница Поиск, карта сайта Написать письмо 
| Новости | Поиск | FAQ | Статьи | Книги | Новости VCL |
| Форумы ЧАТ | Орешник | KOL и MCK |
Форумы -» Основная («Начинающим»)/ Базы / WinAPI / Компоненты / Сети / Media / Игры / Corba и COM / KOL / FreePascal / .Net / Прочее / RSDN.ORG

« предыдущая ветвь | форум | следующая ветвь »

Масштабирование Printer.Canvas налету [D7, WinXP]


SergeyRocker ©   (2005-12-06 11:48:00) 

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

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 из файла?


SergeyRocker   (2005-12-07 22:27:00) [1]

Из А5 в А4.


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

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


Наверх

Титульная страница Поиск, карта сайта Написать письмо