当前位置: 首页>>代码示例>>C++>>正文


C++ IWICBitmapDecoder类代码示例

本文整理汇总了C++中IWICBitmapDecoder的典型用法代码示例。如果您正苦于以下问题:C++ IWICBitmapDecoder类的具体用法?C++ IWICBitmapDecoder怎么用?C++ IWICBitmapDecoder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了IWICBitmapDecoder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CreateProgressiveCtrlFromFile

HRESULT DemoApp::CreateProgressiveCtrlFromFile(HWND hWnd)
{
    HRESULT hr = S_OK;

    WCHAR szFileName[MAX_PATH];

    // Create the open dialog box and locate the image file
    if (LocateImageFile(hWnd, szFileName, ARRAYSIZE(szFileName)))
    {
        // Create a decoder
        IWICBitmapDecoder *pDecoder = NULL;

        hr = m_pIWICFactory->CreateDecoderFromFilename(
            szFileName,                      // Image to be decoded
            NULL,                            // Do not prefer a particular vendor
            GENERIC_READ,                    // Desired read access to the file
            WICDecodeMetadataCacheOnDemand,  // Cache metadata when needed
            &pDecoder                        // Pointer to the decoder
            );

        // Retrieve the first frame of the image from the decoder
        if (SUCCEEDED(hr))
        {
            // Need to release the previously source bitmap.
            // For each new image file, we need to create a new source bitmap
            SafeRelease(m_pSourceFrame);
            hr = pDecoder->GetFrame(0, &m_pSourceFrame);
        }

        IWICProgressiveLevelControl *pProgressive = NULL;

        if (SUCCEEDED(hr))
        {
            // Query for Progressive Level Control Interface
            hr = m_pSourceFrame->QueryInterface(IID_PPV_ARGS(&pProgressive));

            // Update progressive level count and reset the current level
            if (SUCCEEDED(hr))
            {
                m_uCurrentLevel = 0;
                hr = pProgressive->GetLevelCount(&m_uLevelCount);
            }
            else
            {
                MessageBox(hWnd, L"Image has no progressive encoding, select another one.", L"Application Error", 
                    MB_ICONEXCLAMATION | MB_OK);
            }
        }
        else
        {
            MessageBox(hWnd, L"Failed to load image, select another one.", L"Application Error", 
                MB_ICONEXCLAMATION | MB_OK);
        }

        SafeRelease(pDecoder);
        SafeRelease(pProgressive);
    }

    return hr;
}
开发者ID:Essjay1,项目名称:Windows-classic-samples,代码行数:60,代码来源:WICProgressiveDecoding.cpp

示例2: Buffer

Image::Buffer * WIC::Api::CreateImage(char * buffer, unsigned bufferLength)
{
	if(!factory) return 0;

	// Create input stream for memory
	IWICStream * stream = 0;
	factory->CreateStream(&stream);
	if(!stream) return 0;

	stream->InitializeFromMemory((unsigned char*)(buffer), static_cast<DWORD>(bufferLength));

	IWICBitmapDecoder * decoder = 0;
	factory->CreateDecoderFromStream(stream, 0, WICDecodeMetadataCacheOnDemand, &decoder);
	if(!decoder) return 0;

	IWICBitmapFrameDecode * bitmapSource = 0;
	decoder->GetFrame(0, &bitmapSource);
	if(!bitmapSource)
	{
		decoder->Release();
		return 0;
	}

	IWICBitmapSource * convertedSource = 0;
	WICConvertBitmapSource(GUID_WICPixelFormat32bppRGBA, bitmapSource, &convertedSource);
	bitmapSource->Release();
	if(!convertedSource)
	{
		decoder->Release();
		return 0;
	}

	// Create the bitmap from the image frame.
	IWICBitmap * bitmap = 0;
	factory->CreateBitmapFromSource(
		convertedSource,         // Create a bitmap from the image frame
		WICBitmapCacheOnDemand,  // Cache metadata when needed
		&bitmap);                // Pointer to the bitmap

	convertedSource->Release();
	decoder->Release();

	if(!bitmap) return 0;

	unsigned width = 0, height = 0;
	bitmap->GetSize(&width, &height);
	WICRect lockRect = { 0, 0, width, height };

	IWICBitmapLock * lock = 0;
	bitmap->Lock(&lockRect, WICBitmapLockWrite, &lock);
	if(!lock)
	{
		bitmap->Release();
		return 0;
	}

	return new WIC::Buffer(bitmap, lock, width, height);
}
开发者ID:DashW,项目名称:Ingenuity,代码行数:58,代码来源:WICImageApi.cpp

