libito & 64 bit

Discuss the development of software, tools, libraries and anything else that helps make ps2dev happen.

Moderators: cheriff, Herben

Post Reply
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

libito & 64 bit

Post by J.F. »

Seems the image converter for libito wasn't 64 bit clean... in fact, it tried storing pointers in a uint32. Not good on 64 bit linux. :)

Here's the corrected saveiif.cpp:

Code: Select all

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "saveiif.h"
#include "loadimage.h"
#include "exoquant.h"
#include "swizzle.h"

extern char* uppercase&#40;char* str&#41;;

// IIF v1 - Ito Image Format
typedef struct&#123;
	uint32 identifier; // 'IIF1' - IIFv &#40;v = version of iif&#41;
	uint32 width;
	uint32 height;
	uint32 psm;
&#125; IIFHeader;

// IIF v2 - Ito Image Format
typedef struct&#123;
	uint32 identifier; // 'IIF2'
	uint32 headerSize;
	uint16 width;
	uint16 height;
	uint16 psm;
	uint16 options;
	char   name&#91;16&#93;;
&#125; IIF2Header;

static bool ConvertRGBA32&#40;Image *image, void **outBuffer, uint32& outSize&#41;
&#123;
	outSize = image->width*image->height*4;
	*outBuffer = malloc&#40;outSize&#41;;

	memcpy&#40;*outBuffer, image->data, outSize&#41;;

	return true;
&#125;

static bool ConvertRGB24&#40;Image *image, void **outBuffer, uint32& outSize&#41;
&#123;
	outSize = image->width*image->height*3;
	*outBuffer = malloc&#40;outSize&#41;;

	uint8* out = &#40;uint8*&#41;*outBuffer;

	for&#40;uint32 i=0; i < &#40;image->width*image->height&#41;; i++&#41;
	&#123;
		out&#91;&#40;i*3&#41;&#93; = image->data&#91;&#40;i*4&#41;&#93;;
		out&#91;&#40;i*3&#41;+1&#93; = image->data&#91;&#40;i*4&#41;+1&#93;;
		out&#91;&#40;i*3&#41;+2&#93; = image->data&#91;&#40;i*4&#41;+2&#93;;
	&#125;

	return true;
&#125;

static bool ConvertRGBA16&#40;Image* image, void **outBuffer, uint32& outSize, bool swizzle&#41;
&#123;
	outSize = image->width*image->height*2;
	*outBuffer = malloc&#40;outSize&#41;;

	uint16* out = &#40;uint16*&#41;*outBuffer;

	for&#40;uint32 i=0; i < &#40;outSize/2&#41;; i++&#41;
	&#123;
		uint32 r = image->data&#91;&#40;i*4&#41;+0&#93; >> 3;
		uint32 g = image->data&#91;&#40;i*4&#41;+1&#93; >> 3;
		uint32 b = image->data&#91;&#40;i*4&#41;+2&#93; >> 3;
		uint32 a = &#40;image->data&#91;&#40;i*4&#41;+3&#93; > 0&#41;;

		out&#91;i&#93; = &#40;a << 15&#41; | &#40; &#40;b & 0x1F&#41; << 10&#41; | &#40; &#40;g & 0x1F&#41; << 5&#41; | &#40;r & 0x1F&#41;;
	&#125;

	if&#40;swizzle&#41;
	&#123;
		uint8* temp = &#40;uint8*&#41;malloc&#40;outSize&#41;;

		Swizzle16to32&#40;temp, &#40;uint8*&#41;*outBuffer, image->width, image->height&#41;;

		memcpy&#40;*outBuffer, temp, outSize&#41;;
		free&#40;temp&#41;;
	&#125;

	return true;
&#125;

