473,387 Members | 1,512 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Pixel Array => Bitmap File

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
Feb 27 '07 #1
3 8120
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
Feb 27 '07 #2
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
Feb 27 '07 #3
My mistake, I see the section now about "Writing Your Own File Decoder..."

Thanks again for your help!

- J
"Jason B" <me@mylife.comwrote in message
news:mV*****************@newssvr21.news.prodigy.ne 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

Feb 27 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: charsh | last post by:
Hi, I using the code below to draw a text in a pictureBox1. //Start--------------------------------------------------------------- private void button1_Click(object sender, System.EventArgs e)...
5
by: Jeroen Ceuppens | last post by:
I have the colormap (ARGB, 8bit , so every color from 0 to 255) , put it in an array (1dim) I have the pixel date (array 640x480) What is the best way to make with these array's a bitmap file?...
4
by: Carsten Kraft | last post by:
Hello Newsgroup, I think this is easy for you: I want to save the data line by line into an string array. eg. Text file: Array Line 1 Line1
2
by: victor | last post by:
hello, I have several arrays containing (image-) pixel data; I want to display it onto a PictureBox. What is the best Graphics method for it? (MSDN examples talks only about loading it from...
2
by: madhuri.eerupula | last post by:
Hi Actually my task is to select some text in bitmap file and then copy paste somewhere else may in some word document or notepad or anything. My problem is how to read text from a bitmap file...
9
by: Myombi Natuse | last post by:
I need to print a bitmap file in C under Windows. I'm a senior in college so please show me the respect I'm due. I don't want any of you jokers telling me that it can't be done because I know it...
1
by: janaki112 | last post by:
my 1 dimensional pixel array is named => intensity (got by using pixel grabber) I have created an image using Code: Container n=new Container(); Image img=n.createImage(new...
5
by: stef | last post by:
hello I can find all kind of procedures to convert an array to a bitmap (wxPython, PIL), but I can't find the reverse, either - convert a bitmap to an array or - read a bitmap file to an...
1
by: Malam Sani | last post by:
How to open and read bitmap file without using image library like gd. I need to perform certain calculations on pixel so need to seperate the header from the image
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.