avr-chat
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-chat] Storing B&W bitmap images into Flash : file format sugges


From: Dustin Lang
Subject: Re: [avr-chat] Storing B&W bitmap images into Flash : file format suggestion ?
Date: Tue, 12 Jan 2010 21:34:38 -0500 (EST)
User-agent: Alpine 1.00 (DEB 882 2007-12-20)


Some pointers:

-reading files: try fopen(), fread(); see "man fopen" on a linux box.

-image format: have a look at the "netpbm" toolkit. It is very useful. The "pbm" format may be useful for you. For example, if your image is a black-and-white jpeg:

jpegtopnm bw.jpg | pgmtopbm > bw.pbm

The "bw.pbm" file has a short header followed by (8 pixels per byte) raw pixels.

This command:

od -t x1 bw.pbm

writes out the "bw.pbm" file as hex values.

If you do this:

od -t x1 bw.pbm | sed 's/  /,/g'

you can replace the spaces with commas and have something that you can copy-n-paste, with a bit of editing, into your C code.

cheers,
dstn.


On Wed, 13 Jan 2010, Vincent Trouilliez wrote:

On Wed, 13 Jan 2010 10:56:03 +1030
"Daniel O'Connor" <address@hidden> wrote:

Starting to sound like too much work IMO :)

Yeah, I think I will just write my own little C programme to convert
the picture into a C array of bytes. I now fancy doing it regardless,
just as a little exercise... and it's just cool to build his own tools
I find ! I mean, can't be that complex, just need to figure out how to
read a binary file on Linux.

FreeBSD comes with 'file2c'
http://svn.freebsd.org/viewvc/base/head/usr.bin/file2c/file2c.c?revision=200462&view=markup

I guess this does what I stated above ? It must read a file fro the
disk, but for the life ofd me I can't see any instruction/command
related to reading/opening files in this piece of code.. I must be
blind ?! :-/
Anyway, I will just search for some Linux C tutorial (I assume the
commands to handle files/disks are specific to Linux, so a Windows
C tutorial won't do !...)

Also it only does RGBA which will cost you lots of RAM since you only
want B&W.

Yeah we have already pointed this out I think ;-)

RLE is Run Length Encoding, a basic compression scheme
http://en.wikipedia.org/wiki/Run-length_encoding

Thanks ! This Wikipedia thing is bloody useful isn't it !
RLE yeah.. now I think of it, ISTR it was used in the "PCX" picture
file format in Windows 3.1 a century ago LOL...

I don't think it's suited to my project though... it would save me
space, but there is too much decoding for the case at hand, and it
would be too much work when displaying font digits. So I prefer an
uncompressed format, where I can just dump my array of bits straight
onto the LCD, to draw very fast, with maybe some shifting or masking
or trivial things, but no arythmetic/calculations...

I was suggested this utility off-list:

http://www.dreamsware.info/

It looks great, but I am not quite sure that it stuffs 8 pixels per
byte, I fear it wastes a whole byte for each single B/W pixel... which I
can't afford (I am using an ATmega32, I have space for one full screen
picture or two (I don't need more anyway), but that's about it). I must
absolutely pack 8 pixels per byte. The BMP format I tried the other day
appears to do that, so it could be a good base for my utility program.
I will keep searching a little bit for less "polluted" formats though,
to simplify the work.


Regards,

--
Vince


_______________________________________________
AVR-chat mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/avr-chat





reply via email to

[Prev in Thread] Current Thread [Next in Thread]