static bool ConvertCLUT8RGBA32&#40;Image *image, void **outBuffer, uint32& outSize, bool swizzle&#41;
&#123;
	outSize = &#40;image->width*image->height&#41;+&#40;256*4&#41;;
	*outBuffer = malloc&#40;outSize&#41;;

	if&#40;image->psm > RGBA16&#41;
	&#123;
		uint32 *p = &#40;uint32*&#41;image->data;
		uint8* pixels = &#40;uint8*&#41;*outBuffer+&#40;256*4&#41;;
		uint32* pal = &#40;uint32*&#41;*outBuffer;
		uint32 index = 0;

		for&#40;uint32 i=0; i < &#40;image->width*image->height&#41;; i++&#41;
		&#123;
			uint32 j = 0;

			while&#40;&#40;p&#91;i&#93; != pal&#91;j&#93;&#41; && &#40;j < 256&#41;&#41; j++;

			if&#40;j == 256&#41; j = 255;

			if&#40;p&#91;i&#93; != pal&#91;j&#93;&#41;
			&#123;
				pal&#91;index&#93; = p&#91;i&#93;;
				pixels&#91;i&#93; = index;
				index++;
				//printf&#40;"!"&#41;;
			&#125;
			else
			&#123;
				//printf&#40;"%i\n", j&#41;;
				pixels&#91;i&#93; = j;
			&#125;
		&#125;

	&#125;
	else
	&#123;
		exq_data *pExq = exq_init&#40;&#41;;
		exq_feed&#40;pExq, image->data, image->width*image->height&#41;;
		exq_quantize&#40;pExq, 256&#41;;
		exq_get_palette&#40;pExq, &#40;uint8*&#41;*outBuffer, 256&#41;;
		exq_map_image&#40;pExq, image->width*image->height, image->data, &#40;uint8*&#41;&#40;&#40;uint8*&#41;*outBuffer+&#40;256*4&#41;&#41;&#41;;
		exq_free&#40;pExq&#41;;
	&#125;

	uint32* pal = &#40;uint32*&#41;*outBuffer;

	for&#40;uint32 i=0; i < 8; i++&#41;
	&#123;
		uint32 temp&#91;8&#93;;

		memcpy&#40;temp, pal+8, &#40;8*4&#41;&#41;;
		memcpy&#40;pal+8, pal+16, &#40;8*4&#41;&#41;;
		memcpy&#40;pal+16, temp, &#40;8*4&#41;&#41;;

		pal += 32;
	&#125;


	if&#40;swizzle&#41;
	&#123;
		uint8* temp = &#40;uint8*&#41;malloc&#40;outSize-&#40;256*4&#41;&#41;;

		Swizzle8to32&#40;temp, &#40;uint8*&#41;*outBuffer+&#40;256*4&#41;, image->width, image->height&#41;;
		memcpy&#40;&#40;uint8*&#41;*outBuffer+&#40;256*4&#41;, temp, outSize-&#40;256*4&#41;&#41;;
		free&#40;temp&#41;;
	&#125;

	return true;
&#125;


static bool ConvertCLUT4RGBA32&#40;Image *image, void **outBuffer, uint32& outSize, bool swizzle&#41;
&#123;
	outSize = &#40;&#40;image->width*image->height&#41;/2&#41;+&#40;16*4&#41;;
	*outBuffer = malloc&#40;outSize&#41;;

	uint8* buffer = &#40;uint8*&#41;malloc&#40;image->width*image->height&#41;;

	if&#40;image->psm > CLUT8_RGBA16&#41;
	&#123;
		uint32 *p = &#40;uint32*&#41;image->data;
		uint8* pixels = buffer;
		uint32* pal = &#40;uint32*&#41;*outBuffer;
		uint32 index = 0;

		for&#40;uint32 i=0; i < &#40;image->width*image->height&#41;; i++&#41;
		&#123;
			uint32 j = 0;

			while&#40;&#40;p&#91;i&#93; != pal&#91;j&#93;&#41; && &#40;j < 16&#41;&#41; j++;

			if&#40;j == 16&#41; j = 15;;

			if&#40;p&#91;i&#93; != pal&#91;j&#93;&#41;
			&#123;
				pal&#91;index&#93; = p&#91;i&#93;;
				pixels&#91;i&#93; = index;
				index++;
			&#125;
			else
			&#123;
				pixels&#91;i&#93; = j;
			&#125;
		&#125;

	&#125;
	else
	&#123;
		exq_data *pExq = exq_init&#40;&#41;;
		exq_feed&#40;pExq, image->data, image->width*image->height&#41;;
		exq_quantize&#40;pExq, 16&#41;;
		exq_get_palette&#40;pExq, &#40;uint8*&#41;*outBuffer, 16&#41;;
		exq_map_image&#40;pExq, image->width*image->height, image->data, buffer&#41;;
		exq_free&#40;pExq&#41;;
	&#125;

	uint8* out = &#40;&#40;uint8*&#41;*outBuffer&#41;+&#40;16*4&#41;;

	for&#40;uint32 i=0; i < &#40;&#40;image->width*image->height&#41;/2&#41;; i++&#41;
	&#123;
		//out&#91;i&#93; = &#40;i % 16&#41; << 4 | &#40;i % 16&#41;;

		out&#91;i&#93; = buffer&#91;&#40;i*2&#41;+1&#93; << 4 | buffer&#91;&#40;i*2&#41;&#93;;
	&#125;


	free&#40;buffer&#41;;

	if&#40;swizzle&#41;
	&#123;
		uint8* temp = &#40;uint8*&#41;malloc&#40;outSize-&#40;16*4&#41;&#41;;

		Swizzle4to32&#40;temp, &#40;uint8*&#41;*outBuffer+&#40;16*4&#41;, image->width, image->height&#41;;
		memcpy&#40;&#40;uint8*&#41;*outBuffer+&#40;16*4&#41;, temp, outSize-&#40;16*4&#41;&#41;;
		free&#40;temp&#41;;
	&#125;

	return true;
