#148105 - sowee - Wed Jan 02, 2008 9:12 am
I am able to read png8 files from the memory card and get their info when i followed the discussion between rook02 and quirky, however, i have no idea how to display them on screen. Can someone teach me how to do this? I really still have minimal knowledge regarding programming with libnds, and I'm not even sure what screen mode is the best to display it to. The only means i can find of displaying pictures is the one where i have to convert a png file to raw, which is not what i intended on doing. I would like to know how programs like Colors! could load png images on screen. Thanks in advance :D
#148119 - tepples - Wed Jan 02, 2008 2:31 pm
The general formula:
- Figure out the format that libpng gives you.
- Figure out which format the hardware needs.
- Figure out how to convert 1 to 2.
If you want to display 8-bit PNG images as a background, I would recommend starting out by using an "extended rotation" bitmap background in mode 4 (GBA) or mode 5 (DS). PNG was originally designed for use on PC-like graphics models, and these bitmap backgrounds most closely match how PC bitmaps are laid out.
If you want to display 8-bit PNG images as sprite cels, I recommend getting them working as a background first and then coming back for more help.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#148204 - sowee - Thu Jan 03, 2008 4:01 pm
Thanks for the tip, i drew the png files using framebuffer mode at the moment using the palette and pixel array libpng gives me. I'll be trying out drawing them in the extended rotation bg mode 5 next like you said hehe.
I have another question though, would it be possible to treat the png file i load from the memory card like a sprite?
#148237 - tepples - Thu Jan 03, 2008 9:02 pm
Yes. But for each run of 8 pixels, you'll have to figure out which tile and which offset within the tile the pixels belong to. That's a bit of bit-shifting.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#148286 - sowee - Fri Jan 04, 2008 10:15 am
I see...although i didn't understand that very much hehe, maybe i'll get it next time after reading up more on the subject :P
but..just to be clear, what you're saying is that with that method i can use png files loaded directly from the mem card as sprites without having to link them? because as i understand it right now sprites have to be converted and linked as headers to be able to use them as sprites?
On a side note, i've been reading the forums about playing sound files, and i want to be able to play sound files (wav and/or mp3) directly from the mem card too....
1.) For the mp3 support i understand i'd have to port libmad to the ds. Would porting it now with the new devarm be still as simple as before?
2.) But for the wav support, i still have no clue how to do it. Is there a library that does that already? i read in one of your posts (in the topic: Raising pitch of a sound effect) that you know of a .wav parser library. Would i be able to use that library and play wav files directly from the mem card? If so, can i know what library this is or where i can find it? thanks..hehe and sorry for bothering you with all these questions hehe.. :P
#148287 - simonjhall - Fri Jan 04, 2008 10:46 am
I don't know anything about sprites but I can help with the sound stuff.
1) mp3 - for this you could use libmad. It's been ported to the DS before (eg it's in scummvm) and it's probably in use by other projects so have a hunt around for the source.
There's also a new lib for sound stuff - have a look here:
http://forum.gbadev.org/viewtopic.php?t=14617
2) wav is easy and the few functions you need to parse wav files, resample them to an arbitrary sample rate/sample width and play them is in the Quake DS source. Have a look in snd_null_7.cpp. Runs on the ARM7, but would run just fine on the '9.
_________________
Big thanks to everyone who donated for Quake2
#148292 - sowee - Fri Jan 04, 2008 12:34 pm
Thanks for the quick reply hehe, ill look into quake ds but which one, i seem to recall having seen two different quake ds projects lately :P
#148377 - sowee - Sat Jan 05, 2008 3:04 am
Oops, i just read at the ds quake website that the other quake ds port is run by simon hall..so that must be you hehehe so i guess you're referring to your quake ds hehe :D . Thanks again ^_^