Hi all!
Thanks a lot for your very fast answers!! =)
I have solved my problem, well, rather got around it.
I used PIL to chop the image in smaller chunks, loaded them as
StaticBitmap in several Panel and then displayed them in a
ScrolledWindow using a horizontal BoxSizer.
Below are code samples performing these operations, if anybody ever
encounters a similar problem.
@Robin :
Which platform?
Windows 7 on a 64 bits machine
Have you checked that the virtual size of the scrolledwindow is >= the image's size?
Yes it is. The image size is 550Ko whereas the virtual size is 49Mo
(as stated when opened with IrfanView).
The next thing I would look at is drawing the image yourself instead of using a wx.StaticBitmap.
In fact, the image is generated with Matplotlib. I saw that it's
possible to use wxPython as a backend for Matplotlib (not built-in,
but some people managed to do it), but simply it felt easier to export
the image as a file and then open it with wxPython.
##### code samples ####
## slicing images ##
from PIL import Image
im = Image.open(r'figure2.jpg')
number_of_parts = 4
width, height = im.size
for i in range(number_of_parts) :
outfile = r'figure2-' + str(i)
region = im.crop((i*width/number_of_parts,
0,
(i+1)*width/number_of_parts,
height))
region.save(outfile, "JPEG")
## displaying the images ##
import wx
class ScrolledWindow(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent, id, title, size=(500, 400))
sw = wx.ScrolledWindow(self)
box = wx.BoxSizer(wx.HORIZONTAL)
bmp0 =
wx.Image(r'figure2-0.jpg',wx.BITMAP_TYPE_JPEG).ConvertToBitmap()
bmp1 =
wx.Image(r'figure2-1.jpg',wx.BITMAP_TYPE_JPEG).ConvertToBitmap()
bmp2 =
wx.Image(r'figure2-2.jpg',wx.BITMAP_TYPE_JPEG).ConvertToBitmap()
bmp3 =
wx.Image(r'figure2-3.jpg',wx.BITMAP_TYPE_JPEG).ConvertToBitmap()
panel0 = wx.Panel(sw)
panel1 = wx.Panel(sw)
panel2 = wx.Panel(sw)
panel3 = wx.Panel(sw)
sbmp0 = wx.StaticBitmap(panel0, -1, bmp0)
sbmp1 = wx.StaticBitmap(panel1, -1, bmp1)
sbmp2 = wx.StaticBitmap(panel2, -1, bmp2)
sbmp3 = wx.StaticBitmap(panel3, -1, bmp3)
box.Add(panel0, 0, wx.ALIGN_LEFT|wx.ALL, 0)
box.Add(panel1, 0, wx.ALIGN_LEFT|wx.ALL, 0)
box.Add(panel2, 0, wx.ALIGN_LEFT|wx.ALL, 0)
box.Add(panel3, 0, wx.ALIGN_LEFT|wx.ALL, 0)
sw.SetSizer(box)
scroll_step = 500
sw.SetScrollbars(scroll_step, scroll_step, (3 *
bmp0.GetWidth() / scroll_step) + 1, (bmp0.GetHeight() / scroll_step) +
1)
#self.SetAutoLayout(1)
self.Centre()
self.Show()
app = wx.App()
ScrolledWindow(None, -1, 'Test')
app.MainLoop()
···
On Dec 13, 11:13 am, Dr Funk <clement.chastag...@gmail.com> wrote:
No, I pasted bmp.GetWidth() / 20) + 1, I had a hard-coded value to
test things before =)
On Dec 10, 7:27 pm, mw <m...@tangsoo.us> wrote:
> Is that verbatim?
> you've got a syntax error in your statement (missing parentheses after the
> 20,20)
> sw.SetScrollbars(20,20,*(*bmp.GetWidth() / 20) + 1, (bmp.GetHeight() / 20) +
> 1)
> On Fri, Dec 10, 2010 at 8:23 AM, Dr Funk <clement.chastag...@gmail.com>wrote:
> > Hi all,
> > I'm trying to visualize a very large image (approximately 63000 by
> > 300) in a ScrolledWindow.
> > The thing is, the left and the right of the image are cropped and I
> > can't seem to do much about it.
> > Is there some kind of size limitation (I didn't find anything in the
> > documentation about that...)?
> > Here's a snippet of my class MyScrolledWindow:
> > sw = wx.ScrolledWindow(self)
> > bmp = wx.Image(r'figure2.png',wx.BITMAP_TYPE_PNG).ConvertToBitmap()
> > sbmp = wx.StaticBitmap(sw, -1, bmp)
> > sw.SetScrollbars(20, 20, bmp.GetWidth() / 20) + 1, (bmp.GetHeight() /
> > 20) + 1)
> > Any help/insight would be very appreciated =)
> > Regards.
> > --
> > To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com<wxPython-users%2Bunsubscribe@googlegroups.com>
> > or visithttp://groups.google.com/group/wxPython-users?hl=en