&#125;

static bool ConvertCLUT8RGBA16&#40;Image *image, void **outBuffer, uint32& outSize, bool swizzle&#41;
&#123;
	uint8 palette&#91;256*4&#93;;

	outSize = &#40;image->width*image->height&#41;+&#40;256*2&#41;;
	*outBuffer = malloc&#40;outSize&#41;;

	if&#40;image->psm > RGBA16&#41;
	&#123;
		uint32 *p = &#40;uint32*&#41;image->data;
		uint8* pixels = &#40;uint8*&#41;*outBuffer+&#40;256*2&#41;;
		uint32* pal = &#40;uint32*&#41;palette;
		uint32 index = 0;

		for&#40;uint32 i=0; i < &#40;image->width*image->height&#41;; i++&#41;
		&#123;
			uint32 j = 0;

			while&#40;&#40;p&#91;i&#93; != pal&#91;j&#93;&#41; && &#40;j < 256&#41;&#41; j++;

			if&#40;j == 256&#41; j = 255;

			if&#40;p&#91;i&#93; != pal&#91;j&#93;&#41;
			&#123;
				pal&#91;index&#93; = p&#91;i&#93;;
				pixels&#91;i&#93; = index;
				index++;
				//printf&#40;"!"&#41;;
			&#125;
			else
			&#123;
				//printf&#40;"%i\n", j&#41;;
				pixels&#91;i&#93; = j;
			&#125;
		&#125;

	&#125;
	else
	&#123;

		exq_data *pExq = exq_init&#40;&#41;;
		exq_feed&#40;pExq, image->data, image->width*image->height&#41;;
		exq_quantize&#40;pExq, 256&#41;;
		exq_get_palette&#40;pExq, palette, 256&#41;;
		exq_map_image&#40;pExq, image->width*image->height, image->data, &#40;uint8*&#41;&#40;&#40;uint8*&#41;*outBuffer+&#40;256*2&#41;&#41;&#41;;
		exq_free&#40;pExq&#41;;
	&#125;

	uint32* pal = &#40;uint32*&#41;palette;

	for&#40;uint32 i=0; i < 8; i++&#41;
	&#123;
		uint32 temp&#91;8&#93;;

		memcpy&#40;temp, pal+8, &#40;8*4&#41;&#41;;
		memcpy&#40;pal+8, pal+16, &#40;8*4&#41;&#41;;
		memcpy&#40;pal+16, temp, &#40;8*4&#41;&#41;;

		pal += 32;
	&#125;


	uint16* out = &#40;uint16*&#41;*outBuffer;

	for&#40;uint32 i=0; i < 256; i++&#41;
	&#123;
		uint32 r = palette&#91;&#40;i*4&#41;+0&#93; >> 3;
		uint32 g = palette&#91;&#40;i*4&#41;+1&#93; >> 3;
		uint32 b = palette&#91;&#40;i*4&#41;+2&#93; >> 3;
		uint32 a = &#40;palette&#91;&#40;i*4&#41;+3&#93; > 0&#41;;

		out&#91;i&#93; = &#40;a << 15&#41; | &#40; &#40;b & 0x1F&#41; << 10&#41; | &#40; &#40;g & 0x1F&#41; << 5&#41; | &#40;r & 0x1F&#41;;
	&#125;

	if&#40;swizzle&#41;
	&#123;
		uint8* temp = &#40;uint8*&#41;malloc&#40;outSize-&#40;256*2&#41;&#41;;

		Swizzle8to32&#40;temp, &#40;uint8*&#41;*outBuffer+&#40;256*2&#41;, image->width, image->height&#41;;
		memcpy&#40;&#40;uint8*&#41;*outBuffer+&#40;256*2&#41;, temp, outSize-&#40;256*2&#41;&#41;;
		free&#40;temp&#41;;
	&#125;


	return true;
