added a few comments, fixed a bug in libpng parsing code

This commit is contained in:
ekeeke31 2009-04-07 16:17:08 +00:00
parent 0d04018401
commit b70626ebd8
2 changed files with 18 additions and 14 deletions

View File

@ -306,22 +306,26 @@ png_texture *OpenTexturePNG(const u8 *buffer)
/* retrieve image information */ /* retrieve image information */
u32 width = png_get_image_width(png_ptr, info_ptr); u32 width = png_get_image_width(png_ptr, info_ptr);
u32 height = png_get_image_height(png_ptr, info_ptr); u32 height = png_get_image_height(png_ptr, info_ptr);
/*u32 bit_depth = png_get_bit_depth(png_ptr, info_ptr);
u32 color_type = png_get_color_type(png_ptr, info_ptr);*/ #if 0
/* ensure PNG images are in the supported format */
u32 bit_depth = png_get_bit_depth(png_ptr, info_ptr);
u32 color_type = png_get_color_type(png_ptr, info_ptr);
/* support for RGBA8 textures ONLY !*/ /* support for RGBA8 textures ONLY !*/
/*if ((color_type != PNG_COLOR_TYPE_RGB_ALPHA) || (bit_depth != 8)) if ((color_type != PNG_COLOR_TYPE_RGB_ALPHA) || (bit_depth != 8))
{ {
png_destroy_read_struct (&png_ptr, &info_ptr, NULL); png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
return; return;
}*/ }
/* 4x4 tiles are required */ /* 4x4 tiles are required */
/*if ((width%4) || (height%4)) if ((width%4) || (height%4))
{ {
png_destroy_read_struct (&png_ptr, &info_ptr, NULL); png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
return; return;
}*/ }
#endif
/* allocate memory to store raw image data */ /* allocate memory to store raw image data */
u32 stride = width << 2; u32 stride = width << 2;
@ -360,7 +364,6 @@ png_texture *OpenTexturePNG(const u8 *buffer)
if (!texture) if (!texture)
{ {
free (img_data); free (img_data);
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
return NULL; return NULL;
} }
@ -369,7 +372,6 @@ png_texture *OpenTexturePNG(const u8 *buffer)
if (!texture->data) if (!texture->data)
{ {
free (img_data); free (img_data);
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
free(texture); free(texture);
return NULL; return NULL;
} }

View File

@ -696,7 +696,7 @@ static void menu_draw(gui_menu *menu)
} }
} }
/* Basic menu prompt */ /* Menu Prompt */
/* prompt window slides in & out */ /* prompt window slides in & out */
static int menu_prompt(gui_menu *parent, char *title, char *items[], u8 nb_items) static int menu_prompt(gui_menu *parent, char *title, char *items[], u8 nb_items)
{ {
@ -868,7 +868,7 @@ static int menu_prompt(gui_menu *parent, char *title, char *items[], u8 nb_items
/* draw parent menu */ /* draw parent menu */
menu_draw(parent); menu_draw(parent);
/* draw window */ /* draw window + header */
DrawTextureAlpha(window, xwindow, ywindow - yoffset, window->width, window->height,235); DrawTextureAlpha(window, xwindow, ywindow - yoffset, window->width, window->height,235);
DrawTexture(top, xwindow, ywindow - yoffset, top->width, top->height); DrawTexture(top, xwindow, ywindow - yoffset, top->width, top->height);
@ -911,7 +911,7 @@ static void menu_slide(gui_menu *menu, u8 speed, u8 out)
yfinal[1] = 0; yfinal[1] = 0;
yfinal[2] = 0; yfinal[2] = 0;
/* logo (top or bottom) */ /* Main Logo (top or bottom) */
image[2] = menu->logo; image[2] = menu->logo;
/* Top banner */ /* Top banner */
@ -941,12 +941,12 @@ static void menu_slide(gui_menu *menu, u8 speed, u8 out)
} }
} }
/* alpha step */ /* Alpha steps */
u16 alpha = out ? 128 : 255; u16 alpha = out ? 128 : 255;
s16 alpha_step = (127 * speed) /offset; s16 alpha_step = (127 * speed) /offset;
if (!out) alpha_step = -alpha_step; if (!out) alpha_step = -alpha_step;
/* loop until final position is reeached */ /* Let's loop until final position has been reached */
while (offset > 0) while (offset > 0)
{ {
if ((menu == &menu_main) && genromsize) if ((menu == &menu_main) && genromsize)
@ -987,6 +987,7 @@ static void menu_slide(gui_menu *menu, u8 speed, u8 out)
SetScreen (); SetScreen ();
} }
/* final position */
if (!out) if (!out)
{ {
menu_draw(menu); menu_draw(menu);
@ -997,8 +998,9 @@ static void menu_slide(gui_menu *menu, u8 speed, u8 out)
} }
#define MAX_COLORS 11 #define MAX_COLORS 11
#define VERSION "version 1.03" #define VERSION "Version 1.03"
/* it's hard to choose a nice background colors ;-) */
static GXColor background_colors[MAX_COLORS]= static GXColor background_colors[MAX_COLORS]=
{ {
{0xcc,0xcc,0xcc,0xff}, /* light grey */ {0xcc,0xcc,0xcc,0xff}, /* light grey */