示例#1
0
static HRESULT WINAPI ComponentFactory_CreateDecoderFromFilename(
    IWICComponentFactory *iface, LPCWSTR wzFilename, const GUID *pguidVendor,
    DWORD dwDesiredAccess, WICDecodeOptions metadataOptions,
    IWICBitmapDecoder **ppIDecoder)
{
    IWICStream *stream;
    HRESULT hr;

    TRACE("(%p,%s,%s,%u,%u,%p)\n", iface, debugstr_w(wzFilename),
        debugstr_guid(pguidVendor), dwDesiredAccess, metadataOptions, ppIDecoder);

    hr = StreamImpl_Create(&stream);
    if (SUCCEEDED(hr))
    {
        hr = IWICStream_InitializeFromFilename(stream, wzFilename, dwDesiredAccess);

        if (SUCCEEDED(hr))
        {
            hr = IWICComponentFactory_CreateDecoderFromStream(iface, (IStream*)stream,
                pguidVendor, metadataOptions, ppIDecoder);
        }

        IWICStream_Release(stream);
    }

    return hr;
}
示例#2
0
文件: stream.c 项目: RareHare/reactos
HRESULT stream_initialize_from_filehandle(IWICStream *iface, HANDLE file)
{
    IWICStreamImpl *This = impl_from_IWICStream(iface);
    StreamOnFileHandle *pObject;
    IWICStream *stream = NULL;
    HANDLE map;
    void *mem;
    LARGE_INTEGER size;
    HRESULT hr;
    TRACE("(%p,%p)\n", iface, file);

    if (This->pStream) return WINCODEC_ERR_WRONGSTATE;

    hr = map_file(file, &map, &mem, &size);
    if (FAILED(hr)) return hr;

    hr = StreamImpl_Create(&stream);
    if (FAILED(hr)) goto error;

    hr = IWICStreamImpl_InitializeFromMemory(stream, mem, size.u.LowPart);
    if (FAILED(hr)) goto error;

    pObject = HeapAlloc(GetProcessHeap(), 0, sizeof(StreamOnFileHandle));
    if (!pObject)
    {
        hr = E_OUTOFMEMORY;
        goto error;
    }
    pObject->IStream_iface.lpVtbl = &StreamOnFileHandle_Vtbl;
    pObject->ref = 1;
    pObject->map = map;
    pObject->mem = mem;
    pObject->stream = stream;

    if (InterlockedCompareExchangePointer((void**)&This->pStream, pObject, NULL))
    {
        /* Some other thread set the stream first. */
        IStream_Release(&pObject->IStream_iface);
        return WINCODEC_ERR_WRONGSTATE;
    }
    return S_OK;

error:
    if (stream) IWICStream_Release(stream);
    UnmapViewOfFile(mem);
    CloseHandle(map);
    return hr;
}
示例#3
0
static HRESULT WINAPI ComponentFactory_CreateDecoderFromFileHandle(
    IWICComponentFactory *iface, ULONG_PTR hFile, const GUID *pguidVendor,
    WICDecodeOptions metadataOptions, IWICBitmapDecoder **ppIDecoder)
{
    IWICStream *stream;
    HRESULT hr;

    TRACE("(%p,%lx,%s,%u,%p)\n", iface, hFile, debugstr_guid(pguidVendor),
        metadataOptions, ppIDecoder);

    hr = StreamImpl_Create(&stream);
    if (SUCCEEDED(hr))
    {
        hr = stream_initialize_from_filehandle(stream, (HANDLE)hFile);
        if (SUCCEEDED(hr))
        {
            hr = IWICComponentFactory_CreateDecoderFromStream(iface, (IStream*)stream,
                pguidVendor, metadataOptions, ppIDecoder);
        }
        IWICStream_Release(stream);
    }
    return hr;
}
示例#4
0
static HRESULT WINAPI ComponentFactory_CreateStream(IWICComponentFactory *iface,
    IWICStream **ppIWICStream)
{
    TRACE("(%p,%p)\n", iface, ppIWICStream);
    return StreamImpl_Create(ppIWICStream);
}