struggling with loading bitmap

SGDK only sub forum

Moderator: Stef

Stef
Very interested
Posts: 3043
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Wed Feb 12, 2014 9:04 am

the

Code: Select all

 u16 VDP_drawBitmap(u16 plan, const Bitmap *bitmap, u16 x, u16 y);
wait for a Bitmap so you have to directly pass the car variable to it (and not the image data field :

Code: Select all

   VDP_drawBitmap(VDP_PLAN_A, car, 3, 3); 

matteus
Very interested
Posts: 336
Joined: Mon Feb 04, 2008 1:41 pm

Post by matteus » Wed Feb 12, 2014 9:21 am

Code

Code: Select all

VDP_drawBitmap(VDP_PLAN_A, car, 3, 3);

Res file

Code: Select all

BITMAP car "car.bmp" -1
Error

Code: Select all

src\main.c|10|error: incompatible type for argument 2 of `VDP_drawBitmap'|

Mixail
Very interested
Posts: 118
Joined: Thu Nov 18, 2010 4:47 pm

Post by Mixail » Wed Feb 12, 2014 10:41 am

matteus, use sample ...\sample\sprite

matteus
Very interested
Posts: 336
Joined: Mon Feb 04, 2008 1:41 pm

Post by matteus » Wed Feb 12, 2014 11:18 am

Mixail wrote:matteus, use sample ...\sample\sprite
Hi Mixail, thank you for your response. My project setup is already based on the sample sprite, it copies everything but the main.c and res.

However the sprite example doesn't use VDP_drawBitmap it uses VDP_drawImageEx. I'm attempting to use the Bitmap engine.

Thank you both, for your efforts and patience with a newbie. Once I have a full understanding of the SGDK. I'd like to help create a document of how to use all of the methods within the SGDK.

Mixail
Very interested
Posts: 118
Joined: Thu Nov 18, 2010 4:47 pm

Post by Mixail » Wed Feb 12, 2014 11:52 am

matteus wrote: I'd like to help create a document of how to use all of the methods within the SGDK.
It would be quite good.

Stef
Very interested
Posts: 3043
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Wed Feb 12, 2014 12:45 pm

matteus wrote:Code

Code: Select all

VDP_drawBitmap(VDP_PLAN_A, car, 3, 3);

Res file

Code: Select all

BITMAP car "car.bmp" -1
Error

Code: Select all

src\main.c|10|error: incompatible type for argument 2 of `VDP_drawBitmap'|
Oh sorry, my fault, you have to pass the pointer of the structure of course :

Code: Select all

VDP_drawBitmap(VDP_PLAN_A, &car, 3, 3);
And if you intend to use the bitmap engine directly then use the BMP_xxx methods instead ;)

matteus
Very interested
Posts: 336
Joined: Mon Feb 04, 2008 1:41 pm

Post by matteus » Wed Feb 12, 2014 3:15 pm

Stef wrote:
matteus wrote:Code

Code: Select all

VDP_drawBitmap(VDP_PLAN_A, car, 3, 3);

Res file

Code: Select all

BITMAP car "car.bmp" -1
Error

Code: Select all

