Merge pull request #19 from GRRLIB/gamecube

Fix GameCube support
This commit is contained in:
Crayon 2021-07-07 00:44:20 -04:00 committed by GitHub
commit 9aa8be58e2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 109 additions and 94 deletions

View file

@ -19,7 +19,7 @@ jobs:
run: | run: |
(cd GRRLIB && make clean all install) (cd GRRLIB && make clean all install)
(cd examples && make) (cd examples && make)
(cd GRRLIB && make PLATFORM=cube clean all) (cd GRRLIB/GRRLIB && make PLATFORM=cube clean all install)
- uses: actions/upload-artifact@master - uses: actions/upload-artifact@master
with: with:

View file

@ -66,7 +66,8 @@ int GRRLIB_Init (void) {
VIDEO_SetBlack(true); // Disable video output during initialisation VIDEO_SetBlack(true); // Disable video output during initialisation
// Grab a pointer to the video mode attributes // Grab a pointer to the video mode attributes
if ( !(rmode = VIDEO_GetPreferredMode(NULL)) ) { rmode = VIDEO_GetPreferredMode(NULL);
if (rmode == NULL) {
return -1; return -1;
} }
@ -76,21 +77,24 @@ int GRRLIB_Init (void) {
//rmode = &TVPal574IntDfScale; //rmode = &TVPal574IntDfScale;
rmode = &TVPal528IntDf; // BC ...this is still wrong, but "less bad" for now rmode = &TVPal528IntDf; // BC ...this is still wrong, but "less bad" for now
break; break;
default:
#ifdef HW_DOL
if(VIDEO_HaveComponentCable()) {
rmode = &TVNtsc480Prog;
}
#endif
break;
} }
#if defined(HW_RVL) #if defined(HW_RVL)
// 16:9 and 4:3 Screen Adjustment for Wii // 16:9 and 4:3 Screen Adjustment for Wii
if (CONF_GetAspectRatio() == CONF_ASPECT_16_9) { if (CONF_GetAspectRatio() == CONF_ASPECT_16_9) {
rmode->viWidth = 678; rmode->viWidth = 678;
rmode->viXOrigin = (VI_MAX_WIDTH_NTSC - 678) / 2; // This probably needs to consider PAL
} else { // 4:3 } else { // 4:3
rmode->viWidth = 672; rmode->viWidth = 672;
rmode->viXOrigin = (VI_MAX_WIDTH_NTSC - 672) / 2;
} }
#else // This probably needs to consider PAL
// GameCube rmode->viXOrigin = (VI_MAX_WIDTH_NTSC - rmode->viWidth) / 2;
rmode->viWidth = 672;
rmode->viXOrigin = (VI_MAX_WIDTH_NTSC - 672) / 2;
#endif #endif
#if defined(HW_RVL) #if defined(HW_RVL)

View file

@ -12,16 +12,23 @@ endif
ifeq ($(PLATFORM),cube) ifeq ($(PLATFORM),cube)
include $(DEVKITPPC)/gamecube_rules include $(DEVKITPPC)/gamecube_rules
MACHDEP += -DHW_DOL
INSTALL_INC := $(DEVKITPRO)/portlibs/gamecube/include
INSTALL_LIB := $(DEVKITPRO)/portlibs/gamecube/lib
else else
include $(DEVKITPPC)/wii_rules include $(DEVKITPPC)/wii_rules
MACHDEP += -DHW_RVL
INSTALL_INC := $(DEVKITPRO)/portlibs/wii/include
INSTALL_LIB := $(DEVKITPRO)/portlibs/wii/lib
endif endif
NULLSTR := NULLSTR :=
PWD := $(subst $(NULLSTR) ,\ ,$(shell pwd)) PWD := $(subst $(NULLSTR) ,\ ,$(shell pwd))
INSTALL_INC := $(DEVKITPRO)/portlibs/ppc/include
INSTALL_LIB := $(DEVKITPRO)/portlibs/ppc/lib
INCLUDE := -I../lib/pngu -I$(PWD) -I$(LIBOGC_INC) -I$(DEVKITPRO)/portlibs/ppc/include -I$(DEVKITPRO)/portlibs/ppc/include/freetype2 INCLUDE := -I../lib/pngu -I$(PWD) -I$(LIBOGC_INC) -I$(DEVKITPRO)/portlibs/ppc/include -I$(DEVKITPRO)/portlibs/ppc/include/freetype2
CFLAGS := -O2 -Wall $(MACHDEP) $(INCLUDE) CFLAGS := -O2 -Wall $(MACHDEP) $(INCLUDE)

View file

@ -10,16 +10,13 @@ ifeq ($(strip $(DEVKITPRO)),)
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>devkitPro) $(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>devkitPro)
endif endif
ifeq ($(PLATFORM),cube) include $(DEVKITPPC)/base_rules
include $(DEVKITPPC)/gamecube_rules MACHDEP = -DGEKKO -mcpu=750 -meabi -mhard-float
else
include $(DEVKITPPC)/wii_rules
endif
INSTALL_INC := $(DEVKITPRO)/portlibs/ppc/include INSTALL_INC := $(DEVKITPRO)/portlibs/ppc/include
INSTALL_LIB := $(DEVKITPRO)/portlibs/ppc/lib INSTALL_LIB := $(DEVKITPRO)/portlibs/ppc/lib
INCLUDE := -I$(LIBOGC_INC) -I$(DEVKITPRO)/portlibs/ppc/include INCLUDE := -I$(DEVKITPRO)/portlibs/ppc/include
CFLAGS := -O2 -Wall $(MACHDEP) $(INCLUDE) CFLAGS := -O2 -Wall $(MACHDEP) $(INCLUDE)
LIB := pngu LIB := pngu

View file

