Fix Windows printer output to be centered regardless of the margin offsets imposed by a printer driver.

Switch emulated Imagewriter to using page units equivalent to Postscript points (1/72th of an inch) vs 1/10th of an inch. This is to aid in adding additional paper size support in the future.
This commit is contained in:
Christopher Mason 2015-02-01 20:13:14 +00:00
parent e3b7bcd23e
commit 05e6b4c389
2 changed files with 6 additions and 4 deletions

View File

@ -116,8 +116,8 @@ Imagewriter::Imagewriter(Bit16u dpi, Bit16u width, Bit16u height, char* output,
this->multipageOutput = multipageOutput;
this->port = port;
defaultPageWidth = (Real64)width/(Real64)10;
defaultPageHeight = (Real64)height/(Real64)10;
defaultPageWidth = (Real64)width/(Real64)72;
defaultPageHeight = (Real64)height/(Real64)72;
// Create page
page = SDL_CreateRGBSurface(
@ -1628,6 +1628,8 @@ SDL_FreeSurface(image);*/
Bit16u physW = GetDeviceCaps(printerDC, PHYSICALWIDTH);
Bit16u physH = GetDeviceCaps(printerDC, PHYSICALHEIGHT);
Bit16u offsetW = GetDeviceCaps(printerDC, PHYSICALOFFSETX);
Bit16u offsetH = GetDeviceCaps(printerDC, PHYSICALOFFSETY);
Real64 scaleW, scaleH;
@ -1695,7 +1697,7 @@ SDL_FreeSurface(image);*/
memcpy (Pixels, page->pixels,
BitmapInfo->bmiHeader.biSizeImage);
Prev = SelectObject (memHDC, bitmap);
StretchBlt(printerDC, 0, 0, physW, physH, memHDC, 0, 0, page->w, page->h, SRCCOPY);
StretchBlt(printerDC, -offsetW, -offsetH, physW, physH, memHDC, 0, 0, page->w, page->h, SRCCOPY);
SelectObject (memHDC,Prev);
DeleteObject (bitmap);
}

View File

@ -40,7 +40,7 @@ int scc_imagewriter_init(int port)
{
Scc *scc_ptr;
scc_ptr = &(scc_stat[port]);
imagewriter_init(g_imagewriter_dpi,85,110,g_imagewriter_output,g_imagewriter_multipage != 0, port);
imagewriter_init(g_imagewriter_dpi,612,792,g_imagewriter_output,g_imagewriter_multipage != 0, port);
scc_ptr->state = 4;
return 4;
}