ILboolean ILAPIENTRY ilutD3D8VolTexFromFileHandle(IDirect3DDevice8 *Device, ILHANDLE File, IDirect3DVolumeTexture8 **Texture) { iBindImageTemp(); if (!ilLoadF(IL_TYPE_UNKNOWN, File)) return IL_FALSE; *Texture = ilutD3D8VolumeTexture(Device); return IL_TRUE; }
ILboolean ILAPIENTRY ilutD3D10TexFromFileHandle(ID3D10Device *Device, ILHANDLE File, ID3D10Texture2D **Texture) { iBindImageTemp(); if (!ilLoadF(IL_TYPE_UNKNOWN, File)) return IL_FALSE; *Texture = ilutD3D10Texture(Device); return IL_TRUE; }
void test_ilLoadF(wchar_t* sourceFN, wchar_t* targetFN) { testHeap(); ilInit(); testHeap(); ILuint handle = ilGenImage(); testHeap(); ilBindImage(handle); testHeap(); //printf("Loading " PathCharMod "\n", sourceFN); bool loaded = false; //FILE* f = _wfopen(sourceFN, L"rb"); FILE * f; char buf[10]; _wfopen_s(&f, sourceFN, L"rb"); fread(buf, 1, 10, f); fseek(f, 0, IL_SEEK_SET); if (f != NULL) { loaded = ilLoadF(IL_TYPE_UNKNOWN, f); if(!loaded) { printf("test_ilLoadF: Failed to load %S\n", sourceFN); ++errors; } } else { printf("test_ilLoadF: Failed to open %S\n", sourceFN); ++errors; } fclose(f); 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 ("test_ilLoadF: Failed to save %S\n", targetFN); ++errors; } testHeap(); ilDeleteImage(handle); }
UInt32 GUCEF_PLUGIN_CALLSPEC_PREFIX IMGCODECPLUGIN_DecodeImage( void* pluginData , void* codecData , const char* codecType , TIOAccess* input , TImage** imageOutput , void** imageData ) { UInt32 i=0, n=0, mipmapCount=0, frameCount=0; ILint imageID = 0, imageSize = 0; TImage* image = NULL; if ( ( NULL == codecType ) || ( NULL == input ) ) return 0; /* generate an image ID and make that ID the ID of the current image */ imageID = ilGenImage(); ilBindImage( imageID ); currentResource = input; if ( IL_TRUE == ilLoadF( ilTypeFromExt( codecType ), input ) ) { image = malloc( sizeof(TImage) ); image->version = GUCEF_IMAGE_TIMAGE_VERSION; image->imageInfo.version = GUCEF_IMAGE_TIMAGEINFO_VERSION; frameCount = image->imageInfo.nrOfFramesInImage = (UInt32) ilGetInteger( IL_NUM_IMAGES ); if ( frameCount == 0 ) { /* DevIL returns a image count of 0 for single-image images */ frameCount = image->imageInfo.nrOfFramesInImage = 1; } image->frames = (TImageFrame*) malloc( frameCount * sizeof( TImageFrame ) ); /* Only 1 layer is supported atm */ ilActiveLayer( 0 ); for ( i=0; i<frameCount; ++i ) { TImageFrame* imageFrame = &image->frames[ i ]; imageFrame->version = GUCEF_IMAGE_TIMAGEFRAME_VERSION; /* activate the frame */ ilActiveImage( i ); /* init the TImageFrameInfo section */ imageFrame->frameInfo.version = GUCEF_IMAGE_TIMAGEFRAMEINFO_VERSION; mipmapCount = imageFrame->frameInfo.nrOfMipmapLevels = (UInt32) ilGetInteger( IL_NUM_MIPMAPS ); if ( mipmapCount == 0 ) { /* DevIL returns a mipmap count of 0 images without mipmapping, we use 0 for the base image */ mipmapCount = imageFrame->frameInfo.nrOfMipmapLevels = 1; } imageFrame->mipmapLevel = (TImageMipMapLevel*) malloc( mipmapCount * sizeof(TImageMipMapLevel) ); for ( n=0; n<mipmapCount; ++n ) { TImageMipMapLevel* mipmapLevel = &imageFrame->mipmapLevel[ n ]; mipmapLevel->version = GUCEF_IMAGE_TIMAGEMIPMAPLEVEL_VERSION; /* activate the mip-map */ ilActiveMipmap( n ); // Converted paletted images if( ilGetInteger( IL_IMAGE_FORMAT ) == IL_COLOUR_INDEX ) { ilConvertImage( IL_BGRA, IL_UNSIGNED_BYTE ); } /* init the TImageMipMapLevelInfo section */ mipmapLevel->mipLevelInfo.version = GUCEF_IMAGE_TIMAGEMIPMAPLEVELINFO_VERSION; mipmapLevel->mipLevelInfo.pixelComponentDataType = DATATYPE_UINT8; /* DevIL only supports this type */ mipmapLevel->mipLevelInfo.frameHeight = ilGetInteger( IL_IMAGE_HEIGHT ); mipmapLevel->mipLevelInfo.frameWidth = ilGetInteger( IL_IMAGE_WIDTH ); mipmapLevel->mipLevelInfo.pixelStorageFormat = ConvertILPixelFormatToGUCEFPixelFormat( ilGetInteger( IL_IMAGE_FORMAT ) ); /* now we grab the pixel data */ ilCompressFunc( IL_COMPRESS_NONE ); mipmapLevel->pixelDataSizeInBytes = ilGetInteger( IL_IMAGE_SIZE_OF_DATA ); mipmapLevel->pixelData = malloc( mipmapLevel->pixelDataSizeInBytes ); memcpy( mipmapLevel->pixelData, ilGetData(), mipmapLevel->pixelDataSizeInBytes ); } } } /* * the image has been loaded into our GUCEF structures so we have no need for * DevIL to store the data any more */ ilDeleteImage( imageID ); *imageOutput = image; currentResource = NULL; return 1; }