hchapman/libwiigui

Scrambled image from SD

Closed this issue · 1 comments

What steps will reproduce the problem?
1. loading a png file from sd card with fopen

What is the expected output? What do you see instead?
Should show a clean image but only shows it scrambled

What version of the product are you using? On what operating system?
The actual SVN

Please provide any additional information below.

That´s how i try to doing it at the moment

u8 *imgsd;
static u32 imgsd_size;

int loadimg(char * filename)
{
    FILE *fp;
    u32 filesize;
    u32 ret;
    char filepath[128];

    ret = fatInitDefault();
    if (!ret) {
        return 0;
    }
    sprintf(filepath,filename);

    fp = fopen(filepath, "rb");
    if (!fp) {
        return 0;
    }
    fseek(fp, 0, SEEK_END);
    filesize = ftell(fp);
    fseek(fp, 0, SEEK_SET);

    imgsd= (u8*)malloc (sizeof(u8)*filesize);
    if (imgsd== 0)
    {
        //printf("ERROR: Out of memory\n");
        return 0;
    }

    memset(imgsd,0,filesize);
    if(cover == 0){
        fclose(fp);
        return 0;
    }
    char size[30];

    ret = fread(imgsd, 1, filesize, fp);
    if(ret != filesize){    
        free(imgsd);
        fclose(fp);
        return 0;
    }
    imgsd_size = filesize;
return 1;
}


static int menu()
{
...
    if (loadimg("noimage") != 0)
    {
    GuiImageData coverimgdata((const u8*)cover);
        CoverImg = new GuiImage(&coverimgdata);
    CoverImg->SetAlignment(ALIGN_LEFT, ALIGN_TOP);
    CoverImg->SetPosition(50,200);
    }
...
}

Original issue reported on code.google.com by thedarkn...@googlemail.com on 13 Apr 2009 at 4:08

There isn't a problem with the image displaying in libwiigui. If you're having 
problems you'll have to debug your own code. One tip is that the image width 
and 
height must multiples of 4

Original comment by dborth@gmail.com on 15 Apr 2009 at 9:58

  • Changed state: Invalid