May 01, 2024, 01:46:31 PM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Ratio/Scaling Help

Started by LarryMc, January 23, 2009, 12:30:16 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

LarryMc

Having a problem figuring out the correct formula to scale between the screen and the printer:
This gives me the size of each:
screenx = _GetSystemMetrics(SM_CXSCREEN)
screeny = _GetSystemMetrics(SM_CYSCREEN)
printerx= _GetDeviceCaps(pd.hdc,HORZRES)
printery = _GetDeviceCaps(pd.hdc,VERTRES)


This determines the correct scale so the screen contents would fit on the printer page:
s1 = printerx/(screenx+0.0f)
s2 = printery/(screeny+0.0f)
IF (s1 < s2) THEN scale = s1 ELSE scale = s2


Then I apply the scaling to the rectangle I want to print:
rc2.left = 0
rc2.top = 0
rc2.right = screenx * scale
rc2.bottom = screeny * scale


Problem is that the result doesn't print correctly.  If the rectangle contains a circle on the screen it prints as an elipse on the printer.
There's something missing in the scaling that accounts for aspect ratios.

I'm having a senior moment trying to figure it out. :D

Larry

LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

GWS

I don't know much about this Larry, but I think the problem comes up from time to time ..  :)

I've found a couple of references - don't know if they'll help you at all ..

http://www.ionicwind.com/forums/index.php/topic,2988.0.html

http://www.ionicwind.com/forums/index.php/topic,570.0.html

all the best, :)

Graham
Tomorrow may be too late ..