Images on the nds

You can prepare images with

  • wingrit for WINDOWS
  • jgrit for MACOS

the settings for the bitmapmode are:

under gfx

  • gfx
  • bpp 16
  • cprs off

under file:

  • filepath is indicated if you drag an image in the gba exporter window
  • type: binary
  • h file: none and at the right of this u16

hit ok and the binary file can be found in the folder of th source file

after that: say you have the file called :  click.img.bin

put this bin file in the data folder of your project

include the header file like this using underscores: #include “click_img_bin.h”

and use it like this:

  • dmaCopy(click_img_bin, pointerToStartMem,   2*256*256     );// if background
  • a copy pixels method in case of a smaller image somewhere on the screen

example of a copy pixels function:

inline void drawPixel(u16 *video_buffer, u16 x, u16 y, u16 color) {

u32 index = (y * SCREEN_WIDTH) + x;
video_buffer[index] = color;
}

in combination with:

void drawPartOfBitmap(u16 *buffer, u16 destX, u16 destY, u16* bitmap, u16 startX, u8 startY, u8 widthD, u8 heightD, u16 widthP, u8 heightP) {
u16 i, j, index;
for(i = 0; i < heightD; i++) {
for(j = 0; j < widthD; j++) {

index = startX + j + i * widthP;

if (PIXEL(bitmap[index]) != COLOR_WHITE) //the transparent color
drawPixel(buffer, destX + j, destY + i, PIXEL(bitmap[index]));
}
}
}

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: