You are not logged in.

#1 2011-11-02 11:41:30

Crosaider
Member

Draw PNG Image

Hello

I try to paint a PNG Image with this Code

Code:

#include <grrlib.h>

#include <stdlib.h>
#include <wiiuse/wpad.h>

int main(int argc, char **argv) 
{
    GRRLIB_Init(); // Initialise the Graphics & Video subsystem
    WPAD_Init(); // Initialise the Wiimotes
    
    WPAD_SetDataFormat(WPAD_CHAN_ALL, WPAD_FMT_BTNS_ACC_IR);
    WPAD_SetVRes(WPAD_CHAN_ALL, rmode->fbWidth, rmode->xfbHeight);
    
    GRRLIB_texImg *background;
    GRRLIB_texImg *cursor;
    GRRLIB_texImg *singleplayer;
    
    background = GRRLIB_LoadTextureFromFile("images/background.jpg");
    cursor = GRRLIB_LoadTextureFromFile("images/cursor.png");
    singleplayer = GRRLIB_LoadTextureFromFile("images/one.png");
    
    int x, y;

    while(1) 
    {
        x = WPAD_Data(0)->ir.x;
        y = WPAD_Data(0)->ir.y;
    

        WPAD_ScanPads();  // Scan the Wiimotes

        if (WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME)
        {
            break;
        }
            
        GRRLIB_DrawImg(0, 0, background, 0, 1, 1, RGBA( 255, 255, 255, 255 ));
        GRRLIB_DrawImg(x, y, cursor, 0, 1, 1, RGBA( 255, 255, 255, 255 ));
        GRRLIB_DrawImg(50, 50, singleplayer, 0, 1, 1, RGBA( 255, 255, 255, 255 ));
        
        GRRLIB_Render();  // Render the frame buffer to the TV
    }
   
    GRRLIB_Exit(); 
    exit(0);
}

The JPG Image is shown but the PNG Images aren't. Has anyone an idea why I can'T see the pictures? They have transparency and 32 Bit but that isn't the problem??

Greetings
Crosaider

P.S: Sorry for my terrible English - I'm from Germany wink

Offline

 

#2 2011-11-02 20:07:17

Crayon
Bad Mother Fucker

Re: Draw PNG Image

Hi, what is the Width and Height of the image?

Offline

 

#3 2011-11-02 20:11:15

Crosaider
Member

Re: Draw PNG Image

The first has 37x52 Pixel (cursor.png) and the second 285x156 Pixel (one.png)

Offline

 

#4 2011-11-04 03:22:56

Crayon
Bad Mother Fucker

Re: Draw PNG Image

The width and height needs to be multiples of 4. That's not the case for 37 and 285.

When you load files from SD card it's best to add sd:/ before the path. ie:

Code:

background = GRRLIB_LoadTextureFromFile("sd:/images/background.jpg");

Offline

 

Board footer

Powered by FluxBB