&#125;

static bool ConvertCLUT4RGBA16&#40;Image *image, void **outBuffer, uint32& outSize, bool swizzle&#41;
&#123;
	uint8 palette&#91;16*4&#93;;

	outSize = &#40;&#40;image->width*image->height&#41;/2&#41;+&#40;16*2&#41;;
	*outBuffer = malloc&#40;outSize&#41;;

	uint8* buffer = &#40;uint8*&#41;malloc&#40;image->width*image->height&#41;;

	if&#40;image->psm > CLUT8_RGBA16&#41;
	&#123;
		uint32 *p = &#40;uint32*&#41;image->data;
		uint8* pixels = buffer;
		uint32* pal = &#40;uint32*&#41;palette;
		uint32 index = 0;

		for&#40;uint32 i=0; i < &#40;image->width*image->height&#41;; i++&#41;
		&#123;
			uint32 j = 0;

			while&#40;&#40;p&#91;i&#93; != pal&#91;j&#93;&#41; && &#40;j < 16&#41;&#41; j++;

			if&#40;j == 16&#41; j = 15;

			if&#40;p&#91;i&#93; != pal&#91;j&#93;&#41;
			&#123;
				pal&#91;index&#93; = p&#91;i&#93;;
				pixels&#91;i&#93; = index;
				index++;
			&#125;
			else
			&#123;
				pixels&#91;i&#93; = j;
			&#125;
		&#125;

	&#125;
	else
	&#123;
		exq_data *pExq = exq_init&#40;&#41;;
		exq_feed&#40;pExq, image->data, image->width*image->height&#41;;
		exq_quantize&#40;pExq, 16&#41;;
		exq_get_palette&#40;pExq, palette, 16&#41;;
		exq_map_image&#40;pExq, image->width*image->height, image->data, buffer&#41;;
		exq_free&#40;pExq&#41;;
	&#125;

	uint16* out = &#40;uint16*&#41;*outBuffer;

	for&#40;uint32 i=0; i < 16; i++&#41;
	&#123;
		uint32 r = palette&#91;&#40;i*4&#41;+0&#93; >> 3;
		uint32 g = palette&#91;&#40;i*4&#41;+1&#93; >> 3;
		uint32 b = palette&#91;&#40;i*4&#41;+2&#93; >> 3;
		uint32 a = &#40;palette&#91;&#40;i*4&#41;+3&#93; > 0&#41;;

		out&#91;i&#93; = &#40;a << 15&#41; | &#40; &#40;b & 0x1F&#41; << 10&#41; | &#40; &#40;g & 0x1F&#41; << 5&#41; | &#40;r & 0x1F&#41;;
	&#125;

	uint8* out2 = &#40;uint8*&#41;&#40;&#40;uint8*&#41;*outBuffer+&#40;16*2&#41;&#41;;

	for&#40;uint32 i=0; i < &#40;&#40;image->width*image->height&#41;/2&#41;; i++&#41;
	&#123;
		out2&#91;i&#93; = &#40;&#40;buffer&#91;&#40;i*2&#41;+1&#93; & 0xF&#41; << 4&#41; | &#40;buffer&#91;&#40;i*2&#41;&#93; & 0xF&#41;;
	&#125;

	free&#40;buffer&#41;;

	if&#40;swizzle&#41;
	&#123;
		uint8* temp = &#40;uint8*&#41;malloc&#40;outSize-&#40;16*2&#41;&#41;;

		Swizzle4to32&#40;temp, &#40;uint8*&#41;*outBuffer+&#40;16*2&#41;, image->width, image->height&#41;;
		memcpy&#40;&#40;uint8*&#41;*outBuffer+&#40;16*2&#41;, temp, outSize-&#40;16*2&#41;&#41;;
		free&#40;temp&#41;;
	&#125;

	return true;
