Read BMP File

Almamu
Posts: 25
Joined: Tue Apr 07, 2009 8:45 pm

Read BMP File

Post by Almamu » Sat Oct 10, 2009 12:12 pm

How Can I Read A BMP File And Set VRAM_A_LCD = BMP File ?

WinterMute
Site Admin
Posts: 2060
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: Read BMP File

Post by WinterMute » Sat Oct 10, 2009 12:19 pm

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.
Help keep devkitPro toolchains free, Donate today

Personal Blog

Almamu
Posts: 25
Joined: Tue Apr 07, 2009 8:45 pm

Re: Read BMP File

Post by Almamu » Sat Oct 10, 2009 12:54 pm

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.

User avatar
vuurrobin
Posts: 219
Joined: Fri Jul 11, 2008 8:49 pm
Location: The Netherlands
Contact:

Re: Read BMP File

Post by vuurrobin » Sat Oct 10, 2009 1:09 pm

converting the bmp file with grit makes it a lot easier to get the colors and putting them in vram.

Almamu
Posts: 25
Joined: Tue Apr 07, 2009 8:45 pm

Re: Read BMP File

Post by Almamu » Sat Oct 10, 2009 1:55 pm

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)

User avatar
vuurrobin
Posts: 219
Joined: Fri Jul 11, 2008 8:49 pm
Location: The Netherlands
Contact:

Re: Read BMP File

Post by vuurrobin » Sat Oct 10, 2009 6:08 pm

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.

Sylus101
Posts: 179
Joined: Wed Dec 24, 2008 5:08 am

Re: Read BMP File

Post by Sylus101 » Sat Oct 10, 2009 7:06 pm

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.
-Sylus "Not Stylus..." McFrederickson

Come visit my web site.

Almamu
Posts: 25
Joined: Tue Apr 07, 2009 8:45 pm

Re: Read BMP File

Post by Almamu » Sat Oct 10, 2009 7:52 pm

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.

Discostew
Posts: 103
Joined: Sun Mar 08, 2009 7:24 pm

Re: Read BMP File

Post by Discostew » Sun Oct 11, 2009 8:30 am

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.

Almamu
Posts: 25
Joined: Tue Apr 07, 2009 8:45 pm

Re: Read BMP File

Post by Almamu » Sun Oct 11, 2009 11:09 am

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...

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest