[CHG] Started function GRRLIB_LoadTextureBMF (just the beginning)

This commit is contained in:
Crayon2000 2009-02-17 05:46:16 +00:00
parent 3d92f40205
commit a1edf64aac
5 changed files with 4171 additions and 5 deletions

View file

@ -241,6 +241,77 @@ GRRLIB_texImg GRRLIB_LoadTextureJPG(const unsigned char my_jpg[]) {
return my_texture;
}
/**
* Load a texture from a buffer.
* @param my_bmf the ByteMap font buffer to load.
* @return A GRRLIB_texImg structure filled with BMF informations.
*/
GRRLIB_texImg GRRLIB_LoadTextureBMF(const unsigned char my_bmf[]) {
/*
if s=BMFHEADER then begin
blockread(f,i,1);
blockread(f,lineheight,1);
blockread(f,sizeover,1);
blockread(f,sizeunder,1);
blockread(f,addspace,1);
blockread(f,sizeinner,1);
blockread(f,usedcolors,1);
blockread(f,highestcolor,1);
blockread(f,s[1],5);
for i:=1 to ord(s[5]) do begin
blockread(f,rgb[i],3);
rgb[i].r:=rgb[i].r shl 2+3;
rgb[i].g:=rgb[i].g shl 2+3;
rgb[i].b:=rgb[i].b shl 2+3;
end;
blockread(f,i,1); i:=byte(i); s:='';
while i>0 do begin
blockread(f,c,1);
s:=s+c;
dec(i);
end;
blockread(f,i,2);
for i:=pred(i) downto 0 do begin
blockread(f,c,1);
blockread(f,tablo[c],5);
with tablo[c] do
if w or h<>0 then begin
getmem(d,w*h);
blockread(f,d^,w*h);
end;
end;
end;
*/
GRRLIB_texImg my_texture;
int i, j = 0;
u8 lineheight;
u8 usedcolors, highestcolor;
short int sizeover, sizeunder, addspace, sizeinner, numcolpal, numchars;
u32 palette[64];
lineheight = my_bmf[5];
sizeover = my_bmf[6];
sizeunder = my_bmf[7];
addspace = my_bmf[8];
sizeinner = my_bmf[9];
usedcolors = my_bmf[10];
highestcolor = my_bmf[11];
numcolpal = 3 * my_bmf[16];
for(i=0; i < numcolpal; i+=3)
{ // Font palette
palette[j++] = ((my_bmf[i+17]<<24) | (my_bmf[i+18]<<16) | (my_bmf[i+19]<<8) | 0xFF);
}
numchars = my_bmf[18 + numcolpal + my_bmf[17 + numcolpal]];
for(i=0; i < numchars; i++)
{ // Bitmap character definitions
}
return my_texture; // Need another kind of struct
}
/**
* Load a texture from a buffer.
* @param my_img the JPEG or PNG buffer to load.
@ -248,14 +319,20 @@ GRRLIB_texImg GRRLIB_LoadTextureJPG(const unsigned char my_jpg[]) {
*/
GRRLIB_texImg GRRLIB_LoadTexture(const unsigned char my_img[]) {
if((my_img[0]==0xff) && (my_img[1]==0xd8) && (my_img[2]==0xff)) {
if(my_img[0]==0xFF && my_img[1]==0xD8 && my_img[2]==0xFF) {
return(GRRLIB_LoadTextureJPG(my_img));
}
else{
else if(my_img[0]==0xE1 && my_img[1]==0xE6 && my_img[2]==0xD5 && my_img[3]==0x1A) {
return GRRLIB_LoadTextureBMF(my_img);
}
/*
else if(my_img[0]==0x42 && my_img[1]==0x4D) {
// Bitmap not supported
}
*/
else {
return(GRRLIB_LoadTexturePNG(my_img));
}
}
/**
@ -640,7 +717,6 @@ void GRRLIB_BMFX_Blur(GRRLIB_texImg texsrc, GRRLIB_texImg texdest, int factor) {
GRRLIB_SetPixelTotexImg(x, y, texdest, (newr<<24) | (newg<<16) | (newb<<8) | newa);
}
}
}
/**

Binary file not shown.

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,14 @@
/*
This file was autogenerated by raw2c.
Visit http://www.devkitpro.org
*/
//---------------------------------------------------------------------------------
#ifndef _ocean_h_
#define _ocean_h_
//---------------------------------------------------------------------------------
extern const unsigned char ocean[];
extern const int ocean_size;
//---------------------------------------------------------------------------------
#endif //_ocean_h_
//---------------------------------------------------------------------------------

View file

@ -19,6 +19,7 @@
#include "gfx/BMfont4.h"
#include "gfx/BMfont5.h"
#include "gfx/test_jpg.h"
#include "gfx/ocean.h"
#include "gfx/sprite.h"
// Tile stuff
@ -71,6 +72,7 @@ int main() {
GRRLIB_texImg tex_test_jpg = GRRLIB_LoadTexture(test_jpg);
GRRLIB_texImg tex_test_bmf = GRRLIB_LoadTexture(ocean);
GRRLIB_texImg tex_sprite_png = GRRLIB_LoadTexture(sprite);
GRRLIB_InitTileSet(&tex_sprite_png, 24, 32, 0);
@ -212,6 +214,7 @@ int main() {
GRRLIB_Exit(); // Be a good boy, clear the memory allocated by GRRLIB
// Free some textures
free(tex_test_jpg.data);
free(tex_test_bmf.data);
free(tex_sprite_png.data);
free(tex_BMfont1.data);
free(tex_BMfont2.data);