示例3: CoCreateInstance

SpriteSheet::SpriteSheet(wchar_t* filename, Graphics* gfx)
{
	this->gfx = gfx;
	bmp = NULL;
	HRESULT hr;

	//create a wic factory 
	IWICImagingFactory *wicFactory = NULL;
	hr = CoCreateInstance(
		CLSID_WICImagingFactory,
		NULL,
		CLSCTX_INPROC_SERVER,
		IID_IWICImagingFactory,
		(LPVOID*)&wicFactory);

	//create a decoder
	IWICBitmapDecoder *wicDecoder = NULL;
	hr = wicFactory->CreateDecoderFromFilename(
		filename,       // THE FILE NAME
		NULL,           // the preferred vendor
		GENERIC_READ,   // we're reading the file, not writing
		WICDecodeMetadataCacheOnLoad,
		&wicDecoder);

	// read a frame from the image
	IWICBitmapFrameDecode* wicFrame = NULL;
	hr = wicDecoder->GetFrame(0, &wicFrame);

	// create a converter
	IWICFormatConverter *wicConverter = NULL;
	hr = wicFactory->CreateFormatConverter(&wicConverter);

	// setup the converter
	hr = wicConverter->Initialize(
		wicFrame,                      // frame
		GUID_WICPixelFormat32bppPBGRA, // pixel format
		WICBitmapDitherTypeNone,       // irrelevant
		NULL,             // no palette needed, irrlevant
		0.0,              // alpha transparency % irrelevant
		WICBitmapPaletteTypeCustom     // irrelevant
		);

	// use the converter to create an D2D1Bitmap
	/// ID2D1Bitmap* bmp;      // this will be a member variable
	hr = gfx->GetRenderTarget()->CreateBitmapFromWicBitmap(
		wicConverter,      // converter
		NULL,              // D2D1_BITMAP_PROPERIES
		&bmp               // destiatnion D2D1 bitmap
		);

	if (wicFactory) wicFactory->Release();
	if (wicDecoder) wicDecoder->Release();
	if (wicConverter) wicConverter->Release();
	if (wicFrame) wicFrame->Release();

}
开发者ID:SneakyRopes,项目名称:Sneaky-Ropes-v3,代码行数:56,代码来源:SpriteSheet.cpp

示例4: createStreamFromBytes

HBITMAP ImageDecoder::loadImage(unsigned char *bytes, int size)
{
	IWICStream *stream = createStreamFromBytes(bytes, size);
	IWICBitmapDecoder *decoder = createDecoderFromStream(stream);

	HBITMAP bitmap = loadImage(decoder);

	decoder->Release();
	stream->Release();

	return bitmap;
}
开发者ID:0359xiaodong,项目名称:whatsapp-viewer,代码行数:12,代码来源:ImageDecoder.cpp

示例5:

HRESULT d2d::LoadBitmap (
	const wchar_t* filename,
	IWICImagingFactory* wic,
	ID2D1RenderTarget* rt,
	ID2D1Bitmap **bitmap )
{
	HRESULT hr = S_OK;
	IWICBitmapFrameDecode *frame = nullptr;
	IWICBitmapDecoder *decoder = nullptr;
	IWICFormatConverter *conv = nullptr;
 
	// 디코더 생성
	hr = wic->CreateDecoderFromFilename (
			filename,
			0,
			GENERIC_READ,
			WICDecodeMetadataCacheOnDemand,
			&decoder );
 
	// 프레임 얻기
	if(SUCCEEDED(hr))
		hr = decoder->GetFrame (0, &frame);
 
	// 변환기 생성
	if(SUCCEEDED(hr))
		hr = wic->CreateFormatConverter(&conv);
	
	// 변환기 초기화
	if(SUCCEEDED(hr))
		hr = conv->Initialize (
				frame,
				GUID_WICPixelFormat32bppPBGRA,
				WICBitmapDitherTypeNone,
				0,
				1.0f,
				WICBitmapPaletteTypeCustom );
 
	// 비트맵 생성
	if(SUCCEEDED(hr))
		hr = rt->CreateBitmapFromWicBitmap (
				conv,
				bitmap );
	
	// 해제
	d2d::SafeRelease(frame);
	d2d::SafeRelease(decoder);
	d2d::SafeRelease(conv);
 
	// 결과 반환
	return hr;
}
开发者ID:KimHeeKue,项目名称:Unipen,代码行数:51,代码来源:d2dutils.cpp

