u8 * GetImageData(void) { u8 * data = NULL; int ret; if (CONF_GetAspectRatio()) { ctx = PNGU_SelectImageFromBuffer(background169_png); if (!ctx) return NULL; } else { ctx = PNGU_SelectImageFromBuffer(background_png); if (!ctx) return NULL; } ret = PNGU_GetImageProperties(ctx, &imgProp); if (ret != PNGU_OK) return NULL; int len = imgProp.imgWidth * imgProp.imgHeight * 4; if(len%32) len += (32-len%32); data = (u8 *)memalign (32, len); ret = PNGU_DecodeTo4x4RGBA8 (ctx, imgProp.imgWidth, imgProp.imgHeight, data, 255); DCFlushRange(data, len); PNGU_ReleaseImageContext(ctx); return data; }
s32 __Gui_DrawPng(void *img, u32 x, u32 y) { IMGCTX ctx = NULL; PNGUPROP imgProp; s32 ret; /* Select PNG data */ ctx = PNGU_SelectImageFromBuffer(img); if (!ctx) { ret = -1; goto out; } /* Get image properties */ ret = PNGU_GetImageProperties(ctx, &imgProp); if (ret != PNGU_OK) { ret = -1; goto out; } /* Draw image */ Video_DrawPng(ctx, imgProp, x, y); /* Success */ ret = 0; out: /* Free memory */ if (ctx) PNGU_ReleaseImageContext(ctx); return ret; }
s32 __Gui_GetPngDimensions(void *img, u32 *w, u32 *h) { IMGCTX ctx = NULL; PNGUPROP imgProp; s32 ret; /* Select PNG data */ ctx = PNGU_SelectImageFromBuffer(img); if (!ctx) { ret = -1; goto out; } /* Get image properties */ ret = PNGU_GetImageProperties(ctx, &imgProp); if (ret != PNGU_OK) { ret = -1; goto out; } /* Set image width and height */ *w = imgProp.imgWidth; *h = imgProp.imgHeight; /* Success */ ret = 0; out: /* Free memory */ if (ctx) PNGU_ReleaseImageContext(ctx); return ret; }
u8 * GetImageData(bool dark) { PNGUPROP imgProp; IMGCTX ctx; u8 * data = NULL; int ret; ctx = PNGU_SelectImageFromBuffer(dark ? background_dark_png : background_png); if (!ctx) return NULL; ret = PNGU_GetImageProperties(ctx, &imgProp); if (ret != PNGU_OK) return NULL; imagewidth = imgProp.imgWidth; imageheight = imgProp.imgHeight; int len = ((((imgProp.imgWidth+3)>>2)*((imgProp.imgHeight+3)>>2)*32*2) + 31) & ~31; data = (u8 *)memalign (32, len); ret = PNGU_DecodeTo4x4RGBA8 (ctx, imgProp.imgWidth, imgProp.imgHeight, data, 255); DCFlushRange(data, len); PNGU_ReleaseImageContext(ctx); return data; }
IMGCTX getPngImageRessources(const void *imgData,PNGUPROP *imgProperties) { IMGCTX varout; if ((varout=PNGU_SelectImageFromBuffer(imgData))) { if (PNGU_GetImageProperties(varout,imgProperties)!=PNGU_OK) { PNGU_ReleaseImageContext(varout); varout=NULL; } } return varout; }
void initConsole(const void *imgBgData,enum CONSOLE_COLORS CONSOLE_COLOR,const char *strSplashScreenMessage,double dbLeft,double dbTop,double dbWidth,double dbHeight) { PNGUPROP imgProperties; IMGCTX imgContext; void *pFramebuffer=NULL; GXRModeObj *pRmode=NULL; double dbConsoleFrameX[2]={dbLeft,dbLeft},dbConsoleFrameY[2]={dbTop,dbTop},dbBgImgXScaleFactor=1,dbBgImgYScaleFactor=1,dbReferenceWidth,dbReferenceHeight; int intConsoleColumnsCount,intConsoleRowsCount; struct stConsoleCursorLocation stTexteLocation; VIDEO_Init(); pRmode=VIDEO_GetPreferredMode(NULL); pFramebuffer=MEM_K0_TO_K1(SYS_AllocateFramebuffer(pRmode)); VIDEO_ClearFrameBuffer(pRmode,pFramebuffer,CONSOLE_COLOR); VIDEO_Configure(pRmode); VIDEO_SetNextFramebuffer(pFramebuffer); VIDEO_SetBlack(FALSE); VIDEO_Flush(); VIDEO_WaitVSync(); if(pRmode->viTVMode&VI_NON_INTERLACE) { VIDEO_WaitVSync(); } dbWidth=fabs(dbWidth); dbHeight=fabs(dbHeight); if ((imgContext=getPngImageRessources(imgBgData,&imgProperties))) { dbReferenceWidth=imgProperties.imgWidth; dbReferenceHeight=imgProperties.imgHeight; dbBgImgXScaleFactor=pRmode->fbWidth/imgProperties.imgWidth; dbBgImgYScaleFactor=pRmode->xfbHeight/imgProperties.imgHeight; } else { dbReferenceWidth=pRmode->fbWidth; dbReferenceHeight=pRmode->xfbHeight; } if (dbWidth<=1) { dbWidth=dbReferenceWidth*dbWidth; dbConsoleFrameX[0]=0; dbConsoleFrameX[1]=dbWidth; } if (dbHeight<=1) { dbHeight=dbReferenceHeight*dbHeight; dbConsoleFrameY[0]=0; dbConsoleFrameY[1]=dbHeight; } CON_InitEx(pRmode,(s32) getRoundNumber(getPolyContainerPosition(&dbConsoleFrameX[0],2,0,dbReferenceWidth,dbLeft)*dbBgImgXScaleFactor),(s32) getRoundNumber(getPolyContainerPosition(&dbConsoleFrameY[0],2,0,dbReferenceHeight,dbTop)*dbBgImgYScaleFactor),(s32) getRoundNumber(dbWidth*dbBgImgXScaleFactor),(s32) getRoundNumber(dbHeight*dbBgImgYScaleFactor)); if (imgContext) { PNGU_DECODE_TO_COORDS_YCbYCr(imgContext,0,0,imgProperties.imgWidth,imgProperties.imgHeight,pRmode->fbWidth,pRmode->xfbHeight,pFramebuffer); PNGU_ReleaseImageContext(imgContext); } resetDefaultFontSyle(); if (*strSplashScreenMessage) { CON_GetMetrics(&intConsoleColumnsCount,&intConsoleRowsCount); printAlignedText(ALIGN_CENTER,ALIGN_MIDDLE,0,0,intConsoleRowsCount-1,intConsoleColumnsCount-1,true,true,&stTexteLocation,"%s",strSplashScreenMessage); } }
/** * Make a PNG screenshot. * It should be called after drawing stuff on the screen, but before GRRLIB_Render. * libfat is required to use the function. * @param filename Name of the file to write. * @return bool true=everything worked, false=problems occurred. */ bool GRRLIB_ScrShot(const char* filename) { IMGCTX pngContext; int ret = -1; if ( (pngContext = PNGU_SelectImageFromDevice(filename)) ) { ret = PNGU_EncodeFromEFB( pngContext, rmode->fbWidth, rmode->efbHeight, 0 ); PNGU_ReleaseImageContext(pngContext); } return !ret; }
bool drawPng(const void *imgData,u32 intLeft,u32 intTop,u32 intWidth,u32 intHeight,void *pFramebuffer) { IMGCTX imgContext; PNGUPROP imgProperties; bool varout=true; if ((imgContext=getPngImageRessources(imgData,&imgProperties))) { PNGU_DECODE_TO_COORDS_YCbYCr(imgContext,intLeft,intTop,imgProperties.imgWidth,imgProperties.imgHeight,intWidth,intHeight,pFramebuffer); PNGU_ReleaseImageContext(imgContext); } else { varout=false; } return varout; }
void screenShot(const char* filename, PANEL * v) { IMGCTX pngContext; pngContext = PNGU_SelectImageFromDevice(filename); if(!v) { PNGU_EncodeFromYCbYCr(pngContext, 640, 480, (frameBuffer[fb]), 0); } else { Vector pos = v->getPos(); Vector size = v->getSize(); PNGU_ENCODE_TO_COORDS_YCbYCr(pngContext,(u32)pos.x,(u32)pos.y,(u32)size.x,(u32)size.y,640,480,(frameBuffer[fb])); } PNGU_ReleaseImageContext(pngContext); }
u8 * GetImageData(void) { u8 * data = NULL; int ret; if (CONF_GetAspectRatio()) { switch (CONF_GetLanguage()) { case CONF_LANG_FRENCH: ctx = PNGU_SelectImageFromBuffer(bk169fr_png); break; case CONF_LANG_JAPANESE: ctx = PNGU_SelectImageFromBuffer(bk169jp_png); break; case CONF_LANG_SPANISH: ctx = PNGU_SelectImageFromBuffer(bk169sp_png); break; case CONF_LANG_ITALIAN: ctx = PNGU_SelectImageFromBuffer(bk169it_png); break; case CONF_LANG_DUTCH: ctx = PNGU_SelectImageFromBuffer(bk169du_png); break; case CONF_LANG_GERMAN: ctx = PNGU_SelectImageFromBuffer(bk169ge_png); break; default: ctx = PNGU_SelectImageFromBuffer(bk169en_png); break; } } else { switch (CONF_GetLanguage()) { case CONF_LANG_FRENCH: ctx = PNGU_SelectImageFromBuffer(bkfr_png); break; case CONF_LANG_JAPANESE: ctx = PNGU_SelectImageFromBuffer(bkjp_png); break; case CONF_LANG_SPANISH: ctx = PNGU_SelectImageFromBuffer(bksp_png); break; case CONF_LANG_ITALIAN: ctx = PNGU_SelectImageFromBuffer(bkit_png); break; case CONF_LANG_DUTCH: ctx = PNGU_SelectImageFromBuffer(bkdu_png); break; case CONF_LANG_GERMAN: ctx = PNGU_SelectImageFromBuffer(bkge_png); break; default: ctx = PNGU_SelectImageFromBuffer(bken_png); break; } } if (!ctx) return NULL; ret = PNGU_GetImageProperties(ctx, &imgProp); if (ret != PNGU_OK) return NULL; int len = imgProp.imgWidth * imgProp.imgHeight * 4; if(len%32) len += (32-len%32); data = (u8 *)memalign (32, len); ret = PNGU_DecodeTo4x4RGBA8 (ctx, imgProp.imgWidth, imgProp.imgHeight, data, 255); DCFlushRange(data, len); PNGU_ReleaseImageContext(ctx); return data; }