Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Pixel Array => Bitmap File

Reply
Thread Tools

Pixel Array => Bitmap File

 
 
Jason B
Guest
Posts: n/a
 
      02-27-2007
Hi all,

I'm somewhat new to Python and I'm trying to figure out the best way to
accomplish the following:

From an array of pixel data in an XML file (given the format, width and
height of the image as attributes) I must read in the data and save it off
as a bmp file.

I've gotten the PIL and Win32 packages and it seems that using
functionallity from each I should be able to do this, but I haven't yet
figured out how.

Scouring the internet for a tutorial hasn't netted me anything so far, so I
was hoping someone here could point me in the right direction...

Thanks!
J


 
Reply With Quote
 
 
 
 
Roel Schroeven
Guest
Posts: n/a
 
      02-27-2007
Jason B schreef:
> Hi all,
>
> I'm somewhat new to Python and I'm trying to figure out the best way to
> accomplish the following:
>
> From an array of pixel data in an XML file (given the format, width and
> height of the image as attributes) I must read in the data and save it off
> as a bmp file.
>
> I've gotten the PIL and Win32 packages and it seems that using
> functionallity from each I should be able to do this, but I haven't yet
> figured out how.
>
> Scouring the internet for a tutorial hasn't netted me anything so far, so I
> was hoping someone here could point me in the right direction...


- read your pixels from the XML file and assemble them in the correct
format in a buffer
- use Image.frombuffer() or Image.fromstring() (from PIL) to create an
image from that data
- use Image.save() (also from PIL) to save it as a bmp.

Have a look at http://www.pythonware.com/library/pi...book/image.htm
for the details on those methods.

--
If I have been able to see further, it was only because I stood
on the shoulders of giants. -- Isaac Newton

Roel Schroeven
 
Reply With Quote
 
 
 
 
Jason B
Guest
Posts: n/a
 
      02-27-2007
Thanks, Roel...

The Image.frombuffer() method looks promising, but the "mode" parameter
seems a bit too limited for my needs. I must be able to specify not only
the order of the bits (RGB in any order) but also whether the format is 565,
555, etc.

Maybe I need to work outside the bounds of PIL?

- J


 
Reply With Quote
 
Jason B
Guest
Posts: n/a
 
      02-27-2007
My mistake, I see the section now about "Writing Your Own File Decoder..."

Thanks again for your help!

- J


"Jason B" <(E-Mail Removed)> wrote in message
news:mV1Fh.2439$(E-Mail Removed) t...
> Thanks, Roel...
>
> The Image.frombuffer() method looks promising, but the "mode" parameter
> seems a bit too limited for my needs. I must be able to specify not only
> the order of the bits (RGB in any order) but also whether the format is
> 565, 555, etc.
>
> Maybe I need to work outside the bounds of PIL?
>
> - J
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help! How can I draw a bitmap only with BITMAP information! xqggz C++ 1 06-19-2007 03:07 PM
How to read pixel values of a Bitmap Image. ajay_itbhu C++ 2 01-29-2007 08:57 PM
GDI+ - limits for pixel dimensions in a bitmap object =?Utf-8?B?cGJ1bQ==?= ASP .Net 0 06-18-2004 10:50 AM
Masked bitmap from bitmap Gandalf Python 0 01-29-2004 09:41 PM
Hot pixel vs. stuck pixel Abrasha Digital Photography 5 09-02-2003 04:49 PM



Advertisments