#pragma once

#include "stdafx.hpp"
#include "basedecoder.hpp"
#include "regman.hpp"

// #include "../pvrlib/PVRTTexture.h"

extern const GUID CLSID_CNG_Container;
extern const GUID CLSID_CNG_Decoder;

namespace cngx
{
	using namespace wicx;

	class CNG_FrameDecode : public BaseFrameDecode
	{
	public:
		CNG_FrameDecode(IWICImagingFactory *pIFactory, UINT num);
		HRESULT LoadImage(IStream *pIStream);

	private:
		HRESULT FillBitmapSource( UINT width, UINT height, REFWICPixelFormatGUID pixelFormat,
			UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer );
	};

	class CNG_Decoder : public BaseDecoder
	{
	public:
		static void Register( RegMan &regMan );

		CNG_Decoder();
		~CNG_Decoder();

		// IWICBitmapDecoder interface

		STDMETHOD( QueryCapability )( 
			/* [in] */ IStream *pIStream,
			/* [out] */ DWORD *pCapability );

		STDMETHOD( Initialize )( 
			/* [in] */ IStream *pIStream,
			/* [in] */ WICDecodeOptions cacheOptions );

	protected:
		virtual CNG_FrameDecode* CreateNewDecoderFrame( IWICImagingFactory *factory , UINT i );
	};
}