示例6: SafeRelease

//从一个文件加载图片
ID2D1Bitmap* d2d::CreateBitmapFromFile(wstring strFileName)
{
    IWICBitmapDecoder *pDecoder = nullptr;
    HRESULT hr = m_pWICFactory->CreateDecoderFromFilename(strFileName.c_str(), NULL, GENERIC_READ,
                                                          WICDecodeMetadataCacheOnLoad, //enum WICDecodeOptions
                                                          &pDecoder);

    if (FAILED(hr))
    {
        return nullptr;
    }

     // Create the initial frame.
    IWICBitmapFrameDecode *pSource = nullptr;
    hr = pDecoder->GetFrame(0, &pSource);
    if (FAILED(hr))
    {
        return nullptr;
    }

    //转换器
    IWICFormatConverter *pConverter = nullptr;
    hr = m_pWICFactory->CreateFormatConverter(&pConverter);
    if (FAILED(hr))
    {
        return nullptr;
    }

    hr = pConverter->Initialize(pSource, GUID_WICPixelFormat32bppPBGRA, WICBitmapDitherTypeNone,
                                NULL, 0.f, WICBitmapPaletteTypeMedianCut);
 
    if (FAILED(hr))
    {
        return nullptr;
    }
    
    // Create a Direct2D bitmap from the WIC bitmap.
    ID2D1Bitmap* picBitmap = nullptr;
    hr = m_pRenderTarget->CreateBitmapFromWicBitmap(pConverter, NULL, &picBitmap);
    if (FAILED(hr))
    {
        return nullptr;
    }

    SafeRelease(pDecoder);
    SafeRelease(pSource);
    SafeRelease(pConverter);

    return picBitmap;
}
开发者ID:wangzhimin,项目名称:WzmPoker,代码行数:51,代码来源:d2d.cpp

示例7: LoadLocalPNG

HBITMAP LoadLocalPNG( const std::string& sPath, const RASize& sz )
{
	SetCurrentDirectory( Widen( g_sHomeDir ).c_str() );

	ASSERT( _FileExists( sPath ) );
	if( !_FileExists( sPath ) )
	{
		RA_LOG( "File could not be found: %s\n", sPath.c_str() );
		return nullptr;
	}

	HBITMAP hRetVal = nullptr;
	// Step 2: Decode the source image to IWICBitmapSource
	IWICBitmapDecoder* pDecoder = nullptr;
	HRESULT hr = g_UserImageFactoryInst.m_pIWICFactory->CreateDecoderFromFilename( Widen( sPath ).c_str(),			// Image to be decoded
																				   nullptr,							// Do not prefer a particular vendor
																				   GENERIC_READ,					// Desired read access to the file
																				   WICDecodeMetadataCacheOnDemand,	// Cache metadata when needed
																				   &pDecoder );						// Pointer to the decoder
	
	// Retrieve the first frame of the image from the decoder
	IWICBitmapFrameDecode* pFrame = nullptr;
	if( SUCCEEDED( hr ) )
		hr = pDecoder->GetFrame( 0, &pFrame );

	// Retrieve IWICBitmapSource from the frame
	if( SUCCEEDED( hr ) )
	{
		SAFE_RELEASE( g_UserImageFactoryInst.m_pOriginalBitmapSource );	//##SD ???
		pFrame->QueryInterface( IID_IWICBitmapSource, reinterpret_cast<void**>( &g_UserImageFactoryInst.m_pOriginalBitmapSource ) );
	}

	// Step 3: Scale the original IWICBitmapSource to the client rect size
	// and convert the pixel format
	IWICBitmapSource* pToRenderBitmapSource = nullptr;
	if( SUCCEEDED( hr ) )
		hr = ConvertBitmapSource( { 0, 0, sz.Width(), sz.Height() }, pToRenderBitmapSource );

	// Step 4: Create a DIB from the converted IWICBitmapSource
	if( SUCCEEDED( hr ) )
		hr = UserImageFactory_CreateDIBSectionFromBitmapSource( pToRenderBitmapSource, hRetVal );

	SAFE_RELEASE( pToRenderBitmapSource );
	SAFE_RELEASE( pDecoder );
	SAFE_RELEASE( pFrame );
	SAFE_RELEASE( g_UserImageFactoryInst.m_pOriginalBitmapSource );
	
	return hRetVal;
}
开发者ID:ddugovic,项目名称:RASuite,代码行数:49,代码来源:RA_ImageFactory.cpp

