flTextureManipulation.c

Go to the documentation of this file.
00001 #include "flGlobal.h"
00002 #if FL_TEXTURE_MANIPULATION != 0
00003 #include <stdlib.h>
00004 #include <stdio.h>
00005 #include <pspkernel.h>
00006 
00007 #if FL_INCLUDE_ALL_C == 0
00008 #include "flTextureManipulation.h"
00009 #include "flTexture.h"
00010 #endif
00011 
00012 void texMnpColorReplace(Texture* inTex, u32 inColor, u32 inReplace) {
00013      if(inTex->texPixelFormat > GU_PSM_8888) {
00014           #if DEBUG_WARNING != 0
00015           debugWarning("Color replacement is currently only supported for true-color textures.");
00016           #endif
00017           return;
00018      }
00019      int i, j;
00020      if(inTex->texPixelFormat == GU_PSM_8888) {
00021           u32* tempData = (u32*)inTex->texData;
00022           for(j = 0; j < inTex->texHeight; j++) {
00023                for(i = 0; i < inTex->texWidth; i++) {
00024                     if(tempData[(j * inTex->texDataWidth) + i] == inColor)
00025                          tempData[(j * inTex->texDataWidth) + i] = inReplace;
00026                }
00027           }
00028      } else if(inTex->texPixelFormat < GU_PSM_8888) {
00029           u16* tempData = (u16*)inTex->texData;
00030           for(j = 0; j < inTex->texHeight; j++) {
00031                for(i = 0; i < inTex->texWidth; i++) {
00032                     if(tempData[(j * inTex->texDataWidth) + i] == (inColor & 0x0000FFFF))
00033                          tempData[(j * inTex->texDataWidth) + i] = (inReplace & 0x0000FFFF);
00034                }
00035           }
00036      }
00037      #if FL_TEXTURE_UNCACHED == 0
00038      sceKernelDcacheWritebackInvalidateAll();
00039      #endif
00040 }
00041 
00042 #endif

Generated on Wed Sep 5 19:04:01 2007 for funcLib by  doxygen 1.5.1