├── .gitignore ├── LICENSE ├── README.md ├── build.bat ├── clean.bat ├── codec ├── LisaImage.cpp ├── LisaImage.h ├── PropertyStore.cpp ├── PropertyStore.h ├── StreamReader.cpp ├── StreamReader.h ├── StreamWriter.cpp ├── StreamWriter.h ├── WicBitmapDecoder.cpp ├── WicBitmapDecoder.h ├── WicBitmapEncoder.cpp ├── WicBitmapEncoder.h ├── WicCodec.def ├── WicCodec.filters ├── WicCodec.sln ├── WicCodec.vcxproj ├── WicCodec.vcxproj.filters ├── WicFrameDecode.cpp ├── WicFrameDecode.h ├── WicFrameEncode.cpp ├── WicFrameEncode.h ├── clean.bat ├── main.cpp ├── main.h ├── utils.h └── uuid.h ├── images ├── Donald_Trump.lisa └── Hello_Kitty.lisa ├── installer └── Setup-ExampleWicCodec.iss └── redistributables ├── x64 ├── msvcp120.dll └── msvcr120.dll └── x86 ├── msvcp120.dll └── msvcr120.dll /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.sln.docstates 8 | 9 | # Build results 10 | [Dd]ebug/ 11 | [Rr]elease/ 12 | # x64/ 13 | build/ 14 | [Bb]in/ 15 | [Oo]bj/ 16 | 17 | # MSTest test Results 18 | [Tt]est[Rr]esult*/ 19 | [Bb]uild[Ll]og.* 20 | 21 | *_i.c 22 | *_p.c 23 | *.exe 24 | *.ilk 25 | *.meta 26 | *.obj 27 | *.pch 28 | *.pdb 29 | *.pgc 30 | *.pgd 31 | *.rsp 32 | *.sbr 33 | *.tlb 34 | *.tli 35 | *.tlh 36 | *.tmp 37 | *.tmp_proj 38 | *.log 39 | *.VC.db 40 | *.VC.VC.opendb 41 | *.vspscc 42 | *.vssscc 43 | .builds 44 | *.pidb 45 | *.log 46 | *.scc 47 | 48 | # Visual C++ cache files 49 | .vs/ 50 | ipch/ 51 | *.aps 52 | *.ncb 53 | *.opensdf 54 | *.sdf 55 | *.cachefile 56 | 57 | # Visual Studio profiler 58 | *.psess 59 | *.vsp 60 | *.vspx 61 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 René Slijkhuis 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReneSlijkhuis/example-wic-codec/cfca2cac799b62b835f3174138505374e7456e73/README.md -------------------------------------------------------------------------------- /build.bat: -------------------------------------------------------------------------------- 1 | rem - Use: Developer Command Prompt VS2015 2 | 3 | cd installer 4 | del /F /S /Q Setup-ExampleWicCodec.exe 5 | cd .. 6 | 7 | cd codec 8 | MSBuild WicCodec.sln /t:Rebuild /p:Configuration=Release /p:Platform=x64 9 | MSBuild WicCodec.sln /t:Rebuild /p:Configuration=Release /p:Platform=x86 10 | cd .. 11 | 12 | cd installer 13 | "C:\Program Files (x86)\Inno Setup 5\ISCC.exe" Setup-ExampleWicCodec.iss 14 | cd .. 15 | -------------------------------------------------------------------------------- /clean.bat: -------------------------------------------------------------------------------- 1 | cd codec 2 | call clean.bat 3 | cd .. 4 | -------------------------------------------------------------------------------- /codec/LisaImage.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReneSlijkhuis/example-wic-codec/cfca2cac799b62b835f3174138505374e7456e73/codec/LisaImage.cpp -------------------------------------------------------------------------------- /codec/LisaImage.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // MIT License 4 | // 5 | // Copyright(c) 2017 René Slijkhuis 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in all 15 | // copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | // 25 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 26 | // 27 | // USAGE INSTRUCTIONS 28 | // 29 | // Include: 30 | // - LisaImage.h 31 | // 32 | // Link: 33 | // - gdiplus.lib 34 | // 35 | // Namespace: 36 | // - Wic::ImageFormat::Lisa 37 | // 38 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 39 | 40 | #pragma once 41 | 42 | #include 43 | #include 44 | #include 45 | 46 | #include 47 | 48 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 49 | 50 | namespace Wic { 51 | namespace ImageFormat { 52 | namespace Lisa { 53 | 54 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 55 | 56 | enum class PixelFormat 57 | { 58 | Unknown = 0, 59 | UInt8, 60 | RGB24 61 | }; 62 | 63 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 64 | 65 | class LisaImage 66 | { 67 | public: 68 | LisaImage( ); 69 | virtual ~LisaImage( ); 70 | 71 | bool Read( const std::wstring& filename ); 72 | bool Read( IStream* pStream ); 73 | bool Save( const std::wstring& filename ) const; 74 | bool Save( IStream* pStream ) const; 75 | 76 | bool SetImage( const UINT width, 77 | const UINT height, 78 | const PixelFormat pixelFormat, 79 | const std::vector& bytes ); 80 | 81 | void GetBytes( std::vector& bytes ) const; 82 | UINT GetWidth( ) const; 83 | UINT GetHeight( ) const; 84 | PixelFormat GetPixelFormat( ) const; 85 | static UINT GetBytesPerPixel( const PixelFormat pixelFormat ); 86 | 87 | private: 88 | PixelFormat ConvertPixelFormat( const UINT value ) const; 89 | UINT ConvertPixelFormat( const PixelFormat pixelFormat ) const; 90 | 91 | UINT m_width; 92 | UINT m_height; 93 | PixelFormat m_pixelFormat; 94 | std::vector m_bytes; 95 | }; 96 | 97 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 98 | 99 | } // namespace Lisa 100 | } // namespace ImageFormat 101 | } // namespace Wic 102 | 103 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -------------------------------------------------------------------------------- /codec/PropertyStore.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReneSlijkhuis/example-wic-codec/cfca2cac799b62b835f3174138505374e7456e73/codec/PropertyStore.cpp -------------------------------------------------------------------------------- /codec/PropertyStore.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReneSlijkhuis/example-wic-codec/cfca2cac799b62b835f3174138505374e7456e73/codec/PropertyStore.h -------------------------------------------------------------------------------- /codec/StreamReader.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReneSlijkhuis/example-wic-codec/cfca2cac799b62b835f3174138505374e7456e73/codec/StreamReader.cpp -------------------------------------------------------------------------------- /codec/StreamReader.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReneSlijkhuis/example-wic-codec/cfca2cac799b62b835f3174138505374e7456e73/codec/StreamReader.h -------------------------------------------------------------------------------- /codec/StreamWriter.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReneSlijkhuis/example-wic-codec/cfca2cac799b62b835f3174138505374e7456e73/codec/StreamWriter.cpp -------------------------------------------------------------------------------- /codec/StreamWriter.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReneSlijkhuis/example-wic-codec/cfca2cac799b62b835f3174138505374e7456e73/codec/StreamWriter.h -------------------------------------------------------------------------------- /codec/WicBitmapDecoder.cpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // MIT License 4 | // 5 | // Copyright(c) 2017 René Slijkhuis 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in all 15 | // copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | // 25 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 26 | 27 | #include "WicBitmapDecoder.h" 28 | #include "WicFrameDecode.h" 29 | #include "uuid.h" 30 | 31 | using namespace std; 32 | 33 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 34 | 35 | WicBitmapDecoder::WicBitmapDecoder( ) : 36 | m_index( 0 ) 37 | { 38 | InitializeCriticalSection( &m_criticalSection ); 39 | } 40 | 41 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 42 | 43 | WicBitmapDecoder::~WicBitmapDecoder( ) 44 | { 45 | DeleteCriticalSection( &m_criticalSection ); 46 | } 47 | 48 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 49 | #pragma region IUnknown 50 | 51 | HRESULT WicBitmapDecoder::QueryInterface( REFIID riid, void** ppObject ) 52 | { 53 | if ( ppObject == nullptr ) 54 | { 55 | return E_INVALIDARG; 56 | } 57 | 58 | *ppObject = nullptr; 59 | 60 | if ( !IsEqualGUID( riid, IID_IUnknown ) && !IsEqualGUID( riid, IID_IWICBitmapDecoder ) ) 61 | { 62 | return E_NOINTERFACE; 63 | } 64 | 65 | this->AddRef( ); 66 | *ppObject = static_cast( this ); 67 | return S_OK; 68 | } 69 | 70 | #pragma endregion 71 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 72 | #pragma region IWICBitmapDecoder_required 73 | 74 | HRESULT WicBitmapDecoder::QueryCapability( IStream* pIStream, DWORD* pCapability ) 75 | { 76 | if ( ( pIStream == nullptr ) || ( pCapability == nullptr ) ) 77 | { 78 | return E_INVALIDARG; 79 | } 80 | 81 | *pCapability = WICBitmapDecoderCapabilityCanDecodeSomeImages; 82 | 83 | return S_OK; 84 | } 85 | 86 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 87 | 88 | HRESULT WicBitmapDecoder::Initialize( IStream* pIStream, WICDecodeOptions /*cacheOptions*/ ) 89 | { 90 | if ( pIStream == nullptr ) 91 | { 92 | return E_INVALIDARG; 93 | } 94 | 95 | SectionLock l( &m_criticalSection ); 96 | 97 | pIStream->AddRef( ); 98 | m_pIStream.reset( pIStream ); 99 | m_index = 0; 100 | 101 | if ( m_frame.Ptr( ) != nullptr ) 102 | { 103 | return WINCODEC_ERR_WRONGSTATE; 104 | } 105 | 106 | ComPtr newWicFrame; 107 | if ( WicFrameDecode::CreateFromStream( m_pIStream.Ptr( ), &newWicFrame, m_index ) != S_OK ) 108 | { 109 | return WINCODEC_ERR_WRONGSTATE; 110 | } 111 | 112 | m_frame.reset( newWicFrame.AddRef( ) ); 113 | 114 | if ( m_frame.Ptr( ) == nullptr ) 115 | { 116 | return WINCODEC_ERR_WRONGSTATE; 117 | } 118 | 119 | return S_OK; 120 | } 121 | 122 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 123 | 124 | HRESULT WicBitmapDecoder::GetContainerFormat( GUID* pGuidContainerFormat ) 125 | { 126 | if ( pGuidContainerFormat == nullptr ) 127 | { 128 | return E_INVALIDARG; 129 | } 130 | 131 | *pGuidContainerFormat = GUID_ContainerFormat; 132 | 133 | return S_OK; 134 | } 135 | 136 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 137 | 138 | HRESULT WicBitmapDecoder::GetDecoderInfo( IWICBitmapDecoderInfo** ppIDecoderInfo ) 139 | { 140 | HRESULT hr; 141 | ComPtr factory; 142 | 143 | { 144 | SectionLock l( &m_criticalSection ); 145 | 146 | if ( m_factory.Ptr( ) == nullptr ) 147 | { 148 | hr = CoCreateInstance( CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, IID_IWICImagingFactory, (LPVOID*) m_factory.get_out_storage( ) ); 149 | if ( FAILED( hr ) ) 150 | { 151 | return hr; 152 | } 153 | } 154 | 155 | factory.reset( m_factory.AddRef( ) ); 156 | } 157 | 158 | ComPtr componentInfo; 159 | 160 | hr = factory->CreateComponentInfo( CLSID_WicBitmapDecoder, componentInfo.get_out_storage( ) ); 161 | if ( FAILED( hr ) ) 162 | { 163 | return hr; 164 | } 165 | 166 | hr = componentInfo->QueryInterface( IID_IWICBitmapDecoderInfo, (void**) ppIDecoderInfo ); 167 | if ( FAILED( hr ) ) 168 | { 169 | return hr; 170 | } 171 | 172 | return S_OK; 173 | } 174 | 175 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 176 | 177 | HRESULT WicBitmapDecoder::GetFrameCount( UINT* pCount ) 178 | { 179 | if ( pCount == nullptr ) 180 | { 181 | return E_INVALIDARG; 182 | } 183 | 184 | *pCount = 1; 185 | 186 | return S_OK; 187 | } 188 | 189 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 190 | 191 | HRESULT WicBitmapDecoder::GetFrame( UINT index, IWICBitmapFrameDecode** ppIBitmapFrame ) 192 | { 193 | if ( ppIBitmapFrame == nullptr ) 194 | { 195 | return E_INVALIDARG; 196 | } 197 | 198 | SectionLock l( &m_criticalSection ); 199 | 200 | if ( index >= 1 ) 201 | { 202 | return WINCODEC_ERR_FRAMEMISSING; 203 | } 204 | 205 | if ( index != m_index ) 206 | { 207 | ComPtr newWicFrame; 208 | if ( WicFrameDecode::CreateFromStream( m_pIStream.Ptr( ), &newWicFrame, index ) != S_OK ) 209 | { 210 | return WINCODEC_ERR_WRONGSTATE; 211 | } 212 | 213 | m_frame.reset( newWicFrame.AddRef( ) ); 214 | m_index = index; 215 | } 216 | 217 | if ( m_frame.Ptr( ) == nullptr ) 218 | { 219 | // No initialize done 220 | return WINCODEC_ERR_FRAMEMISSING; 221 | } 222 | 223 | *ppIBitmapFrame = m_frame.AddRef( ); 224 | 225 | return S_OK; 226 | } 227 | 228 | #pragma endregion 229 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 230 | #pragma region IWICBitmapDecoder_optional 231 | 232 | HRESULT WicBitmapDecoder::GetPreview( IWICBitmapSource** /*ppIBitmapSource*/ ) 233 | { 234 | return WINCODEC_ERR_UNSUPPORTEDOPERATION; 235 | } 236 | 237 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 238 | 239 | HRESULT WicBitmapDecoder::GetThumbnail( IWICBitmapSource** /*ppIThumbnail*/ ) 240 | { 241 | return WINCODEC_ERR_CODECNOTHUMBNAIL; 242 | } 243 | 244 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 245 | 246 | HRESULT WicBitmapDecoder::GetColorContexts( UINT /*cCount*/, IWICColorContext** /*ppIColorContexts*/, UINT* /*pcActualCount*/ ) 247 | { 248 | return WINCODEC_ERR_UNSUPPORTEDOPERATION; 249 | } 250 | 251 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 252 | 253 | HRESULT WicBitmapDecoder::GetMetadataQueryReader( IWICMetadataQueryReader** ppIMetadataQueryReader ) 254 | { 255 | if ( m_frame.Ptr( ) == nullptr ) 256 | { 257 | // No initialize done 258 | return WINCODEC_ERR_UNSUPPORTEDOPERATION; 259 | } 260 | 261 | return m_frame->GetMetadataQueryReader( ppIMetadataQueryReader ); 262 | } 263 | 264 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 265 | 266 | HRESULT WicBitmapDecoder::CopyPalette( IWICPalette* /*pIPalette*/ ) 267 | { 268 | return WINCODEC_ERR_PALETTEUNAVAILABLE; 269 | } 270 | 271 | #pragma endregion 272 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -------------------------------------------------------------------------------- /codec/WicBitmapDecoder.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // MIT License 4 | // 5 | // Copyright(c) 2017 René Slijkhuis 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in all 15 | // copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | // 25 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 26 | 27 | #pragma once 28 | 29 | #include 30 | 31 | #include "utils.h" 32 | 33 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 34 | 35 | class WicFrameDecode; 36 | 37 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 38 | 39 | class WicBitmapDecoder : public ComObjectBase 40 | { 41 | public: 42 | WicBitmapDecoder( ); 43 | virtual ~WicBitmapDecoder( ); 44 | 45 | // IUnknown 46 | HRESULT STDMETHODCALLTYPE QueryInterface( REFIID riid, void** ppObject ); 47 | ULONG STDMETHODCALLTYPE AddRef( ) { return ComObjectBase::AddRef( ); } 48 | ULONG STDMETHODCALLTYPE Release( ) { return ComObjectBase::Release( ); } 49 | 50 | // IWICBitmapDecoder 51 | // Required methods 52 | virtual HRESULT STDMETHODCALLTYPE QueryCapability( IStream* pIStream, DWORD *pCapability ); 53 | virtual HRESULT STDMETHODCALLTYPE Initialize( IStream* pIStream, WICDecodeOptions cacheOptions ); 54 | virtual HRESULT STDMETHODCALLTYPE GetContainerFormat( GUID* pGuidContainerFormat ); 55 | virtual HRESULT STDMETHODCALLTYPE GetDecoderInfo( IWICBitmapDecoderInfo** ppIDecoderInfo ); 56 | virtual HRESULT STDMETHODCALLTYPE GetFrameCount( UINT* pCount ); 57 | virtual HRESULT STDMETHODCALLTYPE GetFrame( UINT index, IWICBitmapFrameDecode** ppIBitmapFrame ); 58 | // Optional methods 59 | virtual HRESULT STDMETHODCALLTYPE GetPreview( IWICBitmapSource** ppIBitmapSource ); 60 | virtual HRESULT STDMETHODCALLTYPE GetThumbnail( IWICBitmapSource** ppIThumbnail ); 61 | virtual HRESULT STDMETHODCALLTYPE GetColorContexts( UINT cCount, IWICColorContext** ppIColorContexts, UINT* pcActualCount ); 62 | virtual HRESULT STDMETHODCALLTYPE GetMetadataQueryReader( IWICMetadataQueryReader** ppIMetadataQueryReader ); 63 | virtual HRESULT STDMETHODCALLTYPE CopyPalette( IWICPalette* pIPalette ); 64 | 65 | private: 66 | ComPtr m_factory; 67 | ComPtr m_frame; 68 | ComPtr m_pIStream; 69 | CRITICAL_SECTION m_criticalSection; 70 | UINT m_index; 71 | }; 72 | 73 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -------------------------------------------------------------------------------- /codec/WicBitmapEncoder.cpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // MIT License 4 | // 5 | // Copyright(c) 2017 René Slijkhuis 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in all 15 | // copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | // 25 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 26 | 27 | #include "WicBitmapEncoder.h" 28 | #include "WicFrameEncode.h" 29 | #include "uuid.h" 30 | 31 | using namespace std; 32 | using namespace Wic::ImageFormat::Lisa; 33 | 34 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 35 | 36 | WicBitmapEncoder::WicBitmapEncoder( ) : 37 | m_pIStream( nullptr ) 38 | { 39 | InitializeCriticalSection( &m_criticalSection ); 40 | } 41 | 42 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 43 | 44 | WicBitmapEncoder::~WicBitmapEncoder( ) 45 | { 46 | DeleteCriticalSection( &m_criticalSection ); 47 | } 48 | 49 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 50 | 51 | void WicBitmapEncoder::SetFrame( LisaImage& image ) 52 | { 53 | m_lisaImage = image; 54 | } 55 | 56 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 57 | #pragma region IUnknown 58 | 59 | HRESULT WicBitmapEncoder::QueryInterface( REFIID riid, void** ppObject ) 60 | { 61 | if ( ppObject == nullptr ) 62 | { 63 | return E_INVALIDARG; 64 | } 65 | 66 | *ppObject = nullptr; 67 | 68 | if ( IsEqualGUID( riid, IID_IWICBitmapEncoder ) ) 69 | { 70 | this->AddRef( ); 71 | *ppObject = static_cast( this ); 72 | return S_OK; 73 | } 74 | else if ( IsEqualGUID( riid, IID_IUnknown ) ) 75 | { 76 | this->AddRef( ); 77 | *ppObject = static_cast( this ); 78 | return S_OK; 79 | } 80 | 81 | return E_NOINTERFACE; 82 | } 83 | 84 | #pragma endregion 85 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 86 | #pragma region IWICBitmapEncoder_required 87 | 88 | HRESULT WicBitmapEncoder::Initialize( IStream* pIStream, WICBitmapEncoderCacheOption /*cacheOption*/ ) 89 | { 90 | HRESULT hr = S_OK; 91 | 92 | if ( pIStream == nullptr ) 93 | { 94 | return E_INVALIDARG; 95 | } 96 | 97 | { 98 | SectionLock l( &m_criticalSection ); 99 | 100 | m_pIStream = pIStream; 101 | 102 | if ( m_imagingFactory.Ptr( ) == nullptr ) 103 | { 104 | hr = CoCreateInstance( CLSID_WICImagingFactory, 105 | NULL, 106 | CLSCTX_INPROC_SERVER, 107 | IID_IWICImagingFactory, 108 | (LPVOID*) m_imagingFactory.get_out_storage( ) ); 109 | } 110 | 111 | if ( ( m_componentFactory.Ptr( ) == nullptr ) && 112 | ( m_imagingFactory.Ptr( ) != nullptr ) && 113 | ( SUCCEEDED( hr ) ) ) 114 | { 115 | hr = m_imagingFactory->QueryInterface( IID_IWICComponentFactory, (void**) &m_componentFactory ); 116 | if ( SUCCEEDED( hr ) ) 117 | { 118 | m_componentFactory.AddRef( ); 119 | } 120 | } 121 | } 122 | 123 | return hr; 124 | } 125 | 126 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 127 | 128 | HRESULT WicBitmapEncoder::GetContainerFormat( GUID* pGuidContainerFormat ) 129 | { 130 | if ( pGuidContainerFormat == nullptr ) 131 | { 132 | return E_INVALIDARG; 133 | } 134 | 135 | *pGuidContainerFormat = GUID_ContainerFormat; 136 | 137 | return S_OK; 138 | } 139 | 140 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 141 | 142 | HRESULT WicBitmapEncoder::GetEncoderInfo( IWICBitmapEncoderInfo** ppIEncoderInfo ) 143 | { 144 | if ( m_imagingFactory.Ptr( ) == nullptr ) 145 | { 146 | return WINCODEC_ERR_NOTINITIALIZED; 147 | } 148 | 149 | HRESULT hr; 150 | ComPtr componentInfo; 151 | 152 | hr = m_imagingFactory->CreateComponentInfo( CLSID_WicBitmapEncoder, componentInfo.get_out_storage( ) ); 153 | if ( FAILED( hr ) ) 154 | { 155 | return hr; 156 | } 157 | 158 | hr = componentInfo->QueryInterface( IID_IWICBitmapEncoderInfo, (void**) ppIEncoderInfo ); 159 | if ( FAILED( hr ) ) 160 | { 161 | return hr; 162 | } 163 | 164 | return S_OK; 165 | } 166 | 167 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 168 | 169 | HRESULT WicBitmapEncoder::CreateNewFrame( IWICBitmapFrameEncode** ppIFrameEncode, IPropertyBag2** ppIEncoderOptions ) 170 | { 171 | if ( ( m_imagingFactory.Ptr( ) == nullptr ) || ( m_componentFactory.Ptr( ) == nullptr ) ) 172 | { 173 | return WINCODEC_ERR_NOTINITIALIZED; 174 | } 175 | 176 | if ( ppIFrameEncode == nullptr ) 177 | { 178 | return E_INVALIDARG; 179 | } 180 | 181 | SectionLock l( &m_criticalSection ); 182 | 183 | ComPtr output; 184 | output.reset( new WicFrameEncode( this ) ); 185 | *ppIFrameEncode = output.AddRef(); 186 | 187 | m_frame.reset( output.AddRef( ) ); 188 | 189 | if ( ppIEncoderOptions != nullptr ) 190 | { 191 | UINT propertyCount = 0; 192 | IPropertyBag2* pPropertyBag = NULL; 193 | PROPBAG2 propBag; 194 | ZeroMemory( &propBag, sizeof propBag ); 195 | 196 | m_componentFactory->CreateEncoderPropertyBag( &propBag, propertyCount, ppIEncoderOptions ); 197 | } 198 | 199 | return S_OK; 200 | } 201 | 202 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 203 | 204 | HRESULT WicBitmapEncoder::Commit( void ) 205 | { 206 | if ( m_pIStream == nullptr ) 207 | { 208 | return WINCODEC_ERR_NOTINITIALIZED; 209 | } 210 | 211 | if ( m_frame.Ptr( ) == nullptr ) 212 | { 213 | return WINCODEC_ERR_FRAMEMISSING; 214 | } 215 | 216 | return m_lisaImage.Save( m_pIStream ) ? S_OK : E_FAIL; 217 | } 218 | 219 | #pragma endregion 220 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 221 | #pragma region IWICBitmapEncoder_optional 222 | 223 | HRESULT WicBitmapEncoder::SetColorContexts( UINT /*cCount*/, IWICColorContext** /*ppIColorContext*/ ) 224 | { 225 | return WINCODEC_ERR_UNSUPPORTEDOPERATION; 226 | } 227 | 228 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 229 | 230 | HRESULT WicBitmapEncoder::SetPalette( IWICPalette* /*pIPalette*/ ) 231 | { 232 | return WINCODEC_ERR_UNSUPPORTEDOPERATION; 233 | } 234 | 235 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 236 | 237 | HRESULT WicBitmapEncoder::SetThumbnail( IWICBitmapSource* /*pIThumbnail*/ ) 238 | { 239 | return WINCODEC_ERR_UNSUPPORTEDOPERATION; 240 | } 241 | 242 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 243 | 244 | HRESULT WicBitmapEncoder::SetPreview( IWICBitmapSource* /*pIPreview*/ ) 245 | { 246 | return WINCODEC_ERR_UNSUPPORTEDOPERATION; 247 | } 248 | 249 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 250 | 251 | HRESULT WicBitmapEncoder::GetMetadataQueryWriter( IWICMetadataQueryWriter** /*ppIMetadataQueryWriter*/ ) 252 | { 253 | return WINCODEC_ERR_UNSUPPORTEDOPERATION; 254 | } 255 | 256 | #pragma endregion 257 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -------------------------------------------------------------------------------- /codec/WicBitmapEncoder.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // MIT License 4 | // 5 | // Copyright(c) 2017 René Slijkhuis 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in all 15 | // copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | // 25 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 26 | 27 | #pragma once 28 | 29 | #include 30 | #include 31 | 32 | #include "utils.h" 33 | #include "LisaImage.h" 34 | 35 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 36 | 37 | class WicFrameEncode; 38 | 39 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 40 | 41 | class WicBitmapEncoder : public ComObjectBase 42 | { 43 | public: 44 | WicBitmapEncoder( ); 45 | virtual ~WicBitmapEncoder( ); 46 | 47 | void SetFrame( Wic::ImageFormat::Lisa::LisaImage& image ); 48 | 49 | // IUnknown 50 | HRESULT STDMETHODCALLTYPE QueryInterface( REFIID riid, void** ppObject ); 51 | ULONG STDMETHODCALLTYPE AddRef( ) { return ComObjectBase::AddRef( ); } 52 | ULONG STDMETHODCALLTYPE Release( ) { return ComObjectBase::Release( ); } 53 | 54 | // IWICBitmapEncoder 55 | // Required methods 56 | HRESULT STDMETHODCALLTYPE Initialize( IStream* pIStream, WICBitmapEncoderCacheOption cacheOption ); 57 | HRESULT STDMETHODCALLTYPE GetContainerFormat( GUID* pGuidContainerFormat ); 58 | HRESULT STDMETHODCALLTYPE GetEncoderInfo( IWICBitmapEncoderInfo** ppIEncoderInfo ); 59 | HRESULT STDMETHODCALLTYPE CreateNewFrame( IWICBitmapFrameEncode** ppIFrameEncode, IPropertyBag2** ppIEncoderOptions ); 60 | HRESULT STDMETHODCALLTYPE Commit( void ); 61 | // Optional methods 62 | HRESULT STDMETHODCALLTYPE SetColorContexts( UINT cCount, IWICColorContext** ppIColorContext ); 63 | HRESULT STDMETHODCALLTYPE SetPalette( IWICPalette* pIPalette ); 64 | HRESULT STDMETHODCALLTYPE SetThumbnail( IWICBitmapSource* pIThumbnail ); 65 | HRESULT STDMETHODCALLTYPE SetPreview( IWICBitmapSource* pIPreview ); 66 | HRESULT STDMETHODCALLTYPE GetMetadataQueryWriter( IWICMetadataQueryWriter** ppIMetadataQueryWriter ); 67 | 68 | private: 69 | ComPtr m_imagingFactory; 70 | ComPtr m_componentFactory; 71 | ComPtr m_frame; 72 | Wic::ImageFormat::Lisa::LisaImage m_lisaImage; 73 | IStream* m_pIStream; 74 | CRITICAL_SECTION m_criticalSection; 75 | }; 76 | 77 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -------------------------------------------------------------------------------- /codec/WicCodec.def: -------------------------------------------------------------------------------- 1 | LIBRARY WicCodec 2 | EXPORTS 3 | DllCanUnloadNow PRIVATE 4 | DllGetClassObject PRIVATE 5 | DllRegisterServer PRIVATE 6 | DllUnregisterServer PRIVATE 7 | -------------------------------------------------------------------------------- /codec/WicCodec.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {3CAD0499-E938-4C64-AE8A-7A74085F4D32} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {BB2CA5B3-F22D-4018-ADF3-CA270B3158EA} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {E79EA339-8DDC-4043-9BD8-5DA048837EDB} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | 29 | 30 | Header Files 31 | 32 | 33 | Header Files 34 | 35 | 36 | Header Files 37 | 38 | 39 | Header Files 40 | 41 | 42 | Header Files 43 | 44 | 45 | Header Files 46 | 47 | 48 | -------------------------------------------------------------------------------- /codec/WicCodec.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.24720.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{3F32818C-BC6A-4752-B38D-F34E51B0311C}") = "WicCodec", "WicCodec.vcxproj", "{C8D77F9F-6464-44B2-A790-2BCA8580C509}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {C8D77F9F-6464-44B2-A790-2BCA8580C509}.Debug|x64.ActiveCfg = Debug|x64 17 | {C8D77F9F-6464-44B2-A790-2BCA8580C509}.Debug|x64.Build.0 = Debug|x64 18 | {C8D77F9F-6464-44B2-A790-2BCA8580C509}.Debug|x86.ActiveCfg = Debug|Win32 19 | {C8D77F9F-6464-44B2-A790-2BCA8580C509}.Debug|x86.Build.0 = Debug|Win32 20 | {C8D77F9F-6464-44B2-A790-2BCA8580C509}.Release|x64.ActiveCfg = Release|x64 21 | {C8D77F9F-6464-44B2-A790-2BCA8580C509}.Release|x64.Build.0 = Release|x64 22 | {C8D77F9F-6464-44B2-A790-2BCA8580C509}.Release|x86.ActiveCfg = Release|Win32 23 | {C8D77F9F-6464-44B2-A790-2BCA8580C509}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /codec/WicCodec.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {C8D77F9F-6464-44B2-A790-2BCA8580C509} 23 | Win32Proj 24 | WicCodec 25 | 8.1 26 | 27 | 28 | 29 | DynamicLibrary 30 | true 31 | Unicode 32 | v120_xp 33 | 34 | 35 | DynamicLibrary 36 | true 37 | Unicode 38 | v120_xp 39 | 40 | 41 | DynamicLibrary 42 | false 43 | true 44 | Unicode 45 | v120_xp 46 | 47 | 48 | DynamicLibrary 49 | false 50 | true 51 | Unicode 52 | v120_xp 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | true 72 | $(SolutionDir)bin\$(Platform)\$(Configuration)\ 73 | $(SolutionDir)obj\codec\$(Platform)\$(Configuration)\ 74 | $(IncludePath) 75 | $(LibraryPath) 76 | $(ExecutablePath) 77 | 78 | 79 | true 80 | $(SolutionDir)bin\$(Platform)\$(Configuration)\ 81 | $(SolutionDir)obj\codec\$(Platform)\$(Configuration)\ 82 | $(IncludePath) 83 | $(LibraryPath) 84 | $(ExecutablePath) 85 | 86 | 87 | false 88 | $(SolutionDir)bin\$(Platform)\$(Configuration)\ 89 | $(SolutionDir)obj\codec\$(Platform)\$(Configuration)\ 90 | $(IncludePath) 91 | $(LibraryPath) 92 | $(ExecutablePath) 93 | 94 | 95 | false 96 | $(SolutionDir)bin\$(Platform)\$(Configuration)\ 97 | $(SolutionDir)obj\codec\$(Platform)\$(Configuration)\ 98 | $(IncludePath) 99 | $(LibraryPath) 100 | $(ExecutablePath) 101 | 102 | 103 | 104 | 105 | 106 | Level3 107 | Disabled 108 | WIN32;_DEBUG;_WINDOWS;_USRDLL;WEBPWICCODEC_EXPORTS;%(PreprocessorDefinitions) 109 | MultiThreadedDebug 110 | 111 | 112 | Windows 113 | true 114 | WicCodec.def 115 | gdiplus.lib;windowscodecs.lib;%(AdditionalDependencies) 116 | 117 | 118 | 119 | 120 | 121 | 122 | Level3 123 | Disabled 124 | WIN32;_DEBUG;_WINDOWS;_USRDLL;WEBPWICCODEC_EXPORTS;%(PreprocessorDefinitions) 125 | MultiThreadedDebug 126 | 127 | 128 | Windows 129 | true 130 | WicCodec.def 131 | gdiplus.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;windowscodecs.lib;%(AdditionalDependencies) 132 | 133 | 134 | 135 | 136 | Level3 137 | 138 | 139 | MaxSpeed 140 | true 141 | true 142 | WIN32;NDEBUG;_WINDOWS;_USRDLL;WEBPWICCODEC_EXPORTS;%(PreprocessorDefinitions) 143 | MultiThreaded 144 | 145 | 146 | Windows 147 | true 148 | true 149 | true 150 | gdiplus.lib;windowscodecs.lib;%(AdditionalDependencies) 151 | WicCodec.def 152 | 153 | 154 | 155 | 156 | Level3 157 | 158 | 159 | MaxSpeed 160 | true 161 | true 162 | WIN32;NDEBUG;_WINDOWS;_USRDLL;WEBPWICCODEC_EXPORTS;%(PreprocessorDefinitions) 163 | MultiThreaded 164 | 165 | 166 | Windows 167 | true 168 | true 169 | true 170 | gdiplus.lib;windowscodecs.lib;%(AdditionalDependencies) 171 | WicCodec.def 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | -------------------------------------------------------------------------------- /codec/WicCodec.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | FileFormat 7 | 8 | 9 | Utilities 10 | 11 | 12 | Utilities 13 | 14 | 15 | CodecInterfaces 16 | 17 | 18 | CodecInterfaces 19 | 20 | 21 | CodecInterfaces 22 | 23 | 24 | CodecInterfaces 25 | 26 | 27 | CodecInterfaces 28 | 29 | 30 | 31 | 32 | 33 | FileFormat 34 | 35 | 36 | Utilities 37 | 38 | 39 | Utilities 40 | 41 | 42 | Utilities 43 | 44 | 45 | Utilities 46 | 47 | 48 | CodecInterfaces 49 | 50 | 51 | CodecInterfaces 52 | 53 | 54 | CodecInterfaces 55 | 56 | 57 | CodecInterfaces 58 | 59 | 60 | CodecInterfaces 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | {fe6b124c-3bbf-491e-b440-78dc07263dd6} 69 | 70 | 71 | {9bf0ef18-3f7e-4594-a8ac-41e3bccb2f97} 72 | 73 | 74 | {63995b57-c2ef-4424-998f-b8bcab3c9dec} 75 | 76 | 77 | -------------------------------------------------------------------------------- /codec/WicFrameDecode.cpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // MIT License 4 | // 5 | // Copyright(c) 2017 René Slijkhuis 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in all 15 | // copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | // 25 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 26 | 27 | #include "WicFrameDecode.h" 28 | 29 | using namespace std; 30 | using namespace Wic::ImageFormat::Lisa; 31 | 32 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 33 | 34 | WicFrameDecode::WicFrameDecode( LisaImage* pLisaImage ) : 35 | m_pLisaImage( pLisaImage ), 36 | m_width( 0 ), 37 | m_height( 0 ), 38 | m_pixelFormat( PixelFormat::Unknown ) 39 | { 40 | m_width = m_pLisaImage->GetWidth( ); 41 | m_height = m_pLisaImage->GetHeight( ); 42 | m_pixelFormat = m_pLisaImage->GetPixelFormat( ); 43 | m_pLisaImage->GetBytes( m_imageData ); 44 | } 45 | 46 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 47 | 48 | WicFrameDecode::~WicFrameDecode( ) 49 | { 50 | } 51 | 52 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 53 | 54 | HRESULT WicFrameDecode::CreateFromStream( IStream* pIStream, ComPtr* ppFrame, UINT index ) 55 | { 56 | if ( pIStream == nullptr ) 57 | { 58 | return E_INVALIDARG; 59 | } 60 | 61 | std::auto_ptr pLisaImage( new LisaImage( ) ); 62 | if ( pLisaImage.get( ) == nullptr ) 63 | { 64 | return E_OUTOFMEMORY; 65 | } 66 | 67 | if ( !pLisaImage->Read( pIStream ) ) 68 | { 69 | return E_FAIL; 70 | } 71 | 72 | ComPtr output; 73 | (*ppFrame).reset( nullptr ); 74 | 75 | output.reset( new WicFrameDecode( pLisaImage.release( ) ) ); 76 | if ( output.Ptr( ) == nullptr ) 77 | { 78 | return E_OUTOFMEMORY; 79 | } 80 | 81 | (*ppFrame).reset( output.AddRef( ) ); 82 | 83 | return S_OK; 84 | } 85 | 86 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 87 | #pragma region RawImageLib 88 | 89 | UINT WicFrameDecode::GetFrameCount( ) 90 | { 91 | return 1; 92 | } 93 | 94 | #pragma endregion 95 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 96 | #pragma region IUnknown 97 | 98 | HRESULT WicFrameDecode::QueryInterface( REFIID riid, void** ppObject ) 99 | { 100 | if ( ppObject == nullptr ) 101 | { 102 | return E_INVALIDARG; 103 | } 104 | 105 | *ppObject = nullptr; 106 | 107 | if ( IsEqualGUID( riid, IID_IWICBitmapFrameDecode ) ) 108 | { 109 | this->AddRef( ); 110 | *ppObject = static_cast( this ); 111 | } 112 | else if ( ( IsEqualGUID( riid, IID_IWICBitmapSource ) ) || 113 | ( IsEqualGUID( riid, IID_IUnknown ) ) ) 114 | { 115 | this->AddRef( ); 116 | *ppObject = static_cast( this ); 117 | } 118 | else 119 | { 120 | return E_NOINTERFACE; 121 | } 122 | 123 | return S_OK; 124 | } 125 | 126 | #pragma endregion 127 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 128 | #pragma region IWICBitmapSource_required 129 | 130 | HRESULT WicFrameDecode::GetSize( UINT* pWidth, UINT* pHeight ) 131 | { 132 | if ( pWidth == nullptr || pHeight == nullptr ) 133 | { 134 | return E_INVALIDARG; 135 | } 136 | 137 | *pWidth = m_width; 138 | *pHeight = m_height; 139 | 140 | return S_OK; 141 | } 142 | 143 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 144 | 145 | HRESULT WicFrameDecode::GetPixelFormat( WICPixelFormatGUID* pPixelFormat ) 146 | { 147 | if ( pPixelFormat == nullptr ) 148 | { 149 | return E_INVALIDARG; 150 | } 151 | 152 | if ( m_pixelFormat == PixelFormat::UInt8 ) 153 | { 154 | *pPixelFormat = GUID_WICPixelFormat8bppGray; 155 | } 156 | else if ( m_pixelFormat == PixelFormat::RGB24 ) 157 | { 158 | *pPixelFormat = GUID_WICPixelFormat24bppRGB; 159 | } 160 | else 161 | { 162 | return E_FAIL; 163 | } 164 | 165 | return S_OK; 166 | } 167 | 168 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 169 | 170 | HRESULT WicFrameDecode::GetResolution(double* pDpiX, double* pDpiY ) 171 | { 172 | if ( pDpiX == nullptr || pDpiY == nullptr ) 173 | { 174 | return E_INVALIDARG; 175 | } 176 | 177 | *pDpiX = 96; 178 | *pDpiY = 96; 179 | 180 | return S_OK; 181 | } 182 | 183 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 184 | 185 | HRESULT WicFrameDecode::CopyPixels( const WICRect* pRc, UINT stride, UINT bufferSize, BYTE* pBuffer ) 186 | { 187 | if ( pBuffer == nullptr ) 188 | { 189 | return E_INVALIDARG; 190 | } 191 | 192 | WICRect rect = { 0, 0, static_cast( m_width ), static_cast( m_height ) }; 193 | 194 | // pRc specifies the rectangle to copy. A NULL value specifies the entire bitmap. 195 | if ( pRc != nullptr ) 196 | { 197 | rect = *pRc; 198 | } 199 | 200 | if ( ( rect.Width < 0 ) || ( rect.Height < 0 ) || ( rect.X < 0 ) || ( rect.Y < 0 ) ) 201 | { 202 | return E_INVALIDARG; 203 | } 204 | 205 | if ( ( ( rect.X + rect.Width ) > static_cast( m_width ) ) || 206 | ( ( rect.Y + rect.Height ) > static_cast( m_height ) ) ) 207 | { 208 | return E_INVALIDARG; 209 | } 210 | 211 | if ( ( bufferSize / stride ) < static_cast( rect.Height ) ) 212 | { 213 | return WINCODEC_ERR_INSUFFICIENTBUFFER; 214 | } 215 | 216 | int bytesPerPixel = 1; 217 | if ( m_pixelFormat == PixelFormat::RGB24 ) bytesPerPixel = 3; 218 | 219 | int x = rect.X; 220 | int strideSrc = m_width * bytesPerPixel; 221 | int strideDest = rect.Width * bytesPerPixel; 222 | 223 | int i = 0; 224 | for ( int y = rect.Y ; y < ( rect.Y + rect.Height ) ; y++ ) 225 | { 226 | BYTE* pLine = m_imageData.data( ) + ( ( y * strideSrc ) + ( x * bytesPerPixel ) ); 227 | memcpy( pBuffer + ( i * stride ), pLine, strideDest ); 228 | i++; 229 | } 230 | 231 | return S_OK; 232 | } 233 | 234 | #pragma endregion 235 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 236 | #pragma region IWICBitmapSource_optional 237 | 238 | HRESULT WicFrameDecode::CopyPalette( IWICPalette* /*pIPalette*/ ) 239 | { 240 | return WINCODEC_ERR_PALETTEUNAVAILABLE; 241 | } 242 | 243 | #pragma endregion 244 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 245 | #pragma region IWICBitmapFrameDecode 246 | 247 | HRESULT WicFrameDecode::GetThumbnail( IWICBitmapSource** /*ppIThumbnail*/ ) 248 | { 249 | return WINCODEC_ERR_CODECNOTHUMBNAIL; 250 | } 251 | 252 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 253 | 254 | HRESULT WicFrameDecode::GetColorContexts( UINT /*cCount*/, IWICColorContext** /*ppIColorContexts*/, UINT* /*pcActualCount*/ ) 255 | { 256 | return WINCODEC_ERR_UNSUPPORTEDOPERATION; 257 | } 258 | 259 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 260 | 261 | HRESULT WicFrameDecode::GetMetadataQueryReader( IWICMetadataQueryReader** /*ppIMetadataQueryReader*/ ) 262 | { 263 | return WINCODEC_ERR_UNSUPPORTEDOPERATION; 264 | } 265 | 266 | #pragma endregion 267 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -------------------------------------------------------------------------------- /codec/WicFrameDecode.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // MIT License 4 | // 5 | // Copyright(c) 2017 René Slijkhuis 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in all 15 | // copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | // 25 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 26 | 27 | #pragma once 28 | 29 | #include 30 | #include 31 | 32 | #include "utils.h" 33 | #include "LisaImage.h" 34 | 35 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 36 | 37 | class WicFrameDecode : public ComObjectBase // Is derived from IWICBitmapSource 38 | { 39 | public: 40 | WicFrameDecode( Wic::ImageFormat::Lisa::LisaImage* pLisaImage ); 41 | virtual ~WicFrameDecode( ); 42 | 43 | static HRESULT CreateFromStream( IStream* pIStream, ComPtr* ppFrame, UINT index ); 44 | 45 | // RawImageLib 46 | UINT GetFrameCount( ); 47 | 48 | // IUnknown 49 | HRESULT STDMETHODCALLTYPE QueryInterface( REFIID riid, void** ppObject ); 50 | ULONG STDMETHODCALLTYPE AddRef( ) { return ComObjectBase::AddRef( ); } 51 | ULONG STDMETHODCALLTYPE Release( ) { return ComObjectBase::Release( ); } 52 | 53 | // IWICBitmapSource 54 | // Required methods 55 | virtual HRESULT STDMETHODCALLTYPE GetSize( UINT* pWidth, UINT* pHeight ); 56 | virtual HRESULT STDMETHODCALLTYPE GetPixelFormat( WICPixelFormatGUID* pPixelFormat ); 57 | virtual HRESULT STDMETHODCALLTYPE GetResolution( double* pDpiX, double* pDpiY ); 58 | virtual HRESULT STDMETHODCALLTYPE CopyPixels( const WICRect* pRc, UINT stride, UINT bufferSize, BYTE* pBuffer ); 59 | // Optional methods 60 | virtual HRESULT STDMETHODCALLTYPE CopyPalette( IWICPalette* pIPalette ); 61 | 62 | // IWICBitmapFrameDecode 63 | virtual HRESULT STDMETHODCALLTYPE GetThumbnail( IWICBitmapSource** ppIThumbnail ); 64 | virtual HRESULT STDMETHODCALLTYPE GetColorContexts( UINT cCount, IWICColorContext** ppIColorContexts, UINT* pcActualCount ); 65 | virtual HRESULT STDMETHODCALLTYPE GetMetadataQueryReader( IWICMetadataQueryReader** ppIMetadataQueryReader ); 66 | 67 | private: 68 | std::unique_ptr m_pLisaImage; 69 | std::vector m_imageData; 70 | UINT m_width; 71 | UINT m_height; 72 | Wic::ImageFormat::Lisa::PixelFormat m_pixelFormat; 73 | }; 74 | 75 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -------------------------------------------------------------------------------- /codec/WicFrameEncode.cpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // MIT License 4 | // 5 | // Copyright(c) 2017 René Slijkhuis 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in all 15 | // copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | // 25 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 26 | 27 | #include "WicBitmapEncoder.h" 28 | #include "WicFrameEncode.h" 29 | 30 | using namespace std; 31 | using namespace Wic::ImageFormat::Lisa; 32 | 33 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 34 | 35 | WicFrameEncode::WicFrameEncode( WicBitmapEncoder* pEncoder ) : 36 | m_width( 0 ), 37 | m_height( 0 ), 38 | m_pixelFormat( PixelFormat::Unknown ), 39 | m_pEncoder( pEncoder ) 40 | { 41 | m_pEncoder->AddRef( ); 42 | } 43 | 44 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 45 | 46 | WicFrameEncode::~WicFrameEncode( ) 47 | { 48 | m_pEncoder->Release( ); 49 | } 50 | 51 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 52 | #pragma region IUnknown 53 | 54 | HRESULT WicFrameEncode::QueryInterface( REFIID riid, void** ppObject ) 55 | { 56 | if ( ppObject == nullptr ) 57 | { 58 | return E_INVALIDARG; 59 | } 60 | 61 | *ppObject = nullptr; 62 | 63 | if ( IsEqualGUID( riid, IID_IWICBitmapFrameEncode ) ) 64 | { 65 | this->AddRef( ); 66 | *ppObject = static_cast( this ); 67 | return S_OK; 68 | } 69 | else if ( IsEqualGUID( riid, IID_IUnknown ) ) 70 | { 71 | this->AddRef( ); 72 | *ppObject = static_cast( this ); 73 | return S_OK; 74 | } 75 | 76 | return E_NOINTERFACE; 77 | } 78 | 79 | #pragma endregion 80 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 81 | #pragma region IWICBitmapFrameEncode_required 82 | 83 | HRESULT WicFrameEncode::Initialize( IPropertyBag2* /*pIEncoderOptions*/ ) 84 | { 85 | return S_OK; 86 | } 87 | 88 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 89 | 90 | HRESULT WicFrameEncode::SetSize( UINT width, UINT height ) 91 | { 92 | m_width = width; 93 | m_height = height; 94 | 95 | return S_OK; 96 | } 97 | 98 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 99 | 100 | HRESULT WicFrameEncode::SetResolution( double /*dpiX*/, double /*dpiY*/ ) 101 | { 102 | return S_OK; 103 | } 104 | 105 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 106 | 107 | HRESULT WicFrameEncode::SetPixelFormat( WICPixelFormatGUID* pPixelFormat ) 108 | { 109 | if ( pPixelFormat == nullptr ) 110 | { 111 | return E_INVALIDARG; 112 | } 113 | 114 | if ( *pPixelFormat == GUID_WICPixelFormat8bppGray ) 115 | { 116 | m_pixelFormat = PixelFormat::UInt8; 117 | } 118 | else if ( *pPixelFormat == GUID_WICPixelFormat24bppRGB ) 119 | { 120 | m_pixelFormat = PixelFormat::RGB24; 121 | } 122 | else 123 | { 124 | return WINCODEC_ERR_UNSUPPORTEDPIXELFORMAT; 125 | } 126 | 127 | return S_OK; 128 | } 129 | 130 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 131 | 132 | HRESULT WicFrameEncode::WritePixels( UINT lineCount, UINT cbStride, UINT cbBufferSize, BYTE* pbPixels ) 133 | { 134 | if ( pbPixels == nullptr ) 135 | { 136 | return E_INVALIDARG; 137 | } 138 | 139 | if ( ( m_width == 0 ) || ( m_height == 0 ) || ( m_pixelFormat == PixelFormat::Unknown ) ) 140 | { 141 | return WINCODEC_ERR_NOTINITIALIZED; 142 | } 143 | 144 | const UINT strideDestination = m_width * LisaImage::GetBytesPerPixel( m_pixelFormat ); 145 | const UINT sizeDestination = m_height * strideDestination; 146 | 147 | if ( ( m_height != lineCount ) || 148 | ( strideDestination < cbStride ) || 149 | ( sizeDestination < cbBufferSize ) ) 150 | { 151 | return E_INVALIDARG; 152 | } 153 | 154 | vector bytes( sizeDestination, 0x00 ); 155 | for ( UINT i = 0 ; i < m_height ; i++ ) 156 | { 157 | BYTE* pBytesSource = pbPixels + ( cbStride * i ); 158 | BYTE* pBytesDestination = bytes.data( ) + ( strideDestination * i ); 159 | memcpy_s( pBytesDestination, strideDestination, pBytesSource, strideDestination ); 160 | } 161 | 162 | if ( !m_lisaImage.SetImage( m_width, m_height, m_pixelFormat, bytes ) ) 163 | { 164 | return E_FAIL; 165 | } 166 | 167 | return S_OK; 168 | } 169 | 170 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 171 | 172 | HRESULT WicFrameEncode::WriteSource( IWICBitmapSource* pIBitmapSource, WICRect* pRect ) 173 | { 174 | HRESULT hr = S_OK; 175 | 176 | if ( pIBitmapSource == nullptr ) 177 | { 178 | return E_INVALIDARG; 179 | } 180 | 181 | if ( pRect != nullptr ) 182 | { 183 | return WINCODEC_ERR_UNSUPPORTEDOPERATION; 184 | } 185 | 186 | hr = pIBitmapSource->GetSize( &m_width, &m_height ); 187 | if ( FAILED( hr ) ) 188 | { 189 | return WINCODEC_ERR_GENERIC_ERROR; 190 | } 191 | 192 | WICPixelFormatGUID pixelFormat; 193 | hr = pIBitmapSource->GetPixelFormat( &pixelFormat ); 194 | if ( FAILED( hr ) ) 195 | { 196 | return WINCODEC_ERR_GENERIC_ERROR; 197 | } 198 | 199 | if ( pixelFormat == GUID_WICPixelFormat8bppGray ) 200 | { 201 | m_pixelFormat = PixelFormat::UInt8; 202 | } 203 | else if ( pixelFormat == GUID_WICPixelFormat24bppRGB ) 204 | { 205 | m_pixelFormat = PixelFormat::RGB24; 206 | } 207 | else 208 | { 209 | return WINCODEC_ERR_UNSUPPORTEDPIXELFORMAT; 210 | } 211 | 212 | UINT bytesPerPixel = LisaImage::GetBytesPerPixel( m_pixelFormat ); 213 | UINT stride = m_width * bytesPerPixel; 214 | UINT size = m_width * m_height * bytesPerPixel; 215 | 216 | vector bytes( size ); 217 | hr = pIBitmapSource->CopyPixels( NULL, stride, size, bytes.data( ) ); 218 | if ( FAILED( hr ) ) 219 | { 220 | return WINCODEC_ERR_GENERIC_ERROR; 221 | } 222 | 223 | return WritePixels( m_height, stride, size, bytes.data( ) ); 224 | } 225 | 226 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 227 | 228 | HRESULT WicFrameEncode::Commit( void ) 229 | { 230 | m_pEncoder->SetFrame( m_lisaImage ); 231 | return S_OK; 232 | } 233 | 234 | #pragma endregion 235 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 236 | #pragma region IWICBitmapFrameEncode_optional 237 | 238 | HRESULT WicFrameEncode::SetColorContexts( UINT /*cCount*/, IWICColorContext** /*ppIColorContext*/ ) 239 | { 240 | return WINCODEC_ERR_UNSUPPORTEDOPERATION; 241 | } 242 | 243 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 244 | 245 | HRESULT WicFrameEncode::SetPalette( IWICPalette* /*pIPalette*/ ) 246 | { 247 | return WINCODEC_ERR_UNSUPPORTEDOPERATION; 248 | } 249 | 250 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 251 | 252 | HRESULT WicFrameEncode::SetThumbnail( IWICBitmapSource* /*pIThumbnail*/ ) 253 | { 254 | return WINCODEC_ERR_UNSUPPORTEDOPERATION; 255 | } 256 | 257 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 258 | 259 | HRESULT WicFrameEncode::GetMetadataQueryWriter( IWICMetadataQueryWriter** /*ppIMetadataQueryWriter*/ ) 260 | { 261 | return WINCODEC_ERR_UNSUPPORTEDOPERATION; 262 | } 263 | 264 | #pragma endregion 265 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -------------------------------------------------------------------------------- /codec/WicFrameEncode.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // MIT License 4 | // 5 | // Copyright(c) 2017 René Slijkhuis 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in all 15 | // copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | // 25 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 26 | 27 | #pragma once 28 | 29 | #include 30 | #include 31 | 32 | #include "utils.h" 33 | #include "LisaImage.h" 34 | 35 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 36 | 37 | class WicFrameEncode : public ComObjectBase 38 | { 39 | public: 40 | WicFrameEncode( WicBitmapEncoder* pEncoder ); 41 | virtual ~WicFrameEncode( ); 42 | 43 | // IUnknown 44 | HRESULT STDMETHODCALLTYPE QueryInterface( REFIID riid, void** ppObject ); 45 | ULONG STDMETHODCALLTYPE AddRef( ) { return ComObjectBase::AddRef( ); } 46 | ULONG STDMETHODCALLTYPE Release( ) { return ComObjectBase::Release( ); } 47 | 48 | // IWICBitmapFrameEncode 49 | // Required methods 50 | virtual HRESULT STDMETHODCALLTYPE Initialize( IPropertyBag2* pIEncoderOptions ); 51 | virtual HRESULT STDMETHODCALLTYPE SetSize( UINT width, UINT height ); 52 | virtual HRESULT STDMETHODCALLTYPE SetResolution( double dpiX, double dpiY ); 53 | virtual HRESULT STDMETHODCALLTYPE SetPixelFormat( WICPixelFormatGUID* pPixelFormat ); 54 | virtual HRESULT STDMETHODCALLTYPE WritePixels( UINT lineCount, UINT cbStride, UINT cbBufferSize, BYTE* pbPixels ); 55 | virtual HRESULT STDMETHODCALLTYPE WriteSource( IWICBitmapSource* pIBitmapSource, WICRect* pRect ); 56 | virtual HRESULT STDMETHODCALLTYPE Commit( void ); 57 | 58 | // Optional methods 59 | virtual HRESULT STDMETHODCALLTYPE SetColorContexts( UINT cCount, IWICColorContext** ppIColorContext ); 60 | virtual HRESULT STDMETHODCALLTYPE SetPalette( IWICPalette* pIPalette ); 61 | virtual HRESULT STDMETHODCALLTYPE SetThumbnail( IWICBitmapSource* pIThumbnail ); 62 | virtual HRESULT STDMETHODCALLTYPE GetMetadataQueryWriter( IWICMetadataQueryWriter** ppIMetadataQueryWriter ); 63 | 64 | private: 65 | WicBitmapEncoder* m_pEncoder; 66 | UINT m_width; 67 | UINT m_height; 68 | Wic::ImageFormat::Lisa::PixelFormat m_pixelFormat; 69 | Wic::ImageFormat::Lisa::LisaImage m_lisaImage; 70 | }; 71 | 72 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -------------------------------------------------------------------------------- /codec/clean.bat: -------------------------------------------------------------------------------- 1 | rmdir /S /Q .vs 2 | rmdir /S /Q ipch 3 | rmdir /S /Q bin 4 | rmdir /S /Q obj 5 | rmdir /S /Q Debug 6 | rmdir /S /Q Release 7 | 8 | del /F /S /Q *.aps 9 | del /F /S /Q *.VC.db 10 | del /F /S /Q *.VC.VC.opendb 11 | -------------------------------------------------------------------------------- /codec/main.cpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // MIT License 4 | // 5 | // Copyright(c) 2017 René Slijkhuis 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in all 15 | // copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | // 25 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 26 | 27 | #define INITGUID 28 | 29 | #include 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | #include "main.h" 38 | #include "utils.h" 39 | #include "uuid.h" 40 | #include "WicBitmapDecoder.h" 41 | #include "WicBitmapEncoder.h" 42 | #include "PropertyStore.h" 43 | 44 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 45 | 46 | // Object and server locks counters 47 | LONG volatile MAIN_nObjects = 0; 48 | LONG volatile MAIN_nServerLocks = 0; 49 | HINSTANCE g_hInst; 50 | 51 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 52 | // Class factory 53 | 54 | typedef HRESULT (*ObjectConstructor)(IUnknown** ppvObject); 55 | 56 | // A default constructor. Creates and instance of T. T should be a subclass of 57 | // IUnknown with a parameter-less constructor. 58 | template 59 | HRESULT CreateComObject(IUnknown** output) 60 | { 61 | T* result = new (std::nothrow) T(); 62 | if ( result == nullptr ) 63 | { 64 | return E_OUTOFMEMORY; 65 | } 66 | 67 | *output = reinterpret_cast( result ); 68 | if ( *output == nullptr ) 69 | { 70 | return E_NOINTERFACE; 71 | } 72 | 73 | return S_OK; 74 | } 75 | 76 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 77 | 78 | class MyClassFactory : public ComObjectBase 79 | { 80 | public: 81 | MyClassFactory(ObjectConstructor ctor); 82 | // IUnknown: 83 | HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject); 84 | ULONG STDMETHODCALLTYPE AddRef() { return ComObjectBase::AddRef(); } 85 | ULONG STDMETHODCALLTYPE Release() { return ComObjectBase::Release(); } 86 | // IClassFactory: 87 | HRESULT STDMETHODCALLTYPE CreateInstance(IUnknown* pUnkOuter, REFIID riid, void** ppvObject); 88 | HRESULT STDMETHODCALLTYPE LockServer(BOOL fLock); 89 | 90 | private: 91 | volatile LONG ref_count_; 92 | ObjectConstructor ctor_; 93 | }; 94 | 95 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 96 | 97 | MyClassFactory::MyClassFactory(ObjectConstructor ctor) { 98 | InterlockedIncrement(&MAIN_nObjects); 99 | ref_count_ = 0; 100 | ctor_ = ctor; 101 | } 102 | 103 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 104 | 105 | HRESULT MyClassFactory::QueryInterface(REFIID riid, void **ppvObject) 106 | { 107 | if (ppvObject == NULL) 108 | return E_INVALIDARG; 109 | *ppvObject = NULL; 110 | 111 | if (!IsEqualGUID(riid, IID_IUnknown) && !IsEqualGUID(riid, IID_IClassFactory)) 112 | return E_NOINTERFACE; 113 | this->AddRef(); 114 | *ppvObject = static_cast(this); 115 | return S_OK; 116 | } 117 | 118 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 119 | 120 | HRESULT MyClassFactory::CreateInstance(IUnknown* pUnkOuter, REFIID riid, void** ppvObject) 121 | { 122 | IUnknown* output; 123 | HRESULT ret; 124 | 125 | if (ppvObject == NULL) 126 | return E_INVALIDARG; 127 | *ppvObject = NULL; 128 | 129 | if (pUnkOuter != NULL) 130 | return CLASS_E_NOAGGREGATION; 131 | 132 | ret = ctor_(&output); 133 | if (FAILED(ret)) 134 | return ret; 135 | ret = output->QueryInterface(riid, ppvObject); 136 | output->Release(); 137 | if (FAILED(ret)) 138 | ppvObject = NULL; 139 | return ret; 140 | } 141 | 142 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 143 | 144 | HRESULT MyClassFactory::LockServer(BOOL fLock) 145 | { 146 | if (fLock) 147 | InterlockedIncrement(&MAIN_nServerLocks); 148 | else 149 | InterlockedDecrement(&MAIN_nServerLocks); 150 | return S_OK; 151 | } 152 | 153 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 154 | 155 | typedef HRESULT (WINAPI *RegInstallFuncA)(HMODULE hm, LPCSTR pszSection, const STRTABLEA* pstTable); 156 | typedef void (STDAPICALLTYPE *SHChangeNotifyFunc)(LONG wEventId, UINT uFlags, LPCVOID dwItem1, LPCVOID dwItem2); 157 | 158 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 159 | 160 | static HRESULT RegisterServer( ) 161 | { 162 | // The installer will create the needed registry entries... 163 | 164 | // Updating the Thumbnail Cache When Installing Your Codec 165 | // When a codec is installed, the installer needs to call the following function after writing its registry entries. 166 | SHChangeNotify( SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL ); 167 | 168 | return S_OK; 169 | } 170 | 171 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 172 | 173 | STDAPI DllRegisterServer( ) 174 | { 175 | RegisterServer( ); 176 | 177 | return S_OK; 178 | } 179 | 180 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 181 | 182 | STDAPI DllUnregisterServer( ) 183 | { 184 | return S_OK; 185 | } 186 | 187 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 188 | 189 | STDAPI DllGetClassObject( REFCLSID clsid, REFIID iid, LPVOID *ppv ) 190 | { 191 | if ( ppv == nullptr ) 192 | { 193 | return E_INVALIDARG; 194 | } 195 | 196 | *ppv = nullptr; 197 | 198 | if ( !IsEqualGUID( iid, IID_IClassFactory ) ) 199 | { 200 | return E_INVALIDARG; 201 | } 202 | 203 | if ( IsEqualGUID( clsid, CLSID_WicBitmapDecoder ) ) 204 | { 205 | *ppv = (LPVOID)(new (std::nothrow) MyClassFactory( CreateComObject ) ); 206 | } 207 | else if ( IsEqualGUID( clsid, CLSID_WicBitmapEncoder ) ) 208 | { 209 | *ppv = (LPVOID)(new (std::nothrow) MyClassFactory( CreateComObject ) ); 210 | } 211 | else if ( IsEqualGUID( clsid, CLSID_PropertyStore ) ) 212 | { 213 | *ppv = (LPVOID)(new (std::nothrow) MyClassFactory( CreateComObject ) ); 214 | } 215 | else 216 | { 217 | return CLASS_E_CLASSNOTAVAILABLE; 218 | } 219 | 220 | if ( *ppv == nullptr ) 221 | { 222 | return E_OUTOFMEMORY; 223 | } 224 | 225 | return S_OK; 226 | } 227 | 228 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 229 | 230 | STDAPI DllCanUnloadNow( ) 231 | { 232 | if ( MAIN_nObjects == 0 && MAIN_nServerLocks == 0 ) 233 | { 234 | return S_OK; 235 | } 236 | else 237 | { 238 | return S_FALSE; 239 | } 240 | } 241 | 242 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 243 | 244 | BOOL WINAPI DllMain( __in HINSTANCE hinstDLL, __in DWORD fdwReason, __in LPVOID lpvReserved ) 245 | { 246 | if ( fdwReason == DLL_PROCESS_ATTACH ) 247 | { 248 | DisableThreadLibraryCalls( hinstDLL ); 249 | g_hInst = hinstDLL; 250 | } 251 | 252 | return TRUE; 253 | } 254 | 255 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -------------------------------------------------------------------------------- /codec/main.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // MIT License 4 | // 5 | // Copyright(c) 2017 René Slijkhuis 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in all 15 | // copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | // 25 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 26 | 27 | #pragma once 28 | 29 | // The number of COM objects created 30 | extern LONG volatile MAIN_nObjects; 31 | 32 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -------------------------------------------------------------------------------- /codec/utils.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // MIT License 4 | // 5 | // Copyright(c) 2017 René Slijkhuis 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in all 15 | // copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | // 25 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 26 | 27 | #pragma once 28 | 29 | #include 30 | 31 | #include "main.h" 32 | 33 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 34 | 35 | class SectionLock { 36 | public: 37 | SectionLock(CRITICAL_SECTION* cs) :cs_(cs) { EnterCriticalSection(cs_); } 38 | ~SectionLock() { LeaveCriticalSection(cs_); } 39 | private: 40 | CRITICAL_SECTION* cs_; 41 | }; 42 | 43 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 44 | 45 | // A wrapper around a pointer to a COM object that does a Release on 46 | // descruction. T should be a subclass of IUnknown. 47 | template 48 | class ComPtr 49 | { 50 | public: 51 | ComPtr( ) : m_ptr( nullptr ) { } 52 | // ptr should be already AddRef'ed for this reference. 53 | ComPtr( T* ptr ) : m_ptr( ptr ) { } 54 | ~ComPtr( ) { if (m_ptr) m_ptr->Release( ); } 55 | 56 | T* Ptr( ) { return m_ptr; } 57 | T* AddRef( ) { m_ptr->AddRef( ); return m_ptr; } 58 | // new_ptr should be already AddRef'ed for this new reference. 59 | void reset( T* new_ptr ) { if ( m_ptr != nullptr ) m_ptr->Release( ); m_ptr = new_ptr; } 60 | // Allows to pass the the pointer as an 'out' parameter. If a non-NULL value 61 | // is written to it, it should be a valid pointer and already AddRef'ed for 62 | // this new reference. 63 | T** get_out_storage( ) { reset(nullptr); return &m_ptr; } 64 | T* operator->( ) { return m_ptr; } 65 | T& operator*( ) { return *m_ptr; } 66 | private: 67 | T* m_ptr; 68 | 69 | // No copy and assign. 70 | ComPtr( const ComPtr& ); 71 | void operator=( const ComPtr& ); 72 | }; 73 | 74 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 75 | 76 | // Implements handling of object's and DLL's COM reference counts. 77 | // T should be a subinterface of IUnknown. Templating used to avoid unnecessary 78 | // mulitple inheritance. 79 | template 80 | class ComObjectBase : public T { 81 | public: 82 | ComObjectBase() { 83 | InterlockedIncrement(&MAIN_nObjects); 84 | ref_count_ = 1; 85 | } 86 | virtual ~ComObjectBase() { 87 | InterlockedDecrement(&MAIN_nObjects); 88 | } 89 | 90 | // IUnknown methods: 91 | virtual ULONG STDMETHODCALLTYPE AddRef() { 92 | return InterlockedIncrement(&ref_count_); 93 | } 94 | 95 | virtual ULONG STDMETHODCALLTYPE Release() { 96 | ULONG ret = InterlockedDecrement(&ref_count_); 97 | if (ret == 0) 98 | delete this; 99 | return ret; 100 | } 101 | 102 | protected: 103 | volatile ULONG ref_count_; 104 | }; 105 | 106 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -------------------------------------------------------------------------------- /codec/uuid.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // MIT License 4 | // 5 | // Copyright(c) 2017 René Slijkhuis 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // The above copyright notice and this permission notice shall be included in all 15 | // copies or substantial portions of the Software. 16 | // 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | // SOFTWARE. 24 | // 25 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 26 | 27 | #pragma once 28 | 29 | // Class ID of the decoder class (WicBitmapDecoder) - {EB68FE9B-B1D7-4E76-8B68-781E5CFB5290} 30 | DEFINE_GUID(CLSID_WicBitmapDecoder, 0xeb68fe9b, 0xb1d7, 0x4e76, 0x8b, 0x68, 0x78, 0x1e, 0x5c, 0xfb, 0x52, 0x90); 31 | 32 | // Class ID of the encoder class (WicBitmapEncoder) - {79CC92AA-B204-4B11-A341-1617D9CD8A88} 33 | DEFINE_GUID(CLSID_WicBitmapEncoder, 0x79cc92aa, 0xb204, 0x4b11, 0xa3, 0x41, 0x16, 0x17, 0xd9, 0xcd, 0x8a, 0x88); 34 | 35 | // Class ID of the IPropertyStore implementation - {308BF946-3857-4083-B2B9-3D19093A7EA2} 36 | DEFINE_GUID(CLSID_PropertyStore, 0x308bf946, 0x3857, 0x4083, 0xb2, 0xb9, 0x3d, 0x19, 0x09, 0x3a, 0x7e, 0xa2); 37 | 38 | // GUID of the container format - {91DFBD70-3D2C-440F-B297-1E2097D4A833} 39 | DEFINE_GUID(GUID_ContainerFormat, 0x91dfbd70, 0x3d2c, 0x440f, 0xb2, 0x97, 0x1e, 0x20, 0x97, 0xd4, 0xa8, 0x33); 40 | 41 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -------------------------------------------------------------------------------- /images/Donald_Trump.lisa: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReneSlijkhuis/example-wic-codec/cfca2cac799b62b835f3174138505374e7456e73/images/Donald_Trump.lisa -------------------------------------------------------------------------------- /images/Hello_Kitty.lisa: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReneSlijkhuis/example-wic-codec/cfca2cac799b62b835f3174138505374e7456e73/images/Hello_Kitty.lisa -------------------------------------------------------------------------------- /installer/Setup-ExampleWicCodec.iss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReneSlijkhuis/example-wic-codec/cfca2cac799b62b835f3174138505374e7456e73/installer/Setup-ExampleWicCodec.iss -------------------------------------------------------------------------------- /redistributables/x64/msvcp120.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReneSlijkhuis/example-wic-codec/cfca2cac799b62b835f3174138505374e7456e73/redistributables/x64/msvcp120.dll -------------------------------------------------------------------------------- /redistributables/x64/msvcr120.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReneSlijkhuis/example-wic-codec/cfca2cac799b62b835f3174138505374e7456e73/redistributables/x64/msvcr120.dll -------------------------------------------------------------------------------- /redistributables/x86/msvcp120.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReneSlijkhuis/example-wic-codec/cfca2cac799b62b835f3174138505374e7456e73/redistributables/x86/msvcp120.dll -------------------------------------------------------------------------------- /redistributables/x86/msvcr120.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ReneSlijkhuis/example-wic-codec/cfca2cac799b62b835f3174138505374e7456e73/redistributables/x86/msvcr120.dll --------------------------------------------------------------------------------