Hi Chris Barker
In fact I had do a corp befor trans to wxBitmap then to wxImage. and do resize use wxImage. I think only corp is not enough, corp works when show a small section in a large scale. but sometimes we need show a large image in small scale to see all (my english is bad...). In this condition we need down simple first.
but if we do corp and down simple... That means we do all the things ourself, then I think we need not wxImage at more.
<< wxImage is scaling in C++, so you're not going to get much faster unless you can use a particularly smart algorithm (or simple one -- are you interpolation, or ???>>
I think wx should has a method that draw with offset and scale. count the final area smartly, and render useing the corresponding pixel from a bitmap. It is esay to do with C implement (Even need not a buffer). but it's difficult to do with python, then trans to bitmap...
Thanks for your advice, I am writting ImageJ in Python, aimed to progrgram with skimage, opencv, itk seamless.
best
YXDragon
发件人:Chris Barker <chris.barker@noaa.gov>
收件人:wxpython-users <wxpython-users@googlegroups.com>
主题:Re: [wxPython-users] Draw bitmap(Numpy) with scale and offset
日期:2017年07月06日 04点52分
I need to draw a Numpy array on panel (zoom out and in ...). I use buffer to give the pixel data to the wxbitmap, but I did not find a method in dc can draw bitmap with offset and scale. so I must trans the wxbitmap to wximage, then scale and trans back to wxbitmap to draw.
yes, I think that's what you need to do
though I would suspect that skimage would have a scaling ability -- maybe scale in numpy , then draw to wx.
but it cost so much memory and time (when the picture is large and scale large, a 1000 * 1000 picture scale 100 times will be 100000 * 100000). so I do a lot of work to count the final extent and corp the Numpy array first,
yup -- that's what you need to do -- again, unless skimage has this functionality.
in wx.lib.floatcanvas ScaledBitmap2, that's how I do it -- (though not from a numpy array) -- a bit of finicky code, but you really can't expect to scale up an entire huge image in memory -- so you need to crop it first.
I'm not trying to get any kind of "frame rate" with FC -- but it seems snappy enough.
then: numpy -> bitmap -> image -> scale -> bitmap -> draw. It works, but so complex, and with a bad performance (Far inferior to Java's drawImage...)
you should be able to:
crop_in_numpy->wxImage->scale->wxBitmap-Draw
wxImage is scaling in C++, so you're not going to get much faster unless you can use a particularly smart algorithm (or simple one -- are you interpolation, or ???
I hope that is enough to get you started, or inspire a correction from someone who knows a better way. I should admit that I have not tested this approach thoroughly with Python 3.
nor have I
···
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.