Revision: 391
http://hdrflow.svn.sourceforge.net/hdrflow/?rev=391&view=rev
Author: glslang
Date: 2008-01-01 09:55:53 -0800 (Tue, 01 Jan 2008)
Log Message:
-----------
+ little bit more wic
Modified Paths:
--------------
trunk/lib/extras/src/wic/wic.cpp
Modified: trunk/lib/extras/src/wic/wic.cpp
===================================================================
--- trunk/lib/extras/src/wic/wic.cpp 2007-12-30 21:21:49 UTC (rev 390)
+++ trunk/lib/extras/src/wic/wic.cpp 2008-01-01 17:55:53 UTC (rev 391)
@@ -15,6 +15,7 @@
#include <openlibraries_global_config.hpp>
#endif
+#include <atlbase.h>
#include <wincodec.h>
#include <wincodecsdk.h>
@@ -38,31 +39,32 @@
im = il::allocate( L"r32g32b32a32f", width, height );
pitch = im->pitch( ) * sizeof( float );
}
+ else if( guid == GUID_WICPixelFormat128bppRGBFloat )
+ {
+ }
return im;
}
il::image_type_ptr load_wic( const pl::string& uri )
{
-# define SAFE_RELEASE( p ) { if( p ) { p->Release( ); p = NULL; } }
-
il::image_type_ptr im;
- IWICImagingFactory* wic_factory = NULL;
- IWICBitmapDecoder* decoder = NULL;
- IWICBitmapFrameDecode* frame = NULL;
+ CComPtr<IWICImagingFactory> wic_factory;
+ CComPtr<IWICBitmapDecoder> decoder;
+ CComPtr<IWICBitmapFrameDecode> frame;
HRESULT hr = CoCreateInstance( CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, IID_IWICImagingFactory, ( LPVOID* ) &wic_factory );
if( FAILED( hr ) )
- goto error;
+ return im;
hr = wic_factory->CreateDecoderFromFilename( pl::to_wstring( uri ).c_str( ), NULL, GENERIC_READ, WICDecodeMetadataCacheOnDemand, &decoder );
if( FAILED( hr ) )
- goto error;
+ return im;
hr = decoder->GetFrame( 0, &frame );
if( FAILED( hr ) )
- goto error;
+ return im;
IWICBitmapSource* source = ( IWICBitmapSource* ) frame;
UINT width;
@@ -74,16 +76,12 @@
UINT pitch;
im = GUID_to_pf( pixelformat, width, height, pitch );
+ if( !im )
+ return im;
+
hr = source->CopyPixels( NULL, pitch, im->size( ), im->data( ) );
- error:
- SAFE_RELEASE( decoder );
- SAFE_RELEASE( wic_factory );
- SAFE_RELEASE( frame );
-
return im;
-
-# undef SAFE_RELEASE
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|