示例8: LoadBitmapFromStream

// Loads a PNG image from the specified stream (using Windows Imaging Component).
IWICBitmapSource * LoadBitmapFromStream(IStream * ipImageStream)
{
	// initialize return value
	IWICBitmapSource * ipBitmap = NULL;

	// load WIC's PNG decoder
	IWICBitmapDecoder * ipDecoder = NULL;
	IID i = IID_IWICBitmapDecoder;

	if (FAILED(CoCreateInstance(CLSID_WICPngDecoder, NULL, CLSCTX_INPROC_SERVER,
		i,//__uuidof(ipDecoder)

		(void **)&ipDecoder)))
		goto Return;


	// load the PNG
	if (FAILED(ipDecoder->Initialize(ipImageStream, WICDecodeMetadataCacheOnLoad)))
		goto ReleaseDecoder;

	// check for the presence of the first frame in the bitmap
	UINT nFrameCount = 0;

	if (FAILED(ipDecoder->GetFrameCount(&nFrameCount)) || nFrameCount != 1)
		goto ReleaseDecoder;

	// load the first frame (i.e., the image)
	IWICBitmapFrameDecode * ipFrame = NULL;

	if (FAILED(ipDecoder->GetFrame(0, &ipFrame)))
		goto ReleaseDecoder;


	// convert the image to 32bpp BGRA format with pre-multiplied alpha
	//   (it may not be stored in that format natively in the PNG resource,
	//   but we need this format to create the DIB to use on-screen)
	WICConvertBitmapSource(GUID_WICPixelFormat32bppPBGRA, ipFrame, &ipBitmap);
	ipFrame->Release();

ReleaseDecoder:
	ipDecoder->Release();

Return:
	return ipBitmap;

}
开发者ID:RaMMicHaeL,项目名称:winspy,代码行数:47,代码来源:LoadPNG.cpp

示例9: SetCoverFromFolder

/// <summary>
/// Tries to get the cover from the specified folder.
/// </summary>
/// <param name="filePath">Path to the file to get the cover from.</param>
bool CoverArt::SetCoverFromFolder(LPCWSTR filePath)
{
    WCHAR folderPath[MAX_PATH] = {0};
    IWICImagingFactory *factory = nullptr;
    IWICBitmapDecoder *decoder = nullptr;
    IWICBitmapFrameDecode *source = nullptr;
    HRESULT hr = E_FAIL;

    StringCchCopyW(folderPath, _countof(folderPath), filePath);
    PathRemoveFileSpecW(folderPath);

    // Check each covername
    WCHAR artPath[MAX_PATH];
    for (auto &canidate : mFolderCanidates)
    {
        StringCchPrintfW(artPath, _countof(artPath), L"%s\\%s", folderPath, canidate.c_str());
        for (auto &file : FileIterator(artPath))
        {
            StringCchPrintfW(artPath, _countof(artPath), L"%s\\%s", folderPath, file.cFileName);

            hr = Factories::GetWICFactory(reinterpret_cast<LPVOID*>(&factory));
            if (SUCCEEDED(hr))
            {
                hr = factory->CreateDecoderFromFilename(artPath, nullptr, GENERIC_READ, WICDecodeMetadataCacheOnDemand, &decoder);
            }
            if (SUCCEEDED(hr))
            {
                hr = decoder->GetFrame(0, &source);
            }
            if (SUCCEEDED(hr))
            {
                SendMessage(gLSModule.GetMessageWindow(), WM_COVERARTUPDATE, (WPARAM)this, (LPARAM)source);
            }

            SAFERELEASE(decoder);

            if (SUCCEEDED(hr))
            {
                return true;
            }
        }
    }
    
    return false;
}
开发者ID:Superxwolf,项目名称:nModules,代码行数:49,代码来源:CoverArt.cpp

示例10: LoadBitmapFromFile

