Understanding bmp image files

P

pranav

Hello,
I want to read a BMP file, do some processing and then write it in a
new file. The problem is in the third step. For reading the file, i
have converted the file into decimal numbers, representing the pixel
values. Then i perform calculations on those decimal numbers. Now i am
unable to convert those into the format as required by the "bmp" file.
Any one, who is into image reading/manipulation, please help.
 
M

Marc 'BlackJack' Rintsch

I want to read a BMP file, do some processing and then write it in a
new file. The problem is in the third step. For reading the file, i
have converted the file into decimal numbers, representing the pixel
values.

You have converted the data into numbers, not "decimal" numbers.
Then i perform calculations on those decimal numbers. Now i am
unable to convert those into the format as required by the "bmp" file.
Any one, who is into image reading/manipulation, please help.

How have you converted the bytes into numbers and why can't you reverse
that step?

Ciao,
Marc 'BlackJack' Rintsch
 
P

Paul McGuire

Hello,
I want to read a BMP file, do some processing and then write it in a
new file. The problem is in the third step. For reading the file, i
have converted the file into decimal numbers, representing the pixel
values. Then i perform calculations on those decimal numbers. Now i am
unable to convert those into the format as required by the "bmp" file.
Any one, who is into image reading/manipulation, please help.

Here is a link to a *very* crude BMP file utility I wrote a long time
ago. (http://www.geocities.com/ptmcg/python/index.html#bmp) Follow
the highlighted "module" link to see the underlying code - there are
methods for saving the BMP data to a file. Perhaps those samples
might give you some insight on what is required.

(I would probably rewrite this to use the struct module nowadays, but
this code works as is.)

-- Paul
 
T

Terry Reedy

| Hello,
| I want to read a BMP file, do some processing and then write it in a
| new file. The problem is in the third step. For reading the file, i
| have converted the file into decimal numbers, representing the pixel
| values. Then i perform calculations on those decimal numbers. Now i am
| unable to convert those into the format as required by the "bmp" file.
| Any one, who is into image reading/manipulation, please help.

I would look into PIL, PyGame, and Numeric/Numpy.
 
P

Paul McGuire

| Hello,
| I want to read a BMP file, do some processing and then write it in a
| new file. The problem is in the third step. For reading the file, i
| have converted the file into decimal numbers, representing the pixel
| values. Then i perform calculations on those decimal numbers. Now i am
| unable to convert those into the format as required by the "bmp" file.
| Any one, who is into image reading/manipulation, please help.

I would look into PIL, PyGame, and Numeric/Numpy.

My mistake, for some reason I thought the OP wanted to read a BMP file
directly, and the code I cited shows the guts of writing out a BMP
file so he might get an idea about the file's structure - to address
the OP's actual question, I would second the recommendation to use PIL
to read, manipulate, and write back out the pixel values.

-- Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top