static HRESULT WINAPI BmpEncoder_GetEncoderInfo(IWICBitmapEncoder *iface, IWICBitmapEncoderInfo **info) { IWICComponentInfo *comp_info; HRESULT hr; TRACE("%p,%p\n", iface, info); if (!info) return E_INVALIDARG; hr = CreateComponentInfo(&CLSID_WICBmpEncoder, &comp_info); if (hr == S_OK) { hr = IWICComponentInfo_QueryInterface(comp_info, &IID_IWICBitmapEncoderInfo, (void **)info); IWICComponentInfo_Release(comp_info); } return hr; }
static HRESULT WINAPI PngDecoder_GetDecoderInfo(IWICBitmapDecoder *iface, IWICBitmapDecoderInfo **ppIDecoderInfo) { HRESULT hr; IWICComponentInfo *compinfo; TRACE("(%p,%p)\n", iface, ppIDecoderInfo); hr = CreateComponentInfo(&CLSID_WICPngDecoder, &compinfo); if (FAILED(hr)) return hr; hr = IWICComponentInfo_QueryInterface(compinfo, &IID_IWICBitmapDecoderInfo, (void**)ppIDecoderInfo); IWICComponentInfo_Release(compinfo); return hr; }
static HRESULT WINAPI MetadataHandler_GetMetadataHandlerInfo(IWICMetadataWriter *iface, IWICMetadataHandlerInfo **ppIHandler) { HRESULT hr; IWICComponentInfo *component_info; MetadataHandler *This = impl_from_IWICMetadataWriter(iface); TRACE("%p,%p\n", iface, ppIHandler); hr = CreateComponentInfo(This->vtable->clsid, &component_info); if (FAILED(hr)) return hr; hr = IWICComponentInfo_QueryInterface(component_info, &IID_IWICMetadataHandlerInfo, (void **)ppIHandler); IWICComponentInfo_Release(component_info); return hr; }
HRESULT get_pixelformat_bpp(const GUID *pixelformat, UINT *bpp) { HRESULT hr; IWICComponentInfo *info; IWICPixelFormatInfo *formatinfo; hr = CreateComponentInfo(pixelformat, &info); if (SUCCEEDED(hr)) { hr = IWICComponentInfo_QueryInterface(info, &IID_IWICPixelFormatInfo, (void**)&formatinfo); if (SUCCEEDED(hr)) { hr = IWICPixelFormatInfo_GetBitsPerPixel(formatinfo, bpp); IWICPixelFormatInfo_Release(formatinfo); } IWICComponentInfo_Release(info); } return hr; }
static HRESULT WINAPI ComponentFactory_CreateBitmapFromSource(IWICComponentFactory *iface, IWICBitmapSource *piBitmapSource, WICBitmapCreateCacheOption option, IWICBitmap **ppIBitmap) { IWICBitmap *result; IWICBitmapLock *lock; IWICPalette *palette; UINT width, height; WICPixelFormatGUID pixelformat = {0}; HRESULT hr; WICRect rc; double dpix, dpiy; IWICComponentInfo *info; IWICPixelFormatInfo2 *formatinfo; WICPixelFormatNumericRepresentation format_type; TRACE("(%p,%p,%u,%p)\n", iface, piBitmapSource, option, ppIBitmap); if (!piBitmapSource || !ppIBitmap) return E_INVALIDARG; hr = IWICBitmapSource_GetSize(piBitmapSource, &width, &height); if (SUCCEEDED(hr)) hr = IWICBitmapSource_GetPixelFormat(piBitmapSource, &pixelformat); if (SUCCEEDED(hr)) hr = CreateComponentInfo(&pixelformat, &info); if (SUCCEEDED(hr)) { hr = IWICComponentInfo_QueryInterface(info, &IID_IWICPixelFormatInfo2, (void**)&formatinfo); if (SUCCEEDED(hr)) { hr = IWICPixelFormatInfo2_GetNumericRepresentation(formatinfo, &format_type); IWICPixelFormatInfo2_Release(formatinfo); } IWICComponentInfo_Release(info); } if (SUCCEEDED(hr)) hr = BitmapImpl_Create(width, height, &pixelformat, option, &result); if (SUCCEEDED(hr)) { hr = IWICBitmap_Lock(result, NULL, WICBitmapLockWrite, &lock); if (SUCCEEDED(hr)) { UINT stride, buffersize; BYTE *buffer; rc.X = rc.Y = 0; rc.Width = width; rc.Height = height; hr = IWICBitmapLock_GetStride(lock, &stride); if (SUCCEEDED(hr)) hr = IWICBitmapLock_GetDataPointer(lock, &buffersize, &buffer); if (SUCCEEDED(hr)) hr = IWICBitmapSource_CopyPixels(piBitmapSource, &rc, stride, buffersize, buffer); IWICBitmapLock_Release(lock); } if (SUCCEEDED(hr)) hr = PaletteImpl_Create(&palette); if (SUCCEEDED(hr) && (format_type == WICPixelFormatNumericRepresentationUnspecified || format_type == WICPixelFormatNumericRepresentationIndexed)) { hr = IWICBitmapSource_CopyPalette(piBitmapSource, palette); if (SUCCEEDED(hr)) hr = IWICBitmap_SetPalette(result, palette); else hr = S_OK; IWICPalette_Release(palette); } if (SUCCEEDED(hr)) { hr = IWICBitmapSource_GetResolution(piBitmapSource, &dpix, &dpiy); if (SUCCEEDED(hr)) hr = IWICBitmap_SetResolution(result, dpix, dpiy); else hr = S_OK; } if (SUCCEEDED(hr)) *ppIBitmap = result; else IWICBitmap_Release(result); } return hr; }
static HRESULT WINAPI ComponentFactory_CreateComponentInfo(IWICComponentFactory *iface, REFCLSID clsidComponent, IWICComponentInfo **ppIInfo) { TRACE("(%p,%s,%p)\n", iface, debugstr_guid(clsidComponent), ppIInfo); return CreateComponentInfo(clsidComponent, ppIInfo); }