src\main.c|10|error: incompatible type for argument 2 of `VDP_drawBitmap'|
Oh sorry, my fault, you have to pass the pointer of the structure of course :

Code: Select all

VDP_drawBitmap(VDP_PLAN_A, &car, 3, 3);
And if you intend to use the bitmap engine directly then use the BMP_xxx methods instead ;)
Well when I say bitmap engine I mean the bitmap based VDP methods :D

ahh so you pass the pointer to the structure! ooo could we be getting close, I'll try this when I get home from work tonight! I'm excited about getting this working haha how sad am I? :D

matteus
Very interested
Posts: 336
Joined: Mon Feb 04, 2008 1:41 pm

Post by matteus » Wed Feb 12, 2014 7:01 pm

Some success!!! :D however it's hard to tell what its done to my images colours!

Image

The image is a basic 32 x 16 graphic using about 9 colours

Image

matteus
Very interested
Posts: 336
Joined: Mon Feb 04, 2008 1:41 pm

Post by matteus » Wed Feb 12, 2014 7:10 pm

Further testing using VDP_drawImage instead of VDP_drawBitmap resulted in a single 8x8 tile being drawn.

Image

matteus
Very interested
Posts: 336
Joined: Mon Feb 04, 2008 1:41 pm

Post by matteus » Wed Feb 12, 2014 8:04 pm

Right I have some more questions :)

Code: Select all

        VDP_drawImage(VDP_PLAN_A, &car_image, 3, 0);
        VDP_drawImage(VDP_PLAN_B, &background_image, 3, 0);
Does PLAN_A and PLAN_B run off the same palette in the SGDK?

I thought the 16th colour in a standard palette was for transparency? if so should I be able to have the car on VDP_PLAN_A with the background on VDP_PLAN_B. Is the transparency colour black?

Stef
Very interested
Posts: 3043
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Wed Feb 12, 2014 10:55 pm

You can use VDP_drawImageEx(..) method so you can specify more parameters (as the palette informations).
And the transparency color is color 0, not color 15.

matteus
Very interested
Posts: 336
Joined: Mon Feb 04, 2008 1:41 pm

Post by matteus » Wed Feb 12, 2014 11:39 pm

Stef wrote:You can use VDP_drawImageEx(..) method so you can specify more parameters (as the palette informations).
And the transparency color is color 0, not color 15.
Do you have any examples? :)

matteus
Very interested
Posts: 336
Joined: Mon Feb 04, 2008 1:41 pm

Post by matteus » Thu Feb 13, 2014 12:43 am

I use the standard VDP_drawImage method and the image is fine but when i use this method the palette colours are incorrect :( Does anyone know why?

Code: Select all

#include <genesis.h>

#include "gfx.h"
#include "music.h"

int main()
{
    u16 palette[32];
    u16 ind;

   // initialization
    VDP_setScreenWidth320();

    // set all palettes to black
    VDP_setPaletteColors(0, palette_black, 64);

    // load background
    ind = TILE_USERINDEX;
    VDP_drawImageEx(BPLAN, &background_image, TILE_ATTR_FULL(PAL0, FALSE, FALSE, FALSE, ind), 4, 0, FALSE, TRUE);
    ind += background_image.tileset->numTile;
    VDP_drawImageEx(APLAN, &character_image, TILE_ATTR_FULL(PAL1, FALSE, FALSE, FALSE, ind), 4, 0, FALSE, TRUE);
    ind += character_image.tileset->numTile;

    // prepare palette
    memcpy(&palette[0], background_image.palette->data, 16 * 2);
    memcpy(&palette[16], character_image.palette->data, 16 * 2);

    //VDP_drawImage(VDP_PLAN_B, &background_image, 3, 0);
    //VDP_drawImage(VDP_PLAN_A, &character_image, 3, 0);

    // fade in
    VDP_fadeIn(0, (2 * 16) - 1, palette, 20, FALSE);

    while(1)
    {
            VDP_waitVSync();
    }
    return 0;
}

matteus
Very interested
Posts: 336
Joined: Mon Feb 04, 2008 1:41 pm

Post by matteus » Thu Feb 13, 2014 12:46 am

Stef wrote:You can use VDP_drawImageEx(..) method so you can specify more parameters (as the palette informations).
And the transparency color is color 0, not color 15.
Which colour does the image conversion turn to colour 0 though?

matteus
Very interested
Posts: 336
Joined: Mon Feb 04, 2008 1:41 pm

Post by matteus » Thu Feb 13, 2014 12:38 pm

Again thank you both for your help I thought I'd post my work in progess project so I can show I am learning ;)

Image

The car image was my first attempt at getting something to work small scale 32x16 pixels but I was struggling to convert it. So I decided to go with something a lot bigger. . . I draw this image as a vector in macromedia flash and then exported it to a 8bit png.

I know the mega drive is capable of decent art if its handled correctly :)

I can only get the image to display properly using the VDP_DrawImage method. I can't get the palette to load correctly using the VDP_DrawImageEx code (see my previous post) the colours seem incorrectly mapped.

Post Reply