displaying raw image

Post Reply
Tomdev
Posts: 82
Joined: Thu Jan 08, 2009 9:15 pm

displaying raw image

Post by Tomdev » Mon Jun 22, 2009 7:39 am

hey everyone,

it try to display a raw image, but every time i get a black screen. but when i use dsorganize it displays perfect. can anyone tell me how to display a raw image. i'm doing it like this now:
Code:

Code: Select all

#include <nds.h>
#include <fat.h>
#include <stdio.h>

int main(void) {
//---------------------------------------------------------------------------------
 
videoSetMode(MODE_5_2D);

vramSetBankA(VRAM_A_MAIN_BG_0x06000000);

int bg = bgInit(3, BgType_Bmp16, BgSize_B16_256x256, 0,0);

u16* backBuffer  = (u16*)0x06000000;
fatInitDefault();
FILE * pfile;
pfile = fopen("decoded.raw", "rb");
fread(backBuffer, 1, 256*192*2, pfile);
fclose(pfile);

bgUpdate();

   while(1) {
      swiWaitForVBlank();
   }

}

RyouArashi
Posts: 29
Joined: Sun Mar 29, 2009 9:23 pm

Re: displaying raw image

Post by RyouArashi » Mon Jun 22, 2009 9:26 am

I looked up Bmp BGs in the examples, it is the same code there.

Possible Problems might be:
- File Access (Check the return values of fatInitDefault, fopen, fread, etc.)
- fread may be writing the data to the destination bytewise, however VRAM can only be
accessed by 16bit or 32bit reads or writes. 8bit access is ignored on ARM9 side.

Try to fread your image to a buffer in Main RAM and then copy it to VRAM with dmaCopy.

Tomdev
Posts: 82
Joined: Thu Jan 08, 2009 9:15 pm

Re: displaying raw image

Post by Tomdev » Mon Jun 22, 2009 12:31 pm

actually this was not the problem, it was somewhere else in the code. but thanks anyway :P

Post Reply

Who is online

Users browsing this forum: No registered users and 26 guests