@ -48,7 +48,7 @@ struct _IMGCTX
png_structp png_ptr; png_structp png_ptr;
png_infop info_ptr; png_infop info_ptr;
FILE *fd; FILE *fd;
png_bytep *row_pointers; png_bytep *row_pointers;
png_bytep img_data; png_bytep img_data;
}; };
@ -165,7 +165,7 @@ int PNGU_DecodeToYCbYCr (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buff
for (x = 0; x < (width / 2); x++) for (x = 0; x < (width / 2); x++)
((PNGU_u32 *)buffer)[y*buffWidth+x] = PNGU_RGB8_TO_YCbYCr (*(ctx->row_pointers[y]+x*6), *(ctx->row_pointers[y]+x*6+1), *(ctx->row_pointers[y]+x*6+2), ((PNGU_u32 *)buffer)[y*buffWidth+x] = PNGU_RGB8_TO_YCbYCr (*(ctx->row_pointers[y]+x*6), *(ctx->row_pointers[y]+x*6+1), *(ctx->row_pointers[y]+x*6+2),
*(ctx->row_pointers[y]+x*6+3), *(ctx->row_pointers[y]+x*6+4), *(ctx->row_pointers[y]+x*6+5)); *(ctx->row_pointers[y]+x*6+3), *(ctx->row_pointers[y]+x*6+4), *(ctx->row_pointers[y]+x*6+5));
// Free resources // Free resources
free (ctx->img_data); free (ctx->img_data);
free (ctx->row_pointers); free (ctx->row_pointers);
@ -179,7 +179,7 @@ int PNGU_DecodeToRGB565 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buff
{ {
int result; int result;
PNGU_u32 x, y, buffWidth; PNGU_u32 x, y, buffWidth;
result = pngu_decode (ctx, width, height, 1); result = pngu_decode (ctx, width, height, 1);
if (result != PNGU_OK) if (result != PNGU_OK)
return result; return result;
@ -189,11 +189,11 @@ int PNGU_DecodeToRGB565 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buff
// Copy image to the output buffer // Copy image to the output buffer
for (y = 0; y < height; y++) for (y = 0; y < height; y++)
for (x = 0; x < width; x++) for (x = 0; x < width; x++)
((PNGU_u16 *)buffer)[y*buffWidth+x] = ((PNGU_u16 *)buffer)[y*buffWidth+x] =
(((PNGU_u16) (ctx->row_pointers[y][x*3] & 0xF8)) << 8) | (((PNGU_u16) (ctx->row_pointers[y][x*3] & 0xF8)) << 8) |
(((PNGU_u16) (ctx->row_pointers[y][x*3+1] & 0xFC)) << 3) | (((PNGU_u16) (ctx->row_pointers[y][x*3+1] & 0xFC)) << 3) |
(((PNGU_u16) (ctx->row_pointers[y][x*3+2] & 0xF8)) >> 3); (((PNGU_u16) (ctx->row_pointers[y][x*3+2] & 0xF8)) >> 3);
// Free resources // Free resources
free (ctx->img_data); free (ctx->img_data);
free (ctx->row_pointers); free (ctx->row_pointers);
@ -207,7 +207,7 @@ int PNGU_DecodeToRGBA8 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buffe
{ {
int result; int result;
PNGU_u32 x, y, buffWidth; PNGU_u32 x, y, buffWidth;
result = pngu_decode (ctx, width, height, 0); result = pngu_decode (ctx, width, height, 0);
if (result != PNGU_OK) if (result != PNGU_OK)
return result; return result;
@ -226,13 +226,13 @@ int PNGU_DecodeToRGBA8 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buffe
// No alpha channel present, copy image to the output buffer // No alpha channel present, copy image to the output buffer
for (y = 0; y < height; y++) for (y = 0; y < height; y++)
for (x = 0; x < width; x++) for (x = 0; x < width; x++)
((PNGU_u32 *)buffer)[y*buffWidth+x] = ((PNGU_u32 *)buffer)[y*buffWidth+x] =
(((PNGU_u32) ctx->row_pointers[y][x*3]) << 24) | (((PNGU_u32) ctx->row_pointers[y][x*3]) << 24) |
(((PNGU_u32) ctx->row_pointers[y][x*3+1]) << 16) | (((PNGU_u32) ctx->row_pointers[y][x*3+1]) << 16) |
(((PNGU_u32) ctx->row_pointers[y][x*3+2]) << 8) | (((PNGU_u32) ctx->row_pointers[y][x*3+2]) << 8) |
((PNGU_u32) default_alpha); ((PNGU_u32) default_alpha);
} }
// Free resources // Free resources
free (ctx->img_data); free (ctx->img_data);
free (ctx->row_pointers); free (ctx->row_pointers);
@ -266,37 +266,37 @@ int PNGU_DecodeTo4x4RGB565 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *b
PNGU_u64 field64 = *((PNGU_u64 *)(ctx->row_pointers[y*4]+x*12)); PNGU_u64 field64 = *((PNGU_u64 *)(ctx->row_pointers[y*4]+x*12));
PNGU_u64 field32 = (PNGU_u64) *((PNGU_u32 *)(ctx->row_pointers[y*4]+x*12+8)); PNGU_u64 field32 = (PNGU_u64) *((PNGU_u32 *)(ctx->row_pointers[y*4]+x*12+8));
((PNGU_u64 *) buffer)[blockbase] = ((PNGU_u64 *) buffer)[blockbase] =
(((field64 & 0xF800000000000000ULL) | ((field64 & 0xFC000000000000ULL) << 3) | ((field64 & 0xF80000000000ULL) << 5)) | (((field64 & 0xF800000000000000ULL) | ((field64 & 0xFC000000000000ULL) << 3) | ((field64 & 0xF80000000000ULL) << 5)) |
(((field64 & 0xF800000000ULL) << 8) | ((field64 & 0xFC000000ULL) << 11) | ((field64 & 0xF80000ULL) << 13)) | (((field64 & 0xF800000000ULL) << 8) | ((field64 & 0xFC000000ULL) << 11) | ((field64 & 0xF80000ULL) << 13)) |
(((field64 & 0xF800ULL) << 16) | ((field64 & 0xFCULL) << 19) | ((field32 & 0xF8000000ULL) >> 11)) | (((field64 & 0xF800ULL) << 16) | ((field64 & 0xFCULL) << 19) | ((field32 & 0xF8000000ULL) >> 11)) |
(((field32 & 0xF80000ULL) >> 8) | ((field32 & 0xFC00ULL) >> 5) | ((field32 & 0xF8ULL) >> 3))); (((field32 & 0xF80000ULL) >> 8) | ((field32 & 0xFC00ULL) >> 5) | ((field32 & 0xF8ULL) >> 3)));
field64 = *((PNGU_u64 *)(ctx->row_pointers[y*4+1]+x*12)); field64 = *((PNGU_u64 *)(ctx->row_pointers[y*4+1]+x*12));
field32 = (PNGU_u64) *((PNGU_u32 *)(ctx->row_pointers[y*4+1]+x*12+8)); field32 = (PNGU_u64) *((PNGU_u32 *)(ctx->row_pointers[y*4+1]+x*12+8));
((PNGU_u64 *) buffer)[blockbase+1] = ((PNGU_u64 *) buffer)[blockbase+1] =
(((field64 & 0xF800000000000000ULL) | ((field64 & 0xFC000000000000ULL) << 3) | ((field64 & 0xF80000000000ULL) << 5)) | (((field64 & 0xF800000000000000ULL) | ((field64 & 0xFC000000000000ULL) << 3) | ((field64 & 0xF80000000000ULL) << 5)) |
(((field64 & 0xF800000000ULL) << 8) | ((field64 & 0xFC000000ULL) << 11) | ((field64 & 0xF80000ULL) << 13)) | (((field64 & 0xF800000000ULL) << 8) | ((field64 & 0xFC000000ULL) << 11) | ((field64 & 0xF80000ULL) << 13)) |
(((field64 & 0xF800ULL) << 16) | ((field64 & 0xFCULL) << 19) | ((field32 & 0xF8000000ULL) >> 11)) | (((field64 & 0xF800ULL) << 16) | ((field64 & 0xFCULL) << 19) | ((field32 & 0xF8000000ULL) >> 11)) |
(((field32 & 0xF80000ULL) >> 8) | ((field32 & 0xFC00ULL) >> 5) | ((field32 & 0xF8ULL) >> 3))); (((field32 & 0xF80000ULL) >> 8) | ((field32 & 0xFC00ULL) >> 5) | ((field32 & 0xF8ULL) >> 3)));
field64 = *((PNGU_u64 *)(ctx->row_pointers[y*4+2]+x*12)); field64 = *((PNGU_u64 *)(ctx->row_pointers[y*4+2]+x*12));
field32 = (PNGU_u64) *((PNGU_u32 *)(ctx->row_pointers[y*4+2]+x*12+8)); field32 = (PNGU_u64) *((PNGU_u32 *)(ctx->row_pointers[y*4+2]+x*12+8));
((PNGU_u64 *) buffer)[blockbase+2] = ((PNGU_u64 *) buffer)[blockbase+2] =
(((field64 & 0xF800000000000000ULL) | ((field64 & 0xFC000000000000ULL) << 3) | ((field64 & 0xF80000000000ULL) << 5)) | (((field64 & 0xF800000000000000ULL) | ((field64 & 0xFC000000000000ULL) << 3) | ((field64 & 0xF80000000000ULL) << 5)) |
(((field64 & 0xF800000000ULL) << 8) | ((field64 & 0xFC000000ULL) << 11) | ((field64 & 0xF80000ULL) << 13)) | (((field64 & 0xF800000000ULL) << 8) | ((field64 & 0xFC000000ULL) << 11) | ((field64 & 0xF80000ULL) << 13)) |
(((field64 & 0xF800ULL) << 16) | ((field64 & 0xFCULL) << 19) | ((field32 & 0xF8000000ULL) >> 11)) | (((field64 & 0xF800ULL) << 16) | ((field64 & 0xFCULL) << 19) | ((field32 & 0xF8000000ULL) >> 11)) |
(((field32 & 0xF80000ULL) >> 8) | ((field32 & 0xFC00ULL) >> 5) | ((field32 & 0xF8ULL) >> 3))); (((field32 & 0xF80000ULL) >> 8) | ((field32 & 0xFC00ULL) >> 5) | ((field32 & 0xF8ULL) >> 3)));
field64 = *((PNGU_u64 *)(ctx->row_pointers[y*4+3]+x*12)); field64 = *((PNGU_u64 *)(ctx->row_pointers[y*4+3]+x*12));
field32 = (PNGU_u64) *((PNGU_u32 *)(ctx->row_pointers[y*4+3]+x*12+8)); field32 = (PNGU_u64) *((PNGU_u32 *)(ctx->row_pointers[y*4+3]+x*12+8));
((PNGU_u64 *) buffer)[blockbase+3] = ((PNGU_u64 *) buffer)[blockbase+3] =
(((field64 & 0xF800000000000000ULL) | ((field64 & 0xFC000000000000ULL) << 3) | ((field64 & 0xF80000000000ULL) << 5)) | (((field64 & 0xF800000000000000ULL) | ((field64 & 0xFC000000000000ULL) << 3) | ((field64 & 0xF80000000000ULL) << 5)) |
(((field64 & 0xF800000000ULL) << 8) | ((field64 & 0xFC000000ULL) << 11) | ((field64 & 0xF80000ULL) << 13)) | (((field64 & 0xF800000000ULL) << 8) | ((field64 & 0xFC000000ULL) << 11) | ((field64 & 0xF80000ULL) << 13)) |
(((field64 & 0xF800ULL) << 16) | ((field64 & 0xFCULL) << 19) | ((field32 & 0xF8000000ULL) >> 11)) | (((field64 & 0xF800ULL) << 16) | ((field64 & 0xFCULL) << 19) | ((field32 & 0xF8000000ULL) >> 11)) |
(((field32 & 0xF80000ULL) >> 8) | ((field32 & 0xFC00ULL) >> 5) | ((field32 & 0xF8ULL) >> 3))); (((field32 & 0xF80000ULL) >> 8) | ((field32 & 0xFC00ULL) >> 5) | ((field32 & 0xF8ULL) >> 3)));
} }
// Free resources // Free resources
free (ctx->img_data); free (ctx->img_data);
free (ctx->row_pointers); free (ctx->row_pointers);
@ -337,7 +337,7 @@ int PNGU_DecodeTo4x4RGB5A3 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *b
PNGU_u64 fieldA = *((PNGU_u64 *)(ctx->row_pointers[y*4]+x*16)); PNGU_u64 fieldA = *((PNGU_u64 *)(ctx->row_pointers[y*4]+x*16));
PNGU_u64 fieldB = *((PNGU_u64 *)(ctx->row_pointers[y*4]+x*16+8)); PNGU_u64 fieldB = *((PNGU_u64 *)(ctx->row_pointers[y*4]+x*16+8));
// If first pixel is opaque set MSB to 1 and encode colors in RGB555, else set MSB to 0 and encode colors in ARGB3444 // If first pixel is opaque set MSB to 1 and encode colors in RGB555, else set MSB to 0 and encode colors in ARGB3444
if ((fieldA & 0xE000000000ULL) == 0xE000000000ULL) if ((fieldA & 0xE000000000ULL) == 0xE000000000ULL)
tmp = 0x8000000000000000ULL | ((fieldA & 0xF800000000000000ULL) >> 1) | ((fieldA & 0xF8000000000000ULL) << 2) | ((fieldA & 0xF80000000000ULL) << 5); tmp = 0x8000000000000000ULL | ((fieldA & 0xF800000000000000ULL) >> 1) | ((fieldA & 0xF8000000000000ULL) << 2) | ((fieldA & 0xF80000000000ULL) << 5);
else else
tmp = ((fieldA & 0xE000000000ULL) << 23) | ((fieldA & 0xF000000000000000ULL) >> 4) | (fieldA & 0xF0000000000000ULL) | ((fieldA & 0xF00000000000ULL) << 4); tmp = ((fieldA & 0xE000000000ULL) << 23) | ((fieldA & 0xF000000000000000ULL) >> 4) | (fieldA & 0xF0000000000000ULL) | ((fieldA & 0xF00000000000ULL) << 4);
@ -471,34 +471,34 @@ int PNGU_DecodeTo4x4RGB5A3 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *b
PNGU_u64 field64 = *((PNGU_u64 *)(ctx->row_pointers[y*4]+x*12)); PNGU_u64 field64 = *((PNGU_u64 *)(ctx->row_pointers[y*4]+x*12));
PNGU_u64 field32 = (PNGU_u64) *((PNGU_u32 *)(ctx->row_pointers[y*4]+x*12+8)); PNGU_u64 field32 = (PNGU_u64) *((PNGU_u32 *)(ctx->row_pointers[y*4]+x*12+8));
((PNGU_u64 *) buffer)[blockbase] = ((PNGU_u64 *) buffer)[blockbase] =
alphaMask | ((field64 & 0xF800000000000000ULL) >> 1) | ((field64 & 0xF8000000000000ULL) << 2) | alphaMask | ((field64 & 0xF800000000000000ULL) >> 1) | ((field64 & 0xF8000000000000ULL) << 2) |
((field64 & 0xF80000000000ULL) << 5) | ((field64 & 0xF800000000ULL) << 7) | ((field64 & 0xF8000000ULL) << 10) | ((field64 & 0xF80000000000ULL) << 5) | ((field64 & 0xF800000000ULL) << 7) | ((field64 & 0xF8000000ULL) << 10) |
((field64 & 0xF80000ULL) << 13) | ((field64 & 0xF800ULL) << 15) | ((field64 & 0xF8ULL) << 18) | ((field64 & 0xF80000ULL) << 13) | ((field64 & 0xF800ULL) << 15) | ((field64 & 0xF8ULL) << 18) |
((field32 & 0xF8000000ULL) >> 11) | ((field32 & 0xF80000ULL) >> 9) | ((field32 & 0xF800ULL) >> 6) | ((field32 & 0xF8ULL) >> 3); ((field32 & 0xF8000000ULL) >> 11) | ((field32 & 0xF80000ULL) >> 9) | ((field32 & 0xF800ULL) >> 6) | ((field32 & 0xF8ULL) >> 3);
field64 = *((PNGU_u64 *)(ctx->row_pointers[y*4+1]+x*12)); field64 = *((PNGU_u64 *)(ctx->row_pointers[y*4+1]+x*12));
field32 = (PNGU_u64) *((PNGU_u32 *)(ctx->row_pointers[y*4+1]+x*12+8)); field32 = (PNGU_u64) *((PNGU_u32 *)(ctx->row_pointers[y*4+1]+x*12+8));
((PNGU_u64 *) buffer)[blockbase+1] = ((PNGU_u64 *) buffer)[blockbase+1] =
alphaMask | ((field64 & 0xF800000000000000ULL) >> 1) | ((field64 & 0xF8000000000000ULL) << 2) | alphaMask | ((field64 & 0xF800000000000000ULL) >> 1) | ((field64 & 0xF8000000000000ULL) << 2) |
((field64 & 0xF80000000000ULL) << 5) | ((field64 & 0xF800000000ULL) << 7) | ((field64 & 0xF8000000ULL) << 10) | ((field64 & 0xF80000000000ULL) << 5) | ((field64 & 0xF800000000ULL) << 7) | ((field64 & 0xF8000000ULL) << 10) |
((field64 & 0xF80000ULL) << 13) | ((field64 & 0xF800ULL) << 15) | ((field64 & 0xF8ULL) << 18) | ((field64 & 0xF80000ULL) << 13) | ((field64 & 0xF800ULL) << 15) | ((field64 & 0xF8ULL) << 18) |
((field32 & 0xF8000000ULL) >> 11) | ((field32 & 0xF80000ULL) >> 9) | ((field32 & 0xF800ULL) >> 6) | ((field32 & 0xF8ULL) >> 3); ((field32 & 0xF8000000ULL) >> 11) | ((field32 & 0xF80000ULL) >> 9) | ((field32 & 0xF800ULL) >> 6) | ((field32 & 0xF8ULL) >> 3);
field64 = *((PNGU_u64 *)(ctx->row_pointers[y*4+2]+x*12)); field64 = *((PNGU_u64 *)(ctx->row_pointers[y*4+2]+x*12));
field32 = (PNGU_u64) *((PNGU_u32 *)(ctx->row_pointers[y*4+2]+x*12+8)); field32 = (PNGU_u64) *((PNGU_u32 *)(ctx->row_pointers[y*4+2]+x*12+8));
((PNGU_u64 *) buffer)[blockbase+2] = ((PNGU_u64 *) buffer)[blockbase+2] =
alphaMask | ((field64 & 0xF800000000000000ULL) >> 1) | ((field64 & 0xF8000000000000ULL) << 2) | alphaMask | ((field64 & 0xF800000000000000ULL) >> 1) | ((field64 & 0xF8000000000000ULL) << 2) |
((field64 & 0xF80000000000ULL) << 5) | ((field64 & 0xF800000000ULL) << 7) | ((field64 & 0xF8000000ULL) << 10) | ((field64 & 0xF80000000000ULL) << 5) | ((field64 & 0xF800000000ULL) << 7) | ((field64 & 0xF8000000ULL) << 10) |
((field64 & 0xF80000ULL) << 13) | ((field64 & 0xF800ULL) << 15) | ((field64 & 0xF8ULL) << 18) | ((field64 & 0xF80000ULL) << 13) | ((field64 & 0xF800ULL) << 15) | ((field64 & 0xF8ULL) << 18) |
((field32 & 0xF8000000ULL) >> 11) | ((field32 & 0xF80000ULL) >> 9) | ((field32 & 0xF800ULL) >> 6) | ((field32 & 0xF8ULL) >> 3); ((field32 & 0xF8000000ULL) >> 11) | ((field32 & 0xF80000ULL) >> 9) | ((field32 & 0xF800ULL) >> 6) | ((field32 & 0xF8ULL) >> 3);
field64 = *((PNGU_u64 *)(ctx->row_pointers[y*4+3]+x*12)); field64 = *((PNGU_u64 *)(ctx->row_pointers[y*4+3]+x*12));
field32 = (PNGU_u64) *((PNGU_u32 *)(ctx->row_pointers[y*4+3]+x*12+8)); field32 = (PNGU_u64) *((PNGU_u32 *)(ctx->row_pointers[y*4+3]+x*12+8));
((PNGU_u64 *) buffer)[blockbase+3] = ((PNGU_u64 *) buffer)[blockbase+3] =
alphaMask | ((field64 & 0xF800000000000000ULL) >> 1) | ((field64 & 0xF8000000000000ULL) << 2) | alphaMask | ((field64 & 0xF800000000000000ULL) >> 1) | ((field64 & 0xF8000000000000ULL) << 2) |
((field64 & 0xF80000000000ULL) << 5) | ((field64 & 0xF800000000ULL) << 7) | ((field64 & 0xF8000000ULL) << 10) | ((field64 & 0xF80000000000ULL) << 5) | ((field64 & 0xF800000000ULL) << 7) | ((field64 & 0xF8000000ULL) << 10) |
((field64 & 0xF80000ULL) << 13) | ((field64 & 0xF800ULL) << 15) | ((field64 & 0xF8ULL) << 18) | ((field64 & 0xF80000ULL) << 13) | ((field64 & 0xF800ULL) << 15) | ((field64 & 0xF8ULL) << 18) |
((field32 & 0xF8000000ULL) >> 11) | ((field32 & 0xF80000ULL) >> 9) | ((field32 & 0xF800ULL) >> 6) | ((field32 & 0xF8ULL) >> 3); ((field32 & 0xF8000000ULL) >> 11) | ((field32 & 0xF80000ULL) >> 9) | ((field32 & 0xF800ULL) >> 6) | ((field32 & 0xF8ULL) >> 3);
} }
} }
@ -516,39 +516,39 @@ int PNGU_DecodeTo4x4RGB5A3 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *b
PNGU_u64 field64 = *((PNGU_u64 *)(ctx->row_pointers[y*4]+x*12)); PNGU_u64 field64 = *((PNGU_u64 *)(ctx->row_pointers[y*4]+x*12));
PNGU_u64 field32 = (PNGU_u64) *((PNGU_u32 *)(ctx->row_pointers[y*4]+x*12+8)); PNGU_u64 field32 = (PNGU_u64) *((PNGU_u32 *)(ctx->row_pointers[y*4]+x*12+8));
((PNGU_u64 *) buffer)[blockbase] = ((PNGU_u64 *) buffer)[blockbase] =
alphaMask | ((field64 & 0xF000000000000000ULL) >> 4) | (field64 & 0xF0000000000000ULL) | ((field64 & 0xF00000000000ULL) << 4) | alphaMask | ((field64 & 0xF000000000000000ULL) >> 4) | (field64 & 0xF0000000000000ULL) | ((field64 & 0xF00000000000ULL) << 4) |
((field64 & 0xF000000000ULL) << 4) | ((field64 & 0xF0000000ULL) << 8) | ((field64 & 0xF00000ULL) << 12) | ((field64 & 0xF000000000ULL) << 4) | ((field64 & 0xF0000000ULL) << 8) | ((field64 & 0xF00000ULL) << 12) |
((field64 & 0xF000ULL) << 12) | ((field64 & 0xF0ULL) << 16) | ((field32 & 0xF0000000ULL) >> 12) | ((field64 & 0xF000ULL) << 12) | ((field64 & 0xF0ULL) << 16) | ((field32 & 0xF0000000ULL) >> 12) |
((field32 & 0xF00000ULL) >> 12) | ((field32 & 0xF000ULL) >> 8) | ((field32 & 0xF0ULL) >> 4); ((field32 & 0xF00000ULL) >> 12) | ((field32 & 0xF000ULL) >> 8) | ((field32 & 0xF0ULL) >> 4);
field64 = *((PNGU_u64 *)(ctx->row_pointers[y*4+1]+x*12)); field64 = *((PNGU_u64 *)(ctx->row_pointers[y*4+1]+x*12));
field32 = (PNGU_u64) *((PNGU_u32 *)(ctx->row_pointers[y*4+1]+x*12+8)); field32 = (PNGU_u64) *((PNGU_u32 *)(ctx->row_pointers[y*4+1]+x*12+8));
((PNGU_u64 *) buffer)[blockbase+1] = ((PNGU_u64 *) buffer)[blockbase+1] =
alphaMask | ((field64 & 0xF000000000000000ULL) >> 4) | (field64 & 0xF0000000000000ULL) | ((field64 & 0xF00000000000ULL) << 4) | alphaMask | ((field64 & 0xF000000000000000ULL) >> 4) | (field64 & 0xF0000000000000ULL) | ((field64 & 0xF00000000000ULL) << 4) |
((field64 & 0xF000000000ULL) << 4) | ((field64 & 0xF0000000ULL) << 8) | ((field64 & 0xF00000ULL) << 12) | ((field64 & 0xF000000000ULL) << 4) | ((field64 & 0xF0000000ULL) << 8) | ((field64 & 0xF00000ULL) << 12) |
((field64 & 0xF000ULL) << 12) | ((field64 & 0xF0ULL) << 16) | ((field32 & 0xF0000000ULL) >> 12) | ((field64 & 0xF000ULL) << 12) | ((field64 & 0xF0ULL) << 16) | ((field32 & 0xF0000000ULL) >> 12) |
((field32 & 0xF00000ULL) >> 12) | ((field32 & 0xF000ULL) >> 8) | ((field32 & 0xF0ULL) >> 4); ((field32 & 0xF00000ULL) >> 12) | ((field32 & 0xF000ULL) >> 8) | ((field32 & 0xF0ULL) >> 4);
field64 = *((PNGU_u64 *)(ctx->row_pointers[y*4+2]+x*12)); field64 = *((PNGU_u64 *)(ctx->row_pointers[y*4+2]+x*12));
field32 = (PNGU_u64) *((PNGU_u32 *)(ctx->row_pointers[y*4+2]+x*12+8)); field32 = (PNGU_u64) *((PNGU_u32 *)(ctx->row_pointers[y*4+2]+x*12+8));
((PNGU_u64 *) buffer)[blockbase+2] = ((PNGU_u64 *) buffer)[blockbase+2] =
alphaMask | ((field64 & 0xF000000000000000ULL) >> 4) | (field64 & 0xF0000000000000ULL) | ((field64 & 0xF00000000000ULL) << 4) | alphaMask | ((field64 & 0xF000000000000000ULL) >> 4) | (field64 & 0xF0000000000000ULL) | ((field64 & 0xF00000000000ULL) << 4) |
((field64 & 0xF000000000ULL) << 4) | ((field64 & 0xF0000000ULL) << 8) | ((field64 & 0xF00000ULL) << 12) | ((field64 & 0xF000000000ULL) << 4) | ((field64 & 0xF0000000ULL) << 8) | ((field64 & 0xF00000ULL) << 12) |
((field64 & 0xF000ULL) << 12) | ((field64 & 0xF0ULL) << 16) | ((field32 & 0xF0000000ULL) >> 12) | ((field64 & 0xF000ULL) << 12) | ((field64 & 0xF0ULL) << 16) | ((field32 & 0xF0000000ULL) >> 12) |
((field32 & 0xF00000ULL) >> 12) | ((field32 & 0xF000ULL) >> 8) | ((field32 & 0xF0ULL) >> 4); ((field32 & 0xF00000ULL) >> 12) | ((field32 & 0xF000ULL) >> 8) | ((field32 & 0xF0ULL) >> 4);
field64 = *((PNGU_u64 *)(ctx->row_pointers[y*4+3]+x*12)); field64 = *((PNGU_u64 *)(ctx->row_pointers[y*4+3]+x*12));
field32 = (PNGU_u64) *((PNGU_u32 *)(ctx->row_pointers[y*4+3]+x*12+8)); field32 = (PNGU_u64) *((PNGU_u32 *)(ctx->row_pointers[y*4+3]+x*12+8));
((PNGU_u64 *) buffer)[blockbase+3] = ((PNGU_u64 *) buffer)[blockbase+3] =
alphaMask | ((field64 & 0xF000000000000000ULL) >> 4) | (field64 & 0xF0000000000000ULL) | ((field64 & 0xF00000000000ULL) << 4) | alphaMask | ((field64 & 0xF000000000000000ULL) >> 4) | (field64 & 0xF0000000000000ULL) | ((field64 & 0xF00000000000ULL) << 4) |
((field64 & 0xF000000000ULL) << 4) | ((field64 & 0xF0000000ULL) << 8) | ((field64 & 0xF00000ULL) << 12) | ((field64 & 0xF000000000ULL) << 4) | ((field64 & 0xF0000000ULL) << 8) | ((field64 & 0xF00000ULL) << 12) |
((field64 & 0xF000ULL) << 12) | ((field64 & 0xF0ULL) << 16) | ((field32 & 0xF0000000ULL) >> 12) | ((field64 & 0xF000ULL) << 12) | ((field64 & 0xF0ULL) << 16) | ((field32 & 0xF0000000ULL) >> 12) |
((field32 & 0xF00000ULL) >> 12) | ((field32 & 0xF000ULL) >> 8) | ((field32 & 0xF0ULL) >> 4); ((field32 & 0xF00000ULL) >> 12) | ((field32 & 0xF000ULL) >> 8) | ((field32 & 0xF0ULL) >> 4);
} }
} }
} }
// Free resources // Free resources
free (ctx->img_data); free (ctx->img_data);
free (ctx->row_pointers); free (ctx->row_pointers);
@ -633,7 +633,7 @@ PNGU_u8 * PNGU_DecodeTo4x4RGBA8 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, in
y2 = ((y*yRatio)>>16); y2 = ((y*yRatio)>>16);
} }
if (ctx->prop.imgColorType == PNGU_COLOR_TYPE_GRAY_ALPHA || if (ctx->prop.imgColorType == PNGU_COLOR_TYPE_GRAY_ALPHA ||
ctx->prop.imgColorType == PNGU_COLOR_TYPE_RGB_ALPHA) ctx->prop.imgColorType == PNGU_COLOR_TYPE_RGB_ALPHA)
{ {
if(xRatio > 0) if(xRatio > 0)
@ -682,7 +682,7 @@ int PNGU_EncodeFromRGB (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buffe
ctx->propRead = 0; ctx->propRead = 0;
// Check if the user has selected a file to write the image // Check if the user has selected a file to write the image
if (ctx->source == PNGU_SOURCE_BUFFER); if (ctx->source == PNGU_SOURCE_BUFFER);
else if (ctx->source == PNGU_SOURCE_DEVICE) else if (ctx->source == PNGU_SOURCE_DEVICE)
{ {
@ -725,17 +725,17 @@ int PNGU_EncodeFromRGB (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buffe
} }
// Setup output file properties // Setup output file properties
png_set_IHDR (ctx->png_ptr, ctx->info_ptr, width, height, 8, PNG_COLOR_TYPE_RGB, png_set_IHDR (ctx->png_ptr, ctx->info_ptr, width, height, 8, PNG_COLOR_TYPE_RGB,
PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
// Allocate memory to store the image in RGB format // Allocate memory to store the image in RGB format
rowbytes = width * 3; rowbytes = width * 3;
if (rowbytes % 4) if (rowbytes % 4)
rowbytes = ((rowbytes >>2) + 1) <<2; // Add extra padding so each row starts in a 4 byte boundary rowbytes = ((rowbytes >>2) + 1) <<2; // Add extra padding so each row starts in a 4 byte boundary
ctx->img_data = malloc(rowbytes * height); ctx->img_data = malloc(rowbytes * height);
memset(ctx->img_data, 0, rowbytes * height); memset(ctx->img_data, 0, rowbytes * height);
if (!ctx->img_data) if (!ctx->img_data)
{ {
png_destroy_write_struct (&(ctx->png_ptr), (png_infopp)NULL); png_destroy_write_struct (&(ctx->png_ptr), (png_infopp)NULL);
@ -746,7 +746,7 @@ int PNGU_EncodeFromRGB (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buffe
ctx->row_pointers = malloc (sizeof (png_bytep) * height); ctx->row_pointers = malloc (sizeof (png_bytep) * height);
memset(ctx->row_pointers, 0, sizeof (png_bytep) * height); memset(ctx->row_pointers, 0, sizeof (png_bytep) * height);
if (!ctx->row_pointers) if (!ctx->row_pointers)
{ {
png_destroy_write_struct (&(ctx->png_ptr), (png_infopp)NULL); png_destroy_write_struct (&(ctx->png_ptr), (png_infopp)NULL);
@ -790,7 +790,7 @@ int PNGU_EncodeFromGXTexture (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void
unsigned char * tmpbuffer = (unsigned char *)malloc(width*height*3); unsigned char * tmpbuffer = (unsigned char *)malloc(width*height*3);
memset(tmpbuffer, 0, width*height*3); memset(tmpbuffer, 0, width*height*3);
png_uint_32 offset; png_uint_32 offset;
for(y=0; y < height; y++) for(y=0; y < height; y++)
{ {
tmpy1 = y * 640*3; tmpy1 = y * 640*3;
@ -807,7 +807,7 @@ int PNGU_EncodeFromGXTexture (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void
tmpbuffer[tmpxy+2] = ptr[offset+33]; // B tmpbuffer[tmpxy+2] = ptr[offset+33]; // B
} }
} }
res = PNGU_EncodeFromRGB (ctx, width, height, tmpbuffer, stride); res = PNGU_EncodeFromRGB (ctx, width, height, tmpbuffer, stride);
free(tmpbuffer); free(tmpbuffer);
return res; return res;
@ -852,7 +852,7 @@ int PNGU_EncodeFromYCbYCr (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *bu
ctx->propRead = 0; ctx->propRead = 0;
// Check if the user has selected a file to write the image // Check if the user has selected a file to write the image
if (ctx->source == PNGU_SOURCE_BUFFER); if (ctx->source == PNGU_SOURCE_BUFFER);
else if (ctx->source == PNGU_SOURCE_DEVICE) else if (ctx->source == PNGU_SOURCE_DEVICE)
{ {
@ -895,7 +895,7 @@ int PNGU_EncodeFromYCbYCr (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *bu
} }
// Setup output file properties // Setup output file properties
png_set_IHDR (ctx->png_ptr, ctx->info_ptr, width, height, 8, PNG_COLOR_TYPE_RGB, png_set_IHDR (ctx->png_ptr, ctx->info_ptr, width, height, 8, PNG_COLOR_TYPE_RGB,
PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
// Allocate memory to store the image in RGB format // Allocate memory to store the image in RGB format
@ -928,7 +928,7 @@ int PNGU_EncodeFromYCbYCr (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *bu
ctx->row_pointers[y] = ctx->img_data + (y * rowbytes); ctx->row_pointers[y] = ctx->img_data + (y * rowbytes);
for (x = 0; x < (width / 2); x++) for (x = 0; x < (width / 2); x++)
PNGU_YCbYCr_TO_RGB8 ( ((PNGU_u32 *)buffer)[y*buffWidth+x], PNGU_YCbYCr_TO_RGB8 ( ((PNGU_u32 *)buffer)[y*buffWidth+x],
((PNGU_u8 *) ctx->row_pointers[y]+x*6), ((PNGU_u8 *) ctx->row_pointers[y]+x*6+1), ((PNGU_u8 *) ctx->row_pointers[y]+x*6), ((PNGU_u8 *) ctx->row_pointers[y]+x*6+1),
((PNGU_u8 *) ctx->row_pointers[y]+x*6+2), ((PNGU_u8 *) ctx->row_pointers[y]+x*6+3), ((PNGU_u8 *) ctx->row_pointers[y]+x*6+2), ((PNGU_u8 *) ctx->row_pointers[y]+x*6+3),
((PNGU_u8 *) ctx->row_pointers[y]+x*6+4), ((PNGU_u8 *) ctx->row_pointers[y]+x*6+5) ); ((PNGU_u8 *) ctx->row_pointers[y]+x*6+4), ((PNGU_u8 *) ctx->row_pointers[y]+x*6+5) );
@ -963,14 +963,14 @@ PNGU_u32 PNGU_RGB8_TO_YCbYCr (PNGU_u8 r1, PNGU_u8 g1, PNGU_u8 b1, PNGU_u8 r2, PN
y1 = (299 * r1 + 587 * g1 + 114 * b1) / 1000; y1 = (299 * r1 + 587 * g1 + 114 * b1) / 1000;
cb1 = (-16874 * r1 - 33126 * g1 + 50000 * b1 + 12800000) / 100000; cb1 = (-16874 * r1 - 33126 * g1 + 50000 * b1 + 12800000) / 100000;
cr1 = (50000 * r1 - 41869 * g1 - 8131 * b1 + 12800000) / 100000; cr1 = (50000 * r1 - 41869 * g1 - 8131 * b1 + 12800000) / 100000;
y2 = (299 * r2 + 587 * g2 + 114 * b2) / 1000; y2 = (299 * r2 + 587 * g2 + 114 * b2) / 1000;
cb2 = (-16874 * r2 - 33126 * g2 + 50000 * b2 + 12800000) / 100000; cb2 = (-16874 * r2 - 33126 * g2 + 50000 * b2 + 12800000) / 100000;
cr2 = (50000 * r2 - 41869 * g2 - 8131 * b2 + 12800000) / 100000; cr2 = (50000 * r2 - 41869 * g2 - 8131 * b2 + 12800000) / 100000;
cb = (cb1 + cb2) >> 1; cb = (cb1 + cb2) >> 1;
cr = (cr1 + cr2) >> 1; cr = (cr1 + cr2) >> 1;
return (PNGU_u32) ((y1 << 24) | (cb << 16) | (y2 << 8) | cr); return (PNGU_u32) ((y1 << 24) | (cb << 16) | (y2 << 8) | cr);
} }
@ -1070,7 +1070,7 @@ int pngu_info (IMGCTX ctx)
if (!ctx->propRead) if (!ctx->propRead)
{ {
png_get_IHDR(ctx->png_ptr, ctx->info_ptr, &width, &height, png_get_IHDR(ctx->png_ptr, ctx->info_ptr, &width, &height,
(int *) &(ctx->prop.imgBitDepth), (int *) &(ctx->prop.imgBitDepth),
(int *) &(ctx->prop.imgColorType), (int *) &(ctx->prop.imgColorType),
NULL, NULL, NULL); NULL, NULL, NULL);
@ -1148,7 +1148,7 @@ int pngu_info (IMGCTX ctx)
ctx->prop.trans = malloc (sizeof (PNGUCOLOR) * ctx->prop.numTrans); ctx->prop.trans = malloc (sizeof (PNGUCOLOR) * ctx->prop.numTrans);
if (ctx->prop.trans) if (ctx->prop.trans)
for (i = 0; i < ctx->prop.numTrans; i++) for (i = 0; i < ctx->prop.numTrans; i++)
ctx->prop.trans[i].r = ctx->prop.trans[i].g = ctx->prop.trans[i].b = ctx->prop.trans[i].r = ctx->prop.trans[i].g = ctx->prop.trans[i].b =
trans_values[i].gray / scale; trans_values[i].gray / scale;
else else
ctx->prop.numTrans = 0; ctx->prop.numTrans = 0;

View file

@ -62,7 +62,7 @@ typedef struct
// Image context, always initialize with SelectImageFrom* and free with ReleaseImageContext // Image context, always initialize with SelectImageFrom* and free with ReleaseImageContext
struct _IMGCTX; struct _IMGCTX;
typedef struct _IMGCTX *IMGCTX; typedef struct _IMGCTX *IMGCTX;
/**************************************************************************** /****************************************************************************
@ -110,7 +110,7 @@ int PNGU_GetImageProperties (IMGCTX ctx, PNGUPROP *fileproperties);
* Image conversion * * Image conversion *
****************************************************************************/ ****************************************************************************/
// Expands selected image into an YCbYCr buffer. You need to specify context, image dimensions, // Expands selected image into an YCbYCr buffer. You need to specify context, image dimensions,
// destination address and stride in pixels (stride = buffer width - image width). // destination address and stride in pixels (stride = buffer width - image width).
int PNGU_DecodeToYCbYCr (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buffer, PNGU_u32 stride); int PNGU_DecodeToYCbYCr (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buffer, PNGU_u32 stride);
@ -120,7 +120,7 @@ int PNGU_DecodeToYCbYCr (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buff
PNGU_DecodeToYCbYCr (ctx, imgWidth, imgHeight, ((void *) buffer) + (coordY) * (bufferWidth) * 2 + \ PNGU_DecodeToYCbYCr (ctx, imgWidth, imgHeight, ((void *) buffer) + (coordY) * (bufferWidth) * 2 + \
(coordX) * 2, (bufferWidth) - (imgWidth)) (coordX) * 2, (bufferWidth) - (imgWidth))
// Expands selected image into a linear RGB565 buffer. You need to specify context, image dimensions, // Expands selected image into a linear RGB565 buffer. You need to specify context, image dimensions,
// destination address and stride in pixels (stride = buffer width - image width). // destination address and stride in pixels (stride = buffer width - image width).
int PNGU_DecodeToRGB565 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buffer, PNGU_u32 stride); int PNGU_DecodeToRGB565 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buffer, PNGU_u32 stride);
@ -130,8 +130,8 @@ int PNGU_DecodeToRGB565 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buff
PNGU_DecodeToRGB565 (ctx, imgWidth, imgHeight, ((void *) buffer) + (coordY) * (bufferWidth) * 2 + \ PNGU_DecodeToRGB565 (ctx, imgWidth, imgHeight, ((void *) buffer) + (coordY) * (bufferWidth) * 2 + \
(coordX) * 2, (bufferWidth) - (imgWidth)) (coordX) * 2, (bufferWidth) - (imgWidth))
// Expands selected image into a linear RGBA8 buffer. You need to specify context, image dimensions, // Expands selected image into a linear RGBA8 buffer. You need to specify context, image dimensions,
// destination address, stride in pixels and default alpha value, which is used if the source image // destination address, stride in pixels and default alpha value, which is used if the source image
// doesn't have an alpha channel. // doesn't have an alpha channel.
int PNGU_DecodeToRGBA8 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buffer, PNGU_u32 stride, PNGU_u8 default_alpha); int PNGU_DecodeToRGBA8 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buffer, PNGU_u32 stride, PNGU_u8 default_alpha);
@ -153,7 +153,7 @@ int PNGU_DecodeTo4x4RGB5A3 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *b
// destination address. // destination address.
PNGU_u8 * PNGU_DecodeTo4x4RGBA8 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, int * dstWidth, int * dstHeight, PNGU_u8 *dstPtr); PNGU_u8 * PNGU_DecodeTo4x4RGBA8 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, int * dstWidth, int * dstHeight, PNGU_u8 *dstPtr);
// Encodes an YCbYCr image in PNG format and stores it in the selected device or memory buffer. You need to // Encodes an YCbYCr image in PNG format and stores it in the selected device or memory buffer. You need to
// specify context, image dimensions, destination address and stride in pixels (stride = buffer width - image width). // specify context, image dimensions, destination address and stride in pixels (stride = buffer width - image width).
int PNGU_EncodeFromYCbYCr (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buffer, PNGU_u32 stride); int PNGU_EncodeFromYCbYCr (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buffer, PNGU_u32 stride);
@ -172,4 +172,3 @@ int PNGU_EncodeFromEFB (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, PNGU_u32 st
#endif #endif
#endif #endif

View file

@ -102,20 +102,27 @@ libfreetype and libjpeg with there dependencies in a single command:
Each library could also be installed individually: Each library could also be installed individually:
To install libpngu To install libpngu:
```bash ```bash
c: c:
cd \grr\GRRLIB\lib\pngu cd \grr\GRRLIB\lib\pngu
make clean all install make clean all install
``` ```
To install libgrrlib: To install libgrrlib for Wii:
```bash ```bash
c: c:
cd \grr\GRRLIB\GRRLIB cd \grr\GRRLIB\GRRLIB
make clean all install make clean all install
``` ```
To install libgrrlib for GameCube:
```bash
c:
cd \grr\GRRLIB\GRRLIB
make PLATFORM=cube clean all install
```
## Using GRRLIB ## Using GRRLIB
After everything is installed, simply put After everything is installed, simply put

View file

@ -4,6 +4,7 @@
#include <grrlib.h> #include <grrlib.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h>
#include <wiiuse/wpad.h> #include <wiiuse/wpad.h>
#include <ogc/lwp_watchdog.h> // Needed for gettime and ticks_to_millisecs #include <ogc/lwp_watchdog.h> // Needed for gettime and ticks_to_millisecs