I use matplotlib and Backend Agg to draw a plot , I want to show this plot in
my GUI in specific area (Plot area) , I need to have the image object in
oder to show it, so I have to convert this plot to string or array or save
in buffer and then load it to an Image , I want to know , can I accomplish
this without using PIL , because I need to build, test and verify any new
package added to the system on 6 different platforms, and it might take a
long time and at high expertise level to add the module to our entire
What I have to do?
I can convert it to string or array with numpy or FigureCanvas or ect. , my
problem is how to load this array or string to image !
Is it clear?
Anthony Floyd-2 wrote:
> Forgot to reply-to-list...
> ---------- Forwarded message ----------
> From: Anthony Floyd <anthonyfloyd@...>
> Date: Wed, Mar 26, 2008 at 4:54 PM
> Subject: Re: [Matplotlib-users] load data from string or array to Image
> To: sa6113 <s.payandeh@...>
> On Wed, Mar 26, 2008 at 1:33 AM, sa6113 <s.payandeh@...> wrote:
> > I have a problem to load data from string or array to Image but
> > using PIL , because I have to check the application in 6 different
> > like Windows 32bit, Windows X64 (64bit version), Linux 32bit, Linux
> > x86_64, Linux IPF (Itanium Processor Family) and HP-UX 64.
> > There is a code but I don't want to use PIL :
> > http://mail.python.org/pipermail/image-sig/1998-October/000572.html
> > Can I accomplish the same thing using the modules that are already on
> > system, or those that are pure Python (not requiring any compilation
> > binary download)?
> I went through this just a few weeks ago. Now, mind you I'm using wx
> and numpy already.
> My solution was to turn my .png into a Python string using img2py.py
> in the wx/tools directory.
> With the string, I then used the following code to return the image (a
> watermark) as an array that figimage() or imshow() can use directly.
> I'm sure the code can be optimized, but it works fast enough for me...
> def getWatermarkArray():
> rows = 28
> columns = 200
> dimensions = 3
> image = getWatermarkImage()
> # image array is a string of hex values
> imageString = image.GetData()
> imageList = [ord(item) for item in imageString]
> imageArray = numpy.zeros(shape=(28,200,3), dtype=numpy.float32)
> imageCounter = 0
> for rowCounter in range(rows):
> for columnCounter in range(columns):
> for dimCounter in range(dimensions):
> imageArray[rowCounter][columnCounter][dimCounter] =
> imageCounter += 1
> return imageArray
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> Matplotlib-users mailing list
View this message in context: http://www.nabble.com/load-data-from-string-or-array-to-Image-tp16297653p16322508.html
Sent from the matplotlib - users mailing list archive at Nabble.com.