[CHG] GRRLIB_GetPixelFromFB now use a real way to get it ;)

[ADD] GRRLIB_SetPixelToFB
This commit is contained in:
N0NameN0 2010-04-29 18:20:15 +00:00
parent 46a2297aa6
commit 04cec42e7c
2 changed files with 25 additions and 37 deletions

View file

@ -104,9 +104,8 @@ INLINE u32 GRRLIB_GetPixelFromtexImg (const int x, const int y,
INLINE void GRRLIB_SetPixelTotexImg (const int x, const int y, INLINE void GRRLIB_SetPixelTotexImg (const int x, const int y,
GRRLIB_texImg *tex, const u32 color); GRRLIB_texImg *tex, const u32 color);
INLINE void GRRLIB_GetPixelFromFB (int x, int y, INLINE u32 GRRLIB_GetPixelFromFB (int x, int y);
u8 *R1, u8 *G1, u8 *B1, INLINE void GRRLIB_SetPixelToFB (int x, int y, u32 pokeColor);
u8 *R2, u8 *G2, u8 *B2);
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// GRRLIB_settings.h - Rendering functions // GRRLIB_settings.h - Rendering functions

View file

@ -67,44 +67,33 @@ void GRRLIB_SetPixelTotexImg (const int x, const int y,
/** /**
* Reads a pixel directly from the FrontBuffer. * Reads a pixel directly from the FrontBuffer.
* Since the FB is stored in YCbCr,
* @param x The x-coordinate within the FB. * @param x The x-coordinate within the FB.
* @param y The y-coordinate within the FB. * @param y The y-coordinate within the FB.
* @param R1 A pointer to a variable receiving the first Red value.
* @param G1 A pointer to a variable receiving the first Green value.
* @param B1 A pointer to a variable receiving the first Blue value.
* @param R2 A pointer to a variable receiving the second Red value.
* @param G2 A pointer to a variable receiving the second Green value.
* @param B2 A pointer to a variable receiving the second Blue value.
*/ */
INLINE INLINE
void GRRLIB_GetPixelFromFB (int x, int y, u32 GRRLIB_GetPixelFromFB (int x, int y) {
u8 *R1, u8 *G1, u8 *B1, GXColor peekColor;
u8 *R2, u8 *G2, u8 *B2) { u32 MyColor;
u32 Buffer;
u8 *Colors;
// Position Correction GX_PeekARGB(x, y, &peekColor);
if (x > (rmode->fbWidth/2)) { x = (rmode->fbWidth/2); } MyColor = RGBA(peekColor.r,peekColor.g,peekColor.b,peekColor.a);
if (x < 0) { x = 0; }
if (y > rmode->efbHeight) { y = rmode->efbHeight; }
if (y < 0) { y = 0; }
// Preparing FB for reading return (MyColor);
Buffer = ((u32 *)xfb[fb])[y*(rmode->fbWidth/2)+x]; }
Colors = (u8 *) &Buffer;
/**
/** Color channel: * Writes a pixel directly from the FrontBuffer.
Colors[0] = Y1 * @param x The x-coordinate within the FB.
Colors[1] = Cb * @param y The y-coordinate within the FB.
Colors[2] = Y2 */
Colors[3] = Cr */ INLINE
void GRRLIB_SetPixelToFB (int x, int y, u32 pokeColor) {
*R1 = GRRLIB_ClampVar8( 1.164 * (Colors[0] - 16) + 1.596 * (Colors[3] - 128) ); GXColor MyColor;
*G1 = GRRLIB_ClampVar8( 1.164 * (Colors[0] - 16) - 0.813 * (Colors[3] - 128) - 0.392 * (Colors[1] - 128) );
*B1 = GRRLIB_ClampVar8( 1.164 * (Colors[0] - 16) + 2.017 * (Colors[1] - 128) ); MyColor.r=R(pokeColor);
MyColor.g=G(pokeColor);
*R2 = GRRLIB_ClampVar8( 1.164 * (Colors[2] - 16) + 1.596 * (Colors[3] - 128) ); MyColor.b=B(pokeColor);
*G2 = GRRLIB_ClampVar8( 1.164 * (Colors[2] - 16) - 0.813 * (Colors[3] - 128) - 0.392 * (Colors[1] - 128) ); MyColor.a=A(pokeColor);
*B2 = GRRLIB_ClampVar8( 1.164 * (Colors[2] - 16) + 2.017 * (Colors[1] - 128) );
GX_PokeARGB(x, y, MyColor);
} }