Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles

Rubberduckycooly

1
Posts
1
Topics
A member registered 93 days ago

Recent community posts

No Problem! I have now replied (to the github thread) with more code that might help!

Since i haven't got a response on GitHub i thought i might ask here:

I Have Created a Loader to load .gif images that is based off src_lib\loadbitmap.h but when i load a sprite using this method, nothing is displayed...

When i check the values the width, height, bit_depth and palette are all correct and assigned but the image still isn't showing up...

Here is My Code (I am using gif_lib (http://giflib.sourceforge.net) to get the data for the .gif images):

#include "..\src\GifLib\gif_lib.h"

static TLN_Bitmap LoadGIF(const char* filename)
{
	//Init
	TLN_Bitmap bitmap = NULL;
	GifFileType* Gif = DGifOpenFileName(filename, 0);
	DGifSlurp(Gif);
	//General Gif Values
	int width = Gif->Image.Width; std::cout << "Image Width = " << width << std::endl;
	int height = Gif->Image.Height; std::cout << "Image Height = " << height << std::endl;
	int bit_depth = Gif->SColorResolution; std::cout << "Colour = " << bit_depth << std::endl;
	bitmap = TLN_CreateBitmap(width, height, bit_depth);
	//Load ScanLines
	int pitch = TLN_GetBitmapPitch(bitmap);
	int l;
	for (l = 0; l<height; l++)
	{
		uint8_t* line = TLN_GetBitmapPtr(bitmap, 0, l);
	}
	//Colour Palette Values
	TLN_Palette pal;
	int palette_entries = Gif->SColorMap->ColorCount;
	int c;
	pal = TLN_CreatePalette(palette_entries);
	std::cout << palette_entries << std::endl;
	for (c = 0; c < palette_entries; c++)
	{
		TLN_SetPaletteColor(pal, c, Gif->SColorMap->Colors[c].Red, Gif->SColorMap->Colors[c].Green, Gif->SColorMap->Colors[c].Blue);
	}
	TLN_SetBitmapPalette(bitmap, pal);
	/* bitmap loaded */
	if (bitmap)
	{
		/* accept only 8 bpp */
		int bpp = TLN_GetBitmapDepth(bitmap);
		if (bpp == 8)
			TLN_SetLastError(TLN_ERR_OK);
		else
		{
			TLN_DeleteBitmap(bitmap);
			bitmap = NULL;
		}
	}
	if (!bitmap)
		TLN_SetLastError(TLN_ERR_WRONG_FORMAT);
	return bitmap;
}