// =========================================================
// Load the specified bitmap from file into D2D bitmap
// =========================================================
BOOL Loader::LoadBitmapFromFile(LPCWSTR filename, const Graphics* graphicsWrapper, ID2D1Bitmap** ppBitmap)
{
	if (!isInitialized)
		return FALSE;

	HRESULT hr;

	IWICBitmapDecoder *pDecoder = NULL;
	IWICBitmapFrameDecode *pSource = NULL;
	IWICFormatConverter *pConverter = NULL;

	hr = pFactory->CreateDecoderFromFilename(filename, NULL, GENERIC_READ, WICDecodeMetadataCacheOnDemand, &pDecoder);
	CHECK(failedDecoder);

	hr = pDecoder->GetFrame(0, &pSource);
	CHECK(failedGetFrame);

	hr = pFactory->CreateFormatConverter(&pConverter);
	CHECK(failedConverter);

	hr = pConverter->Initialize(pSource, GUID_WICPixelFormat32bppPBGRA, WICBitmapDitherTypeNone, NULL, 0.0, WICBitmapPaletteTypeMedianCut);
	CHECK(failedConversion);

	hr = graphicsWrapper->pRenderTarget->CreateBitmapFromWicBitmap(pSource, ppBitmap);
	CHECK(failedBitmap);

	return TRUE;

failedBitmap:
	OutputDebugStringA("Loader::LoadBitmapFromFile -> Failed to create bitmap.\n");
failedConversion:
	pConverter->Release();
	OutputDebugStringA("Loader::LoadBitmapFromFile -> Failed to initialise format converter.\n");
failedConverter:
	pSource->Release();
	OutputDebugStringA("Loader::LoadBitmapFromFile -> Failed to create format converter.\n");
failedGetFrame:
	pDecoder->Release();
	OutputDebugStringA("Loader::LoadBitmapFromFile -> Failed to get frame 0 from source bitmap.\n");
failedDecoder:
	OutputDebugStringA("Loader::LoadBitmapFromFile -> Failed to create bitmap decoder.\n");
	return FALSE;
}
开发者ID:beelee93,项目名称:MinesweeperDX,代码行数:46,代码来源:Loader.cpp

示例11: buildWcharString

HBITMAP ImageDecoder::loadImage(const std::string &filename)
{
	WCHAR *wcharFilename = buildWcharString(filename);
	IWICBitmapDecoder *decoder = NULL;
	HRESULT result = factory->CreateDecoderFromFilename(wcharFilename, NULL, GENERIC_READ, WICDecodeMetadataCacheOnDemand, &decoder);

	delete[] wcharFilename;

	if (FAILED(result))
	{
		throw Exception("could not create decoder");
	}

	HBITMAP bitmap = loadImage(decoder);

	decoder->Release();

	return bitmap;
}
开发者ID:0359xiaodong,项目名称:whatsapp-viewer,代码行数:19,代码来源:ImageDecoder.cpp

示例12:

HRESULT CAshaD2D::CreateD2DBitmapFromFile(HWND hWnd)
{
	HRESULT hr = S_OK;

	WCHAR szFileName[MAX_PATH];

	// Step 1: Create the open dialog box and locate the image file
	if (OpenFile(hWnd, szFileName, ARRAYSIZE(szFileName)))
	{
		// Step 2: Decode the source image

		// Create a decoder
		IWICBitmapDecoder *pDecoder = NULL;

		hr = m_pWICImgFactory->CreateDecoderFromFilename(
			szFileName,                      // Image to be decoded
			NULL,                            // Do not prefer a particular vendor
			GENERIC_READ,                    // Desired read access to the file
			WICDecodeMetadataCacheOnDemand,  // Cache metadata when needed
			&pDecoder                        // Pointer to the decoder
			);

		// Retrieve the first frame of the image from the decoder
		//IWICBitmapFrameDecode *pFrame = NULL;

		if (SUCCEEDED(hr))
		{
			SafeRelease(&m_pFrame);
			hr = pDecoder->GetFrame(0, &m_pFrame);
		}

		


		//SafeRelease(&pfmatCoverter);
		SafeRelease(&pDecoder);
		//SafeRelease(&pFrame);
	}

	return hr;
}
开发者ID:lazyrohan,项目名称:Asha,代码行数:41,代码来源:CAshaD2D.cpp

示例13:

