void testSavers2(ILenum type, const TCHAR* targetName, const TCHAR* targetExt) { TCHAR targetFN[MAX_PATH]; // Test ilSave _tcscpy(targetFN, targetName); _tcscat(targetFN, L".ilSave."); _tcscat(targetFN, targetExt); if (!ilSave(type, targetFN)) { printf("testSavers2: Failed to save " PathCharMod " using ilSave\n", targetFN); ++errors; } // Test ilSaveF _tcscpy(targetFN, targetName); _tcscat(targetFN, L".ilSaveF."); _tcscat(targetFN, targetExt); FILE* file = _wfopen(targetFN, L"wb"); if (!ilSaveF(type, file)) { printf("testSavers2: Failed to save " PathCharMod " using ilSaveF\n", targetFN); ++errors; } fclose(file); // Test ilSaveL _tcscpy(targetFN, targetName); _tcscat(targetFN, L"ilSaveL."); _tcscat(targetFN, targetExt); ILuint lumpSize = ilDetermineSize(type); BYTE* lump = new BYTE[lumpSize]; ILuint writtenToLump = ilSaveL(type, lump, lumpSize); if (writtenToLump > 0) { FILE* file = _wfopen(targetFN, L"wb"); size_t writtenToFile = fwrite(lump, 1, lumpSize, file); if (writtenToLump != writtenToFile) { printf("testSavers2: Failed to write " PathCharMod " after ilSaveL\n", targetFN); ++errors; } fclose(file); } else { printf("testSavers2: Failed to save " PathCharMod " using ilSaveL\n", targetFN); ++errors; } delete lump; // Test ilSaveFuncs wcscpy(targetFN, targetName); wcscat(targetFN, L".ilSaveFuncs."); wcscat(targetFN, targetExt); writeFile = _wfopen(targetFN, L"wb"); if (writeFile != NULL) { ilSetWrite(NULL, NULL, myPutc, mySeek, myTell, myWrite); if (!ilSaveFuncs(type)) printf("testSavers2: Failed to save " PathCharMod " using ilSave\n", targetFN); fclose(writeFile); } else printf("testSavers2: Failed to open " PathCharMod " for writing\n", targetFN); }
void ILUTest::TestiluReplaceColour() { ILuint MainImage = 0; FILE * lBuffer = fopen(".\\results\\result.bmp", "wb"); ilGenImages(1, &MainImage); ilBindImage(MainImage); LoadStandardImage(); ilConvertImage(IL_RGB,IL_BYTE); iluReplaceColour(1.0, 0.0, 0.0, 0.0); ilSaveF(IL_BMP,lBuffer); fclose(lBuffer); }
void ILUTest::TestiluSaturate4f() { ILuint MainImage = 0; FILE * lBuffer = fopen(".\\results\\result.bmp", "wb"); ilGenImages(1, &MainImage); ilBindImage(MainImage); LoadStandardImage(); ilConvertImage(IL_RGB,IL_BYTE); iluSaturate4f(-1.0, 0.0, 0.0, -1.0); iluMirror(); iluBlurAvg(3); ilSaveF(IL_BMP,lBuffer); fclose(lBuffer); }
UInt32 GUCEF_PLUGIN_CALLSPEC_PREFIX IMGCODECPLUGIN_EncodeImage( void* pluginData , void* codecData , const char* codecType , TImage* inputImage , TIOAccess* output ) { UInt32 i = 0; UInt32 n = 0; TImageInfo* imageInfo = NULL; char codecTypeExt[ 256 ]; /* generate an image ID and make that ID the ID of the current image */ ilBindImage( ilGenImage() ); /* Only 1 layer is supported atm */ ilActiveLayer( 0 ); imageInfo = &inputImage->imageInfo; for ( i=0; i<imageInfo->nrOfFramesInImage; ++i ) { TImageFrameInfo* imageFrameInfo = &inputImage->frames[ i ].frameInfo; /* activate the frame */ ilActiveImage( i ); for ( n=0; n<imageFrameInfo->nrOfMipmapLevels; ++n ) { /* create a shortcut */ TImageMipMapLevelInfo* mipInfo = &inputImage->frames[ i ].mipmapLevel[ n ].mipLevelInfo; void* imageBuffer = inputImage->frames[ i ].mipmapLevel[ n ].pixelData; /* activate the mip-map */ ilActiveMipmap( n ); /* hand the data over to DevIL */ if ( IL_TRUE != ilTexImage( (ILuint)mipInfo->frameWidth , (ILuint)mipInfo->frameHeight , (ILuint)1 , (ILubyte) GetChannelCountForFormat( mipInfo->pixelStorageFormat ) , (ILenum)ConvertGUCEFPixelFormatToILPixelFormat( mipInfo->pixelStorageFormat ) , (ILenum)ConvertGUCEFTypeToILType( mipInfo->pixelComponentDataType ) , (void*)imageBuffer ) ) { /* Failed to transfer the data over to DevIL */ return 0; } } } /* Make sure we prefix a dot before the codecType */ strcpy_s( codecTypeExt+1, 255, codecType ); codecTypeExt[ 0 ] = '.'; /* now we can perform the actual save */ currentResource = output; if ( IL_TRUE == ilSaveF( ilTypeFromExt( codecTypeExt ), output ) ) { currentResource = NULL; return 1; } currentResource = NULL; return 0; }