Peter,
From: Peter Damoc [mailto:pdamoc@gmail.com]
Sent: Thursday, December 27, 2007 6:06 AM
To: wxPython-users@lists.wxwidgets.org
Subject: Re: [wxPython-users] Scaling an image for printingHi,
I received a feature request of sorts the other day to
allow a user to
take a screenshot of an application I wrote in wxPython
and print said
screenshot out. I found Andrea's great script for
getting the screenshot,
but getting it to print is painful. I am trying to use the
HtmlEasyPrinting object, which works except that the
image that is sent is
too large. Is there a way to scale the image in
wxPython to fit letter
size paper (8 1/2" x 11")?
I've shamelessly used the Demo code for scaling an image for
print and got beautiful results...After all is just a bitmap... it should work. Take a look.
Peter
I use stuff from the demo all the time. I suppose what I don't understand
how to do is taking some image that's of an arbitrary size and scaling it
(while keeping the aspect ratio) so that it'll fit on 8 1/2". I don't know
what the size is I should be shooting for, especially if the user happens
to stretch the GUI out of its original proportion.
I have done this in another application, which I think I nabbed from a
post of Andrea's (thanks!):
img = wx.Image(filepath, wx.BITMAP_TYPE_ANY)
# scale the image, preserving the aspect ratio
W = img.GetWidth()
H = img.GetHeight()
if W > H:
NewW = self.PhotoMaxSize
NewH = self.PhotoMaxSize * H / W
else:
NewH = self.PhotoMaxSize
NewW = self.PhotoMaxSize * W / H
img = img.Scale(NewW,NewH)
Unfortunately, I am not sure how to apply this to my HtmlWindow such that
I can print from it. Maybe create the snapshot, scale it somehow, save it
and then display it in the HtmlWindow? Still, I need some way of know my
MaxSize...
Any suggestions are good.
Mike
···
-----Original Message-----
On Dec 27, 2007 12:26 AM, Mike Driscoll > <mdriscoll@co.marshall.ia.us> wrote: