[CHG] pngu.c does not required to include gx.h anymore

[BUG] Fixed some examples using GRRLIB_ScrShot
This commit is contained in:
Crayon2000 2010-01-19 05:09:58 +00:00
parent 1e066f3877
commit 8789bd4ba6
4 changed files with 17 additions and 11 deletions

View file

@ -85,6 +85,7 @@ GRRLIB_texImg* GRRLIB_LoadTextureFromFile(const char *filename) {
/**
* 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.

View file

@ -9,7 +9,6 @@ More info : http://frontier-dev.net
********************************************************************************************/
#include <stdio.h>
#include <malloc.h>
#include <ogc/gx.h>
#include "pngu.h"
#include "png.h"
@ -18,6 +17,10 @@ More info : http://frontier-dev.net
#define PNGU_SOURCE_BUFFER 1
#define PNGU_SOURCE_DEVICE 2
#define _SHIFTL(v, s, w) \
((png_uint_32) (((png_uint_32)(v) & ((0x01 << (w)) - 1)) << (s)))
#define _SHIFTR(v, s, w) \
((png_uint_32)(((png_uint_32)(v) >> (s)) & ((0x01 << (w)) - 1)))
// Prototypes of helper functions
int pngu_info (IMGCTX ctx);
@ -821,20 +824,21 @@ int PNGU_EncodeFromGXTexture (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void
// Coded by Crayon for GRRLIB (http://code.google.com/p/grrlib)
int PNGU_EncodeFromEFB (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, PNGU_u32 stride)
{
png_uint_32 regval,val;
int x,y,res;
unsigned char * tmpbuffer = (unsigned char *)malloc(width*height*3);
memset(tmpbuffer, 0, width*height*3);
GXColor peekColor;
for(y=0; y < height; y++)
{
for(x=0; x < width; x++)
{
GX_PeekARGB(x, y, &peekColor);
tmpbuffer[y*640*3+x*3] = peekColor.r; // R
tmpbuffer[y*640*3+x*3+1] = peekColor.g; // G
tmpbuffer[y*640*3+x*3+2] = peekColor.b; // B
regval = 0xc8000000|(_SHIFTL(x,2,10));
regval = (regval&~0x3FF000)|(_SHIFTL(y,12,10));
val = *(png_uint_32*)regval;
tmpbuffer[y*640*3+x*3] = _SHIFTR(val,16,8); // R
tmpbuffer[y*640*3+x*3+1] = _SHIFTR(val,8,8); // G
tmpbuffer[y*640*3+x*3+2] = val&0xff; // B
}
}

View file

@ -166,8 +166,6 @@ int main() {
GRRLIB_PrintBMF(left, top+420, bmf_Font2, "%s", bmf_Font2->name);
}
GRRLIB_Printf(500, 27, tex_BMfont5, GRRLIB_WHITE, 1, "Current FPS: %d", FPS);
GRRLIB_Render();
FPS = CalculateFrameRate();
if(wpaddown & WPAD_BUTTON_HOME) {
break;
@ -217,6 +215,9 @@ int main() {
GRRLIB_ScrShot("sd:/grrlib.png");
WPAD_Rumble(WPAD_CHAN_0, 0); // Rumble off
}
GRRLIB_Render();
FPS = CalculateFrameRate();
}
GRRLIB_Exit(); // Be a good boy, clear the memory allocated by GRRLIB
// Free some textures
@ -235,7 +236,6 @@ int main() {
/**
* This function calculates the number of frames we render each second.
* It must be called right after GRRLIB_Render.
* @return The number of frames per second.
*/
static u8 CalculateFrameRate() {

View file

@ -68,7 +68,6 @@ int main(int argc, char **argv) {
GRRLIB_PrintfTTF(500+1, 25+1, myFont, FPS, 12, 0x000000FF);
GRRLIB_PrintfTTF(500, 25, myFont, FPS, 12, 0xFFFFFFFF);
}
GRRLIB_Render(); // Render the frame buffer to the TV
WPAD_ScanPads(); // Scan the Wii Remotes
@ -86,6 +85,8 @@ int main(int argc, char **argv) {
ScreenShot(); // Needs to be after GRRLIB_Render()
WPAD_Rumble(0, false); // Rumble off
}
GRRLIB_Render(); // Render the frame buffer to the TV
}
GRRLIB_FreeTexture(CopiedImg);