Exemple #1
0
void test_ilLoadFuncs(wchar_t* sourceFN, wchar_t* targetFN)
{
	testHeap();
	ilInit();
	testHeap();
	ILuint handle = ilGenImage();
	testHeap();
	ilBindImage(handle);
	testHeap();
	//printf("Loading " PathCharMod "\n", sourceFN);
	FILE* f = _wfopen(sourceFN, L"rb");
	bool loaded = false;

	if (f != NULL) {
		fseek(f, 0, SEEK_END);
		myDataSize = ftell(f);
		if (myDataSize > 0) {
			fseek(f, 0, SEEK_SET);
			myData = new BYTE[myDataSize];
			size_t read = fread(myData, 1, myDataSize, f);
			myReadPos = 0;
			if (read == myDataSize) {
				//loaded = ilLoadL(IL_TYPE_UNKNOWN, lump, read);
				ilSetRead(myOpenProc, myCloseProc, myEofProc, myGetcProc, myReadProc, mySeekProc, myTellProc);
				loaded = ilLoadFuncs(IL_TYPE_UNKNOWN);
				if (!loaded) {
					printf("test_ilLoadFuncs: Failed to load " PathCharMod "\n", sourceFN);
					++errors;
				}
			} else {
				printf("test_ilLoadFuncs: Failed to read " PathCharMod "\n", sourceFN);
				++errors;
			}
			delete myData;
		}
		fclose(f);
	} else {
		printf("test_ilLoadFuncs: Failed to open %S\n", sourceFN);
		++errors;
	}

	testHeap();
	//ilConvertImage(IL_BGR, IL_UNSIGNED_BYTE);
	//ilConvertImage(IL_LUMINANCE, IL_UNSIGNED_BYTE);
	//iluScale(150, 150, 1);
	testHeap();
	DeleteFile(targetFN);
	//printf("Saving " PathCharMod "\n", targetFN);
	if (loaded)
		if(!ilSaveImage(targetFN)) {
			printf("Failed to save " PathCharMod " after ilLoadFuncs\n", targetFN);
			++errors;
		}
	testHeap();
	ilDeleteImage(handle);
}
Exemple #2
0
ILboolean testDetermineTypeFromContent(TCHAR* fn)
{
	testHeap();
	ilInit();
	testHeap();
	ILuint handle = ilGenImage();
	testHeap();
	ilBindImage(handle);
	testHeap();
	//printf("Loading " PathCharMod "\n", sourceFN);
	FILE* f = _wfopen(fn, L"rb");
	bool loaded = false;
	ILenum type = IL_TYPE_UNKNOWN;

	if (f != NULL) {
		fseek(f, 0, SEEK_END);
		myDataSize = ftell(f);
		if (myDataSize > 0) {
			fseek(f, 0, SEEK_SET);
			myData = new BYTE[myDataSize];
			size_t read = fread(myData, 1, myDataSize, f);
			myReadPos = 0;
			if (read == myDataSize) {
				//loaded = ilLoadL(IL_TYPE_UNKNOWN, lump, read);
				ilSetRead(myOpenProc, myCloseProc, myEofProc, myGetcProc, myReadProc, mySeekProc, myTellProc);
				type = ilDetermineTypeFuncs();
				if (type == IL_TYPE_UNKNOWN) {
					printf("testDetermineTypeFromContent: Failed to determine type of " PathCharMod "\n", fn);
					++errors;
				}
			} else {
				printf("testDetermineTypeFromContent: Failed to read " PathCharMod "\n", fn);
				++errors;
			}
			delete myData;
		}
		fclose(f);
	} else {
		printf("testDetermineTypeFromContent: Failed to open %S\n", fn);
		++errors;
	}

	testHeap();
	ilDeleteImage(handle);

	if (type == IL_TYPE_UNKNOWN) {
		++errors;
		return IL_FALSE;
	} else
		return IL_TRUE;
}
Exemple #3
0
ILvoid ILAPIENTRY ilResetRead()
{
	ilSetRead(iDefaultOpenR, iDefaultCloseR, iDefaultEof, iDefaultGetc, 
				iDefaultRead, iDefaultRSeek, iDefaultRTell);
	return;
}