&#125;






bool SaveIIF&#40;char* filename, Image *image, uint32 psm, uint32 options&#41;
&#123;
		uint32 error = 0;

		dprintf&#40;"SaveIIF&#40;..&#41;\n"&#41;;
		dprintf&#40;"image->data 0x%08X\n", &#40;uint32&#41;image->data&#41;;
		dprintf&#40;"image->width&#58; %i\n", image->width&#41;;
		dprintf&#40;"image->height&#58; %i\n", image->height&#41;;


		if&#40;image->width > 4096&#41;
		&#123;
			printf&#40;"Error&#58; Width must be less than or equal 4096\n"&#41;;
			return false;
		&#125;

		if&#40;image->height > 4096&#41;
		&#123;
			printf&#40;"Error&#58; Height must be less than or equal 4096\n"&#41;;
			return false;
		&#125;


		if&#40;&#40;options & IIF_OPTION_SWIZZLE&#41;&#41;
		&#123;
			switch&#40;psm&#41;
			&#123;
				case RGBA32&#58;
				case RGB24&#58;
				case AUTO&#58;
					printf&#40;"Error&#58; RGBA32 & RGB24 images can not be swizzled\n"&#41;;
					return false;
				break;

				case RGBA16&#58;
					if&#40;image->width <= 64&#41;
					&#123;
						if&#40;image->width % 16&#41; error = 1;
					&#125;
					else
					&#123;
						if&#40;image->width % 64&#41; error = 1;
					&#125;

					if&#40;image->height <= 64&#41;
					&#123;
						if&#40;image->height % 8&#41; error = 1;
					&#125;
					else
					&#123;
						if&#40;image->height % 64&#41; error = 1;
					&#125;

					if&#40;error&#41;
					&#123;
						printf&#40;"Error&#58; Could not swizzle image PSM&#58; RGBA16 Width&#58; %i Height&#58; %i\n", image->width, image->height&#41;;
						printf&#40;"Width must be 16, 32, 48, 64, any multiple of 64 less than or equal to 4096\n"&#41;;
						printf&#40;"Height must be 8, 16, 24, 32, 40, 48, 56, 64, any multiple of 64 less than or equal to 4096\n"&#41;;
						return false;
					&#125;
				break;

				case CLUT8_RGBA32&#58;
				case CLUT8_RGBA16&#58;

					if&#40;image->width % 16&#41; error = 1;
					if&#40;image->height % 4&#41; error = 1;

					if&#40;error&#41;
					&#123;
						printf&#40;"Error&#58; Could not swizzle image PSM&#58; CLUT8-RGBA16 / CLUT8-RGBA32 Width&#58; %i Height&#58; %i\n", image->width, image->height&#41;;
						printf&#40;"Width must be any multiple of 16 less than or equal to 4096\n"&#41;;
						printf&#40;"Height must be any multiple of 4 less than or equal to 4096\n"&#41;;
						return false;
					&#125;
				break;

				case CLUT4_RGBA32&#58;
				case CLUT4_RGBA16&#58;

					if&#40;image->width <= 128&#41;
					&#123;
						if&#40;image->width % 32&#41; error = 1;
					&#125;
					else
					&#123;
						if&#40;image->width % 128&#41; error = 1;
					&#125;

					if&#40;image->height <= 128&#41;
					&#123;
						if&#40;image->height % 16&#41; error = 1;
					&#125;
					else
					&#123;
						if&#40;image->height % 128&#41; error = 1;
					&#125;

					if&#40;error&#41;
					&#123;
						printf&#40;"Error&#58; Could not swizzle image PSM&#58; CLUT4-RGBA16 / CLUT4-RGBA32 Width %i Height %i\n", image->width, image->height&#41;;
						printf&#40;"Width must be 32, 64, 96, 128, any multiple of 128 less than or equal to 4096\n"&#41;;
						printf&#40;"Height must be 16, 32, 48, 64, 80, 96, 112, 128, any multiple of 128 less than or equal to 4096\n"&#41;;
						return false;
					&#125;
				break;

				default&#58;
					printf&#40;"Internal Error 2\n"&#41;;
					return false;
				break;
			&#125;
		&#125;

		void* buffer;
		uint32 bufferSize;
		bool res = false;

		switch&#40;psm&#41;
		&#123;
			case RGBA32&#58; res = ConvertRGBA32&#40;image, &buffer, bufferSize&#41;; break;
			case RGB24&#58; res = ConvertRGB24&#40;image, &buffer, bufferSize&#41;; break;
			case RGBA16&#58; res = ConvertRGBA16&#40;image, &buffer, bufferSize, options & IIF_OPTION_SWIZZLE&#41;; break;
			case CLUT8_RGBA32&#58; res = ConvertCLUT8RGBA32&#40;image, &buffer, bufferSize, options & IIF_OPTION_SWIZZLE&#41;; break;
			case CLUT4_RGBA32&#58; res = ConvertCLUT4RGBA32&#40;image, &buffer, bufferSize, options & IIF_OPTION_SWIZZLE&#41;; break;
			case CLUT8_RGBA16&#58; res = ConvertCLUT8RGBA16&#40;image, &buffer, bufferSize, options & IIF_OPTION_SWIZZLE&#41;; break;
			case CLUT4_RGBA16&#58; res = ConvertCLUT4RGBA16&#40;image, &buffer, bufferSize, options & IIF_OPTION_SWIZZLE&#41;; break;

			default&#58;
			&#123;
				printf&#40;"Internal Error 3\n"&#41;;
				return false;
			&#125;
		&#125;

		if&#40;res == false&#41;
		&#123;
			printf&#40;"Error&#58; Could not encode IIF\n"&#41;;
			return false;
		&#125;


		FILE* fpIIF;

		if&#40;!&#40;fpIIF = fopen&#40; filename, "wb"&#41;&#41;&#41;
		&#123;
			printf&#40;"Error&#58; Could not open IIF file \"%s\" for writing.\n", filename&#41;;
			return false;
		&#125;

		dprintf&#40;"bufferSize ~%i KB\n", bufferSize/1024&#41;;
		dprintf&#40;"buffer %016X\n", &#40;uint64&#41;buffer&#41;;


		if&#40;options & IIF_OPTION_FORCE&#41;
		&#123;
			IIFHeader header;

			header.identifier = 0x31464949; // 'IIF1'text string
			header.width = image->width;
			header.height = image->height;
			header.psm = psm;

			fseek&#40;fpIIF, 0, SEEK_SET&#41;;
			fwrite&#40;&header, sizeof&#40;uint8&#41;, sizeof&#40;header&#41;, fpIIF&#41;;
			fseek&#40;fpIIF, sizeof&#40;header&#41;, SEEK_SET&#41;;
			fwrite&#40;buffer, sizeof&#40;uint8&#41;, bufferSize, fpIIF&#41;;
		&#125;
		else
		&#123;
			IIF2Header header;

			header.identifier = 0x32464949; // 'IIF2'text string
			header.headerSize = 24;
			header.width = image->width;
			header.height = image->height;
			header.psm = psm;
			header.options = options & ~IIF_OPTION_FORCE;

			memset&#40;header.name, 0, sizeof&#40;header.name&#41;&#41;;

			if&#40;strlen&#40;filename&#41; > sizeof&#40;header.name&#41;&#41;
				strncpy&#40;header.name, filename, sizeof&#40;header.name&#41;&#41;;
			else
				strcpy&#40;header.name, filename&#41;;

			bool clear = false;

			for&#40;uint32 i=0; i < sizeof&#40;header.name&#41;; i++&#41;
			&#123;
				if&#40;header.name&#91;i&#93; == '.'&#41; clear = true;
				if&#40;clear&#41; header.name&#91;i&#93; = 0;
			&#125;

			uppercase&#40;header.name&#41;;
			header.name&#91;sizeof&#40;header.name&#41;-1&#93; = 0;

			fseek&#40;fpIIF, 0, SEEK_SET&#41;;
			fwrite&#40;&header, sizeof&#40;uint8&#41;, sizeof&#40;header&#41;, fpIIF&#41;;
			fseek&#40;fpIIF, sizeof&#40;header&#41;, SEEK_SET&#41;;
			fwrite&#40;buffer, sizeof&#40;uint8&#41;, bufferSize, fpIIF&#41;;
		&#125;

		free&#40;buffer&#41;;

		fclose&#40;fpIIF&#41;;

		return true;
&#125;
Using that, it seems to work fine on Ubuntu 7.10 on my 64 bit system. The texture format example works fine, and the iif images look like the BMP, so I guess it works.
Post Reply