pngformat.c (324214f9) | pngformat.c (e98ef499) |
---|---|
1/* 2 * Copyright 2009 Vincent Povirk for CodeWeavers 3 * Copyright 2016 Dmitry Timoshkov 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Lesser General Public 7 * License as published by the Free Software Foundation; either 8 * version 2.1 of the License, or (at your option) any later version. --- 830 unchanged lines hidden (view full) --- 839{ 840 TRACE("(%p,%p)\n", iface, palette); 841 return WINCODEC_ERR_PALETTEUNAVAILABLE; 842} 843 844static HRESULT WINAPI PngDecoder_GetMetadataQueryReader(IWICBitmapDecoder *iface, 845 IWICMetadataQueryReader **reader) 846{ | 1/* 2 * Copyright 2009 Vincent Povirk for CodeWeavers 3 * Copyright 2016 Dmitry Timoshkov 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Lesser General Public 7 * License as published by the Free Software Foundation; either 8 * version 2.1 of the License, or (at your option) any later version. --- 830 unchanged lines hidden (view full) --- 839{ 840 TRACE("(%p,%p)\n", iface, palette); 841 return WINCODEC_ERR_PALETTEUNAVAILABLE; 842} 843 844static HRESULT WINAPI PngDecoder_GetMetadataQueryReader(IWICBitmapDecoder *iface, 845 IWICMetadataQueryReader **reader) 846{ |
847 FIXME("(%p,%p): stub\n", iface, reader); | 847 TRACE("(%p,%p)\n", iface, reader); |
848 849 if (!reader) return E_INVALIDARG; 850 851 *reader = NULL; 852 return WINCODEC_ERR_UNSUPPORTEDOPERATION; 853} 854 855static HRESULT WINAPI PngDecoder_GetPreview(IWICBitmapDecoder *iface, --- 200 unchanged lines hidden (view full) --- 1056 { 1057 BYTE alpha = (i < num_trans) ? trans_alpha[i] : 0xff; 1058 palette[i] = (alpha << 24 | 1059 png_palette[i].red << 16| 1060 png_palette[i].green << 8| 1061 png_palette[i].blue); 1062 } 1063 } | 848 849 if (!reader) return E_INVALIDARG; 850 851 *reader = NULL; 852 return WINCODEC_ERR_UNSUPPORTEDOPERATION; 853} 854 855static HRESULT WINAPI PngDecoder_GetPreview(IWICBitmapDecoder *iface, --- 200 unchanged lines hidden (view full) --- 1056 { 1057 BYTE alpha = (i < num_trans) ? trans_alpha[i] : 0xff; 1058 palette[i] = (alpha << 24 | 1059 png_palette[i].red << 16| 1060 png_palette[i].green << 8| 1061 png_palette[i].blue); 1062 } 1063 } |
1064 else if (color_type == PNG_COLOR_TYPE_GRAY) { | 1064 else if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth <= 8) { |
1065 ret = ppng_get_tRNS(This->png_ptr, This->info_ptr, &trans_alpha, &num_trans, &trans_values); 1066 1067 if (!ret) 1068 { 1069 hr = WINCODEC_ERR_PALETTEUNAVAILABLE; 1070 goto end; 1071 } 1072 --- 20 unchanged lines hidden (view full) --- 1093 1094 return hr; 1095} 1096 1097static HRESULT WINAPI PngDecoder_Frame_CopyPixels(IWICBitmapFrameDecode *iface, 1098 const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer) 1099{ 1100 PngDecoder *This = impl_from_IWICBitmapFrameDecode(iface); | 1065 ret = ppng_get_tRNS(This->png_ptr, This->info_ptr, &trans_alpha, &num_trans, &trans_values); 1066 1067 if (!ret) 1068 { 1069 hr = WINCODEC_ERR_PALETTEUNAVAILABLE; 1070 goto end; 1071 } 1072 --- 20 unchanged lines hidden (view full) --- 1093 1094 return hr; 1095} 1096 1097static HRESULT WINAPI PngDecoder_Frame_CopyPixels(IWICBitmapFrameDecode *iface, 1098 const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer) 1099{ 1100 PngDecoder *This = impl_from_IWICBitmapFrameDecode(iface); |
1101 TRACE("(%p,%p,%u,%u,%p)\n", iface, prc, cbStride, cbBufferSize, pbBuffer); | 1101 TRACE("(%p,%s,%u,%u,%p)\n", iface, debug_wic_rect(prc), cbStride, cbBufferSize, pbBuffer); |
1102 1103 return copy_pixels(This->bpp, This->image_bits, 1104 This->width, This->height, This->stride, 1105 prc, cbStride, cbBufferSize, pbBuffer); 1106} 1107 1108static HRESULT WINAPI PngDecoder_Frame_GetMetadataQueryReader(IWICBitmapFrameDecode *iface, 1109 IWICMetadataQueryReader **ppIMetadataQueryReader) --- 129 unchanged lines hidden (view full) --- 1239 hr = StreamImpl_Create(&stream); 1240 1241 if (SUCCEEDED(hr)) 1242 { 1243 hr = IWICStream_InitializeFromIStreamRegion(stream, This->stream, 1244 This->metadata_blocks[nIndex].ofs, This->metadata_blocks[nIndex].len); 1245 1246 if (SUCCEEDED(hr)) | 1102 1103 return copy_pixels(This->bpp, This->image_bits, 1104 This->width, This->height, This->stride, 1105 prc, cbStride, cbBufferSize, pbBuffer); 1106} 1107 1108static HRESULT WINAPI PngDecoder_Frame_GetMetadataQueryReader(IWICBitmapFrameDecode *iface, 1109 IWICMetadataQueryReader **ppIMetadataQueryReader) --- 129 unchanged lines hidden (view full) --- 1239 hr = StreamImpl_Create(&stream); 1240 1241 if (SUCCEEDED(hr)) 1242 { 1243 hr = IWICStream_InitializeFromIStreamRegion(stream, This->stream, 1244 This->metadata_blocks[nIndex].ofs, This->metadata_blocks[nIndex].len); 1245 1246 if (SUCCEEDED(hr)) |
1247 hr = ComponentFactory_CreateInstance(&IID_IWICComponentFactory, (void**)&factory); | 1247 hr = ImagingFactory_CreateInstance(&IID_IWICComponentFactory, (void**)&factory); |
1248 1249 if (SUCCEEDED(hr)) 1250 { 1251 hr = IWICComponentFactory_CreateMetadataReaderFromContainer(factory, 1252 &GUID_ContainerFormatPng, NULL, WICMetadataCreationAllowUnknown, 1253 (IStream*)stream, &This->metadata_blocks[nIndex].reader); 1254 1255 IWICComponentFactory_Release(factory); --- 184 unchanged lines hidden (view full) --- 1440 1441 opts[0].pstrName = (LPOLESTR)wszPngInterlaceOption; 1442 opts[0].vt = VT_BOOL; 1443 opts[1].pstrName = (LPOLESTR)wszPngFilterOption; 1444 opts[1].vt = VT_UI1; 1445 1446 if (pIEncoderOptions) 1447 { | 1248 1249 if (SUCCEEDED(hr)) 1250 { 1251 hr = IWICComponentFactory_CreateMetadataReaderFromContainer(factory, 1252 &GUID_ContainerFormatPng, NULL, WICMetadataCreationAllowUnknown, 1253 (IStream*)stream, &This->metadata_blocks[nIndex].reader); 1254 1255 IWICComponentFactory_Release(factory); --- 184 unchanged lines hidden (view full) --- 1440 1441 opts[0].pstrName = (LPOLESTR)wszPngInterlaceOption; 1442 opts[0].vt = VT_BOOL; 1443 opts[1].pstrName = (LPOLESTR)wszPngFilterOption; 1444 opts[1].vt = VT_UI1; 1445 1446 if (pIEncoderOptions) 1447 { |
1448 hr = IPropertyBag2_Read(pIEncoderOptions, sizeof(opts)/sizeof(opts[0]), opts, NULL, opt_values, opt_hres); | 1448 hr = IPropertyBag2_Read(pIEncoderOptions, ARRAY_SIZE(opts), opts, NULL, opt_values, opt_hres); |
1449 1450 if (FAILED(hr)) 1451 return hr; 1452 1453 if (V_VT(&opt_values[0]) == VT_EMPTY) 1454 interlace = FALSE; 1455 else 1456 interlace = (V_BOOL(&opt_values[0]) != 0); --- 287 unchanged lines hidden (view full) --- 1744 return S_OK; 1745} 1746 1747static HRESULT WINAPI PngFrameEncode_WriteSource(IWICBitmapFrameEncode *iface, 1748 IWICBitmapSource *pIBitmapSource, WICRect *prc) 1749{ 1750 PngEncoder *This = impl_from_IWICBitmapFrameEncode(iface); 1751 HRESULT hr; | 1449 1450 if (FAILED(hr)) 1451 return hr; 1452 1453 if (V_VT(&opt_values[0]) == VT_EMPTY) 1454 interlace = FALSE; 1455 else 1456 interlace = (V_BOOL(&opt_values[0]) != 0); --- 287 unchanged lines hidden (view full) --- 1744 return S_OK; 1745} 1746 1747static HRESULT WINAPI PngFrameEncode_WriteSource(IWICBitmapFrameEncode *iface, 1748 IWICBitmapSource *pIBitmapSource, WICRect *prc) 1749{ 1750 PngEncoder *This = impl_from_IWICBitmapFrameEncode(iface); 1751 HRESULT hr; |
1752 TRACE("(%p,%p,%p)\n", iface, pIBitmapSource, prc); | 1752 TRACE("(%p,%p,%s)\n", iface, pIBitmapSource, debug_wic_rect(prc)); |
1753 1754 if (!This->frame_initialized) 1755 return WINCODEC_ERR_WRONGSTATE; 1756 1757 hr = configure_write_source(iface, pIBitmapSource, prc, 1758 This->format ? This->format->guid : NULL, This->width, This->height, 1759 This->xres, This->yres); 1760 --- 206 unchanged lines hidden (view full) --- 1967 /* set up custom i/o handling */ 1968 ppng_set_write_fn(This->png_ptr, This, user_write_data, user_flush); 1969 1970 LeaveCriticalSection(&This->lock); 1971 1972 return S_OK; 1973} 1974 | 1753 1754 if (!This->frame_initialized) 1755 return WINCODEC_ERR_WRONGSTATE; 1756 1757 hr = configure_write_source(iface, pIBitmapSource, prc, 1758 This->format ? This->format->guid : NULL, This->width, This->height, 1759 This->xres, This->yres); 1760 --- 206 unchanged lines hidden (view full) --- 1967 /* set up custom i/o handling */ 1968 ppng_set_write_fn(This->png_ptr, This, user_write_data, user_flush); 1969 1970 LeaveCriticalSection(&This->lock); 1971 1972 return S_OK; 1973} 1974 |
1975static HRESULT WINAPI PngEncoder_GetContainerFormat(IWICBitmapEncoder *iface, 1976 GUID *pguidContainerFormat) | 1975static HRESULT WINAPI PngEncoder_GetContainerFormat(IWICBitmapEncoder *iface, GUID *format) |
1977{ | 1976{ |
1978 FIXME("(%p,%s): stub\n", iface, debugstr_guid(pguidContainerFormat)); 1979 return E_NOTIMPL; | 1977 TRACE("(%p,%p)\n", iface, format); 1978 1979 if (!format) 1980 return E_INVALIDARG; 1981 1982 memcpy(format, &GUID_ContainerFormatPng, sizeof(*format)); 1983 return S_OK; |
1980} 1981 1982static HRESULT WINAPI PngEncoder_GetEncoderInfo(IWICBitmapEncoder *iface, IWICBitmapEncoderInfo **info) 1983{ 1984 IWICComponentInfo *comp_info; 1985 HRESULT hr; 1986 1987 TRACE("%p,%p\n", iface, info); --- 68 unchanged lines hidden (view full) --- 2056 if (!This->stream) 2057 { 2058 LeaveCriticalSection(&This->lock); 2059 return WINCODEC_ERR_NOTINITIALIZED; 2060 } 2061 2062 if (ppIEncoderOptions) 2063 { | 1984} 1985 1986static HRESULT WINAPI PngEncoder_GetEncoderInfo(IWICBitmapEncoder *iface, IWICBitmapEncoderInfo **info) 1987{ 1988 IWICComponentInfo *comp_info; 1989 HRESULT hr; 1990 1991 TRACE("%p,%p\n", iface, info); --- 68 unchanged lines hidden (view full) --- 2060 if (!This->stream) 2061 { 2062 LeaveCriticalSection(&This->lock); 2063 return WINCODEC_ERR_NOTINITIALIZED; 2064 } 2065 2066 if (ppIEncoderOptions) 2067 { |
2064 hr = CreatePropertyBag2(opts, sizeof(opts)/sizeof(opts[0]), ppIEncoderOptions); | 2068 hr = CreatePropertyBag2(opts, ARRAY_SIZE(opts), ppIEncoderOptions); |
2065 if (FAILED(hr)) 2066 { 2067 LeaveCriticalSection(&This->lock); 2068 return hr; 2069 } 2070 } 2071 2072 This->frame_count = 1; --- 113 unchanged lines hidden --- | 2069 if (FAILED(hr)) 2070 { 2071 LeaveCriticalSection(&This->lock); 2072 return hr; 2073 } 2074 } 2075 2076 This->frame_count = 1; --- 113 unchanged lines hidden --- |