You are not logged in.

#1 2008-08-08 15:52:26

JustWoody
Member

jpeg background coding help

I've been trying to add support to GRRLIB for jpegs (for my purposes primarily as background images). But for some reason the I get the image displayed with alot of flickering (it mush be due to framebuffer / wrong frame type issues, but I can't spot it).

Here are my routines for loading and displaying my jpegs:-

GGRLIB.c

Code:

JPEGIMG GRRLIB_LoadJPEGTexture(const unsigned char inbuffer[], int inbufferlen) {
    JPEGIMG         jpeg;

    memset(&jpeg, 0, sizeof(JPEGIMG));
    jpeg.inbuffer = (char *) inbuffer;
    jpeg.inbufferlength = inbufferlen;

    JPEG_Decompress(&jpeg);

    return jpeg;
}

inline void GRRLIB_DrawJPEGBackground(JPEGIMG jpeg) {
    int             row,
                    col,
                    pix,
                    offset;
    unsigned int   *jpegout;

    pix = 0;
    offset = 0;
    
    jpegout = (unsigned int *) jpeg.outbuffer;

    for (row = 0; row < jpeg.height; row++) {
    for (col = 0; col < (jpeg.width >> 1); col++)
        xfb[fb][offset + col] = jpegout[pix++];

    offset += 320;
    }
}

GGRLIB.h

Code:

#include <jpeg/jpgogc.h>

...
...

JPEGIMG GRRLIB_LoadJPEGTexture(const unsigned char inbuffer[], int inbufferlen);
inline void GRRLIB_DrawJPEGBackground(JPEGIMG jpeg);

In my program

Code:

    JPEGIMG jpegback = GRRLIB_LoadJPEGTexture(startback_jpg,startback_jpg_size);

...
...

    GRRLIB_DrawJPEGBackground(jpegback);

... followed by calls to other GRRlib methods the GRRLIB_Render

Has anyone got any suggestions?

Oh by the way the jpeg library is libjpeg-wii-gc

I'm sure there is probably an easy way to display the image using GX, but I don't know anything about GX (yet) :-)

Last edited by JustWoody (2008-08-08 16:21:44)

Offline

 

#2 2008-08-08 17:49:05

RedShade
Member

Re: jpeg background coding help

GX draws to something called the embeded frame buffer, which then will copy over the external frame buffer (xfb).

With your call, you are writing to the xfb.

When you do GRRLib Render, you are writing over the xfb with whatever you drew in GRRLib

*I looked into libjpeg, but it supports a couple different formats that would each need it's own interpretation of the jpeg data to allow easy conversion from jpeg->texture. FreeImage seems to have better support if you can get that working for libOgc, and it has individual getPixel calls that would make converting it to different textures easy.

**your image routine only loads to the background where GRRLIB can't touch it, so LoadJPEGTexture doesn't seem to fit.

Last edited by RedShade (2008-08-08 19:25:23)

Offline

 

Board footer

Powered by FluxBB