OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkImageGeneratorWIC.h" | 8 #include "SkImageGeneratorWIC.h" |
9 #include "SkIStream.h" | 9 #include "SkIStream.h" |
10 #include "SkStream.h" | 10 #include "SkStream.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 HRESULT hr = CoCreateInstance(CLSID_WICImagingFactory, nullptr, CLSCTX_INPRO
C_SERVER, | 24 HRESULT hr = CoCreateInstance(CLSID_WICImagingFactory, nullptr, CLSCTX_INPRO
C_SERVER, |
25 IID_PPV_ARGS(&imagingFactory)); | 25 IID_PPV_ARGS(&imagingFactory)); |
26 if (FAILED(hr)) { | 26 if (FAILED(hr)) { |
27 return nullptr; | 27 return nullptr; |
28 } | 28 } |
29 | 29 |
30 // Create an IStream. | 30 // Create an IStream. |
31 SkTScopedComPtr<IStream> iStream; | 31 SkTScopedComPtr<IStream> iStream; |
32 // Note that iStream will take ownership of the new memory stream because | 32 // Note that iStream will take ownership of the new memory stream because |
33 // we set |deleteOnRelease| to true. | 33 // we set |deleteOnRelease| to true. |
34 hr = SkIStream::CreateFromSkStream(new SkMemoryStream(data), true, &iStream)
; | 34 hr = SkIStream::CreateFromSkStream(new SkMemoryStream(sk_ref_sp(data)), true
, &iStream); |
35 if (FAILED(hr)) { | 35 if (FAILED(hr)) { |
36 return nullptr; | 36 return nullptr; |
37 } | 37 } |
38 | 38 |
39 // Create the decoder from the stream. | 39 // Create the decoder from the stream. |
40 SkTScopedComPtr<IWICBitmapDecoder> decoder; | 40 SkTScopedComPtr<IWICBitmapDecoder> decoder; |
41 hr = imagingFactory->CreateDecoderFromStream(iStream.get(), nullptr, | 41 hr = imagingFactory->CreateDecoderFromStream(iStream.get(), nullptr, |
42 WICDecodeMetadataCacheOnDemand, &decoder); | 42 WICDecodeMetadataCacheOnDemand, &decoder); |
43 if (FAILED(hr)) { | 43 if (FAILED(hr)) { |
44 return nullptr; | 44 return nullptr; |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 if (FAILED(hr)) { | 166 if (FAILED(hr)) { |
167 return false; | 167 return false; |
168 } | 168 } |
169 | 169 |
170 // Set the destination pixels. | 170 // Set the destination pixels. |
171 hr = formatConverterSrc->CopyPixels(nullptr, (UINT) rowBytes, (UINT) rowByte
s * info.height(), | 171 hr = formatConverterSrc->CopyPixels(nullptr, (UINT) rowBytes, (UINT) rowByte
s * info.height(), |
172 (BYTE*) pixels); | 172 (BYTE*) pixels); |
173 | 173 |
174 return SUCCEEDED(hr); | 174 return SUCCEEDED(hr); |
175 } | 175 } |
OLD | NEW |