Page 1 of 2

Read BMP File

Posted: Sat Oct 10, 2009 12:12 pm
by Almamu
How Can I Read A BMP File And Set VRAM_A_LCD = BMP File ?

Re: Read BMP File

Posted: Sat Oct 10, 2009 12:19 pm
by WinterMute
That really depends on why you want to do that.

For an image viewer application this is a reasonable approach but for most DS games/applications you should use grit to convert the image at compile time. There are a couple of examples showing this in the supplied sample code.

Re: Read BMP File

Posted: Sat Oct 10, 2009 12:54 pm
by Almamu
WinterMute wrote:That really depends on why you want to do that.

For an image viewer application this is a reasonable approach but for most DS games/applications you should use grit to convert the image at compile time. There are a couple of examples showing this in the supplied sample code.
I Only Want Read The Color Information(for example: x=0, y=1, color=30) and then set the VRAM_A_LCD on this coordinates the color.

Re: Read BMP File

Posted: Sat Oct 10, 2009 1:09 pm
by vuurrobin
converting the bmp file with grit makes it a lot easier to get the colors and putting them in vram.

Re: Read BMP File

Posted: Sat Oct 10, 2009 1:55 pm
by Almamu
vuurrobin wrote:converting the bmp file with grit makes it a lot easier to get the colors and putting them in vram.
I Know, But I Need To Load On Program Running(If The Player Press Select Loads the BMP File Saved in FAT)

Re: Read BMP File

Posted: Sat Oct 10, 2009 6:08 pm
by vuurrobin
you can use grit to convert the image file to an *.bin file and load that from fat. still easier than converting it on the ds.

Re: Read BMP File

Posted: Sat Oct 10, 2009 7:06 pm
by Sylus101
Just to finally clarify what the best approach would be, are any images going to be user provided or are you going to be including what the user can select?

If they can be user provided, then you'll need to research the bmp file format and header to know what bytes to read to determine size, bit depth, etc, etc... It's easy to get this information with a couple of google searches.

If you're providing them but still want to load from the filesystem, then vurrobin's suggestion of converting to binary first is the best way to go because you can pretty much read in the binary data and write it directly to VRAM without the worry of cracking the bmp file format.

Re: Read BMP File

Posted: Sat Oct 10, 2009 7:52 pm
by Almamu
Sylus101 wrote:Just to finally clarify what the best approach would be, are any images going to be user provided or are you going to be including what the user can select?

If they can be user provided, then you'll need to research the bmp file format and header to know what bytes to read to determine size, bit depth, etc, etc... It's easy to get this information with a couple of google searches.

If you're providing them but still want to load from the filesystem, then vurrobin's suggestion of converting to binary first is the best way to go because you can pretty much read in the binary data and write it directly to VRAM without the worry of cracking the bmp file format.
I'm Creating A Simple Paint And The User Can Save Own's BMP's, But If You TurnOff or Clean The Screen Re-Load The Image And You Can Re-Edit it.


User Draws-Saves The Image-Turn Off The Console-Then Start The Application And Press A To Load The BMP What He/She Saved Before.

Re: Read BMP File

Posted: Sun Oct 11, 2009 8:30 am
by Discostew
Yeah, basically dealing with user-content, which requires that you know the format that you are working with.

Once loaded into memory, the format can be whatever to your liking, but understand that in order for it to be shown on-screen, you must comply with the formats the NDS can use to display stuff. A simple way to set it up is to set the display to framebuffer mode, and VRAM_A bank to LCD, so that you can just copy a raw 256x192 15-bit bitmap into vram and display it, but depending on what other plans you have for it may require alternate methods to dealing with it.

Re: Read BMP File

Posted: Sun Oct 11, 2009 11:09 am
by Almamu
Discostew wrote:Yeah, basically dealing with user-content, which requires that you know the format that you are working with.

Once loaded into memory, the format can be whatever to your liking, but understand that in order for it to be shown on-screen, you must comply with the formats the NDS can use to display stuff. A simple way to set it up is to set the display to framebuffer mode, and VRAM_A bank to LCD, so that you can just copy a raw 256x192 15-bit bitmap into vram and display it, but depending on what other plans you have for it may require alternate methods to dealing with it.

Code: Select all

videoSetMode(MODE_FB0);
vramSetVBlankA(VRAM_A_LCD);
I Have The Screen Initialized as the Upper code. I Only want to read a BMP(ArcoPaint.BMP)And Show It On The Bottom Screen. I Doesn't Know How To Load A BMP File, Only How To Save It...