// ----------------------------------------------------------------
//	LoadResource
// ----------------------------------------------------------------
bool CD2DBitmap::LoadResource( ResourceId id )
{
	ID2D1HwndRenderTarget * renderTarget = CD2DRenderer::GetInstance().GetHwndRenderTarget();
	IWICImagingFactory * imagingFactory = CD2DRenderer::GetInstance().GetImagingFactory();

	IWICBitmapDecoder * bitmapDecoder = nullptr;
	IWICBitmapFrameDecode* bitmapFrameDecode = nullptr;

	imagingFactory->CreateDecoderFromFilename( id.c_str(), nullptr, GENERIC_READ, WICDecodeMetadataCacheOnDemand, &bitmapDecoder );
	bitmapDecoder->GetFrame( 0, &bitmapFrameDecode );

	imagingFactory->CreateFormatConverter( &m_FmtConverter );
	m_FmtConverter->Initialize( bitmapFrameDecode, GUID_WICPixelFormat32bppPBGRA, WICBitmapDitherTypeNone, nullptr, 0.0f, WICBitmapPaletteTypeCustom );

	renderTarget->CreateBitmapFromWicBitmap( m_FmtConverter, nullptr, &m_D2DBitmap );

	SafeRelease( bitmapDecoder );
	SafeRelease( bitmapFrameDecode );

	return true;
}
开发者ID:LeeInJae,项目名称:meteor,代码行数:24,代码来源:D2DBitmap.cpp

示例14: SHCreateMemStream

void GL::Image::load(const unsigned char *buf, size_t bufSize)
{
    if (CoInitializeEx(NULL, COINIT_MULTITHREADED) != S_OK) {
        // bad!
        return;
    }
    IStream *stream = SHCreateMemStream((const BYTE*)buf, (UINT)bufSize);
    if (stream != NULL) {
        IWICImagingFactory *pFactory;
        if (CoCreateInstance(CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, IID_IWICImagingFactory, (LPVOID*)&pFactory) == S_OK) {
            IWICBitmapDecoder *pDecoder;
            if (pFactory->CreateDecoderFromStream(stream, &CLSID_WICPngDecoder, WICDecodeMetadataCacheOnDemand, &pDecoder) == S_OK) {
                IWICBitmapFrameDecode *frame;
                if (pDecoder->GetFrame(0, &frame) == S_OK) {
                    UINT w, h;
                    if (frame->GetSize(&w, &h) == S_OK) {
                        width_ = w;
                        height_ = h;
                    }
                    IWICFormatConverter *formatConverter;
                    if (pFactory->CreateFormatConverter(&formatConverter) == S_OK) {
                        if (formatConverter->Initialize(frame, GUID_WICPixelFormat32bppPBGRA, WICBitmapDitherTypeNone, nullptr, 0.0, WICBitmapPaletteTypeCustom) == S_OK) {
                            unsigned char *pixels = new unsigned char[w * h * 4];
                            if (formatConverter->CopyPixels(0, w * 4, w * h * 4, pixels) == S_OK) {
                                loadTextureData_(pixels);
                            }
                            delete[] pixels;
                        }
                        formatConverter->Release();
                    }
                }
                pDecoder->Release();
            }
            pFactory->Release();
        }
        stream->Release();
    }
    CoUninitialize();
}
开发者ID:MaddTheSane,项目名称:Glypha,代码行数:39,代码来源:GLImage_Win32.cpp

示例15: loadResource

void ImageDecoder::loadGifFromResource(const WCHAR *name, const WCHAR *type, std::vector<AnimatedGifFrame *> &frames)
{
	unsigned char *bytes = NULL;
	DWORD size = 0;
	loadResource(name, type, bytes, size);

	IWICStream *stream = createStreamFromBytes(bytes, size);
	IWICBitmapDecoder *decoder = createDecoderFromStream(stream);

	unsigned int frameCount = 0;
	if (FAILED(decoder->GetFrameCount(&frameCount)))
	{
		throw Exception("could not get gif frame count");
	}

	if (frameCount <= 1)
	{
		throw Exception("not a gif animation");
	}

	for (unsigned int frameIndex = 0; frameIndex < frameCount; frameIndex++)
	{
		IWICBitmapFrameDecode *bitmapFrame = NULL;
		if (FAILED(decoder->GetFrame(frameIndex, &bitmapFrame)))
		{
			throw Exception("could not get frame");
		}

		HBITMAP bitmap = convertFrameToBitmap(bitmapFrame);
		bitmapFrame->Release();

		AnimatedGifFrame *frame = new AnimatedGifFrame(bitmap);
		frames.push_back(frame);

	}

	decoder->Release();
	stream->Release();
}
开发者ID:0359xiaodong,项目名称:whatsapp-viewer,代码行数:39,代码来源:ImageDecoder.cpp


注:本文中的IWICBitmapDecoder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。