mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +00:00
[WINDOWSCODECS] Sync with Wine Staging 3.9. CORE-14656
This commit is contained in:
parent
3c18f2a7c7
commit
324214f998
16 changed files with 680 additions and 553 deletions
|
@ -45,7 +45,8 @@ typedef struct BitmapImpl {
|
|||
int palette_set;
|
||||
LONG lock; /* 0 if not locked, -1 if locked for writing, count if locked for reading */
|
||||
BYTE *data;
|
||||
BOOL is_section; /* TRUE if data is a section created by an application */
|
||||
void *view; /* used if data is a section created by an application */
|
||||
UINT offset; /* offset into view */
|
||||
UINT width, height;
|
||||
UINT stride;
|
||||
UINT bpp;
|
||||
|
@ -288,8 +289,8 @@ static ULONG WINAPI BitmapImpl_Release(IWICBitmap *iface)
|
|||
if (This->palette) IWICPalette_Release(This->palette);
|
||||
This->cs.DebugInfo->Spare[0] = 0;
|
||||
DeleteCriticalSection(&This->cs);
|
||||
if (This->is_section)
|
||||
UnmapViewOfFile(This->data);
|
||||
if (This->view)
|
||||
UnmapViewOfFile(This->view);
|
||||
else
|
||||
HeapFree(GetProcessHeap(), 0, This->data);
|
||||
HeapFree(GetProcessHeap(), 0, This);
|
||||
|
@ -805,13 +806,13 @@ static const IMILUnknown2Vtbl IMILUnknown2Impl_Vtbl =
|
|||
IMILUnknown2Impl_unknown3
|
||||
};
|
||||
|
||||
HRESULT BitmapImpl_Create(UINT uiWidth, UINT uiHeight,
|
||||
UINT stride, UINT datasize, BYTE *data,
|
||||
REFWICPixelFormatGUID pixelFormat, WICBitmapCreateCacheOption option,
|
||||
HRESULT BitmapImpl_Create(UINT uiWidth, UINT uiHeight, UINT stride, UINT datasize, void *view,
|
||||
UINT offset, REFWICPixelFormatGUID pixelFormat, WICBitmapCreateCacheOption option,
|
||||
IWICBitmap **ppIBitmap)
|
||||
{
|
||||
HRESULT hr;
|
||||
BitmapImpl *This;
|
||||
BYTE *data;
|
||||
UINT bpp;
|
||||
|
||||
hr = get_pixelformat_bpp(pixelFormat, &bpp);
|
||||
|
@ -826,18 +827,12 @@ HRESULT BitmapImpl_Create(UINT uiWidth, UINT uiHeight,
|
|||
This = HeapAlloc(GetProcessHeap(), 0, sizeof(BitmapImpl));
|
||||
if (!This) return E_OUTOFMEMORY;
|
||||
|
||||
if (!data)
|
||||
if (view) data = (BYTE *)view + offset;
|
||||
else if (!(data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, datasize)))
|
||||
{
|
||||
data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, datasize);
|
||||
if (!data)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, This);
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
This->is_section = FALSE;
|
||||
HeapFree(GetProcessHeap(), 0, This);
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
else
|
||||
This->is_section = TRUE;
|
||||
|
||||
This->IWICBitmap_iface.lpVtbl = &BitmapImpl_Vtbl;
|
||||
This->IMILBitmapSource_iface.lpVtbl = &IMILBitmapImpl_Vtbl;
|
||||
|
@ -848,6 +843,8 @@ HRESULT BitmapImpl_Create(UINT uiWidth, UINT uiHeight,
|
|||
This->palette_set = 0;
|
||||
This->lock = 0;
|
||||
This->data = data;
|
||||
This->view = view;
|
||||
This->offset = offset;
|
||||
This->width = uiWidth;
|
||||
This->height = uiHeight;
|
||||
This->stride = stride;
|
||||
|
|
|
@ -1068,20 +1068,9 @@ static HRESULT WINAPI BmpDecoder_GetContainerFormat(IWICBitmapDecoder *iface,
|
|||
static HRESULT WINAPI BmpDecoder_GetDecoderInfo(IWICBitmapDecoder *iface,
|
||||
IWICBitmapDecoderInfo **ppIDecoderInfo)
|
||||
{
|
||||
HRESULT hr;
|
||||
IWICComponentInfo *compinfo;
|
||||
|
||||
TRACE("(%p,%p)\n", iface, ppIDecoderInfo);
|
||||
|
||||
hr = CreateComponentInfo(&CLSID_WICBmpDecoder, &compinfo);
|
||||
if (FAILED(hr)) return hr;
|
||||
|
||||
hr = IWICComponentInfo_QueryInterface(compinfo, &IID_IWICBitmapDecoderInfo,
|
||||
(void**)ppIDecoderInfo);
|
||||
|
||||
IWICComponentInfo_Release(compinfo);
|
||||
|
||||
return hr;
|
||||
return get_decoder_info(&CLSID_WICBmpDecoder, ppIDecoderInfo);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BmpDecoder_CopyPalette(IWICBitmapDecoder *iface,
|
||||
|
|
|
@ -261,8 +261,10 @@ static HRESULT WINAPI BmpFrameEncode_WritePixels(IWICBitmapFrameEncode *iface,
|
|||
UINT lineCount, UINT cbStride, UINT cbBufferSize, BYTE *pbPixels)
|
||||
{
|
||||
BmpFrameEncode *This = impl_from_IWICBitmapFrameEncode(iface);
|
||||
UINT dstbuffersize, bytesperrow, row;
|
||||
BYTE *dst, *src;
|
||||
HRESULT hr;
|
||||
WICRect rc;
|
||||
|
||||
TRACE("(%p,%u,%u,%u,%p)\n", iface, lineCount, cbStride, cbBufferSize, pbPixels);
|
||||
|
||||
if (!This->initialized || !This->width || !This->height || !This->format)
|
||||
|
@ -271,19 +273,27 @@ static HRESULT WINAPI BmpFrameEncode_WritePixels(IWICBitmapFrameEncode *iface,
|
|||
hr = BmpFrameEncode_AllocateBits(This);
|
||||
if (FAILED(hr)) return hr;
|
||||
|
||||
rc.X = 0;
|
||||
rc.Y = 0;
|
||||
rc.Width = This->width;
|
||||
rc.Height = lineCount;
|
||||
bytesperrow = ((This->format->bpp * This->width) + 7) / 8;
|
||||
|
||||
hr = copy_pixels(This->format->bpp, pbPixels, This->width, lineCount, cbStride,
|
||||
&rc, This->stride, This->stride*(This->height-This->lineswritten),
|
||||
This->bits + This->stride*This->lineswritten);
|
||||
if (This->stride < bytesperrow)
|
||||
return E_INVALIDARG;
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
This->lineswritten += lineCount;
|
||||
dstbuffersize = This->stride * (This->height - This->lineswritten);
|
||||
if ((This->stride * (lineCount - 1)) + bytesperrow > dstbuffersize)
|
||||
return E_INVALIDARG;
|
||||
|
||||
return hr;
|
||||
src = pbPixels;
|
||||
dst = This->bits + This->stride * (This->height - This->lineswritten - 1);
|
||||
for (row = 0; row < lineCount; row++)
|
||||
{
|
||||
memcpy(dst, src, bytesperrow);
|
||||
src += cbStride;
|
||||
dst -= This->stride;
|
||||
}
|
||||
|
||||
This->lineswritten += lineCount;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI BmpFrameEncode_WriteSource(IWICBitmapFrameEncode *iface,
|
||||
|
@ -314,11 +324,10 @@ static HRESULT WINAPI BmpFrameEncode_Commit(IWICBitmapFrameEncode *iface)
|
|||
BmpFrameEncode *This = impl_from_IWICBitmapFrameEncode(iface);
|
||||
BITMAPFILEHEADER bfh;
|
||||
BITMAPV5HEADER bih;
|
||||
UINT info_size, i;
|
||||
UINT info_size;
|
||||
LARGE_INTEGER pos;
|
||||
ULONG byteswritten;
|
||||
HRESULT hr;
|
||||
const BYTE *bits;
|
||||
|
||||
TRACE("(%p)\n", iface);
|
||||
|
||||
|
@ -331,7 +340,7 @@ static HRESULT WINAPI BmpFrameEncode_Commit(IWICBitmapFrameEncode *iface)
|
|||
|
||||
bih.bV5Size = info_size = sizeof(BITMAPINFOHEADER);
|
||||
bih.bV5Width = This->width;
|
||||
bih.bV5Height = This->height; /* bottom-top bitmap */
|
||||
bih.bV5Height = This->height;
|
||||
bih.bV5Planes = 1;
|
||||
bih.bV5BitCount = This->format->bpp;
|
||||
bih.bV5Compression = This->format->compression;
|
||||
|
@ -378,15 +387,9 @@ static HRESULT WINAPI BmpFrameEncode_Commit(IWICBitmapFrameEncode *iface)
|
|||
if (byteswritten != This->colors * sizeof(WICColor)) return E_FAIL;
|
||||
}
|
||||
|
||||
/* write the image bits as a bottom-top array */
|
||||
bits = This->bits + bih.bV5SizeImage;
|
||||
for (i = 0; i < This->height; i++)
|
||||
{
|
||||
bits -= This->stride;
|
||||
hr = IStream_Write(This->stream, bits, This->stride, &byteswritten);
|
||||
if (FAILED(hr)) return hr;
|
||||
if (byteswritten != This->stride) return E_FAIL;
|
||||
}
|
||||
hr = IStream_Write(This->stream, This->bits, bih.bV5SizeImage, &byteswritten);
|
||||
if (FAILED(hr)) return hr;
|
||||
if (byteswritten != bih.bV5SizeImage) return E_FAIL;
|
||||
|
||||
This->committed = TRUE;
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
#include "wincodecs_private.h"
|
||||
|
||||
#include "wine/heap.h"
|
||||
#include "wine/debug.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(wincodecs);
|
||||
|
@ -1087,6 +1088,48 @@ static HRESULT copypixels_to_24bppBGR(struct FormatConverter *This, const WICRec
|
|||
}
|
||||
return S_OK;
|
||||
|
||||
case format_32bppCMYK:
|
||||
if (prc)
|
||||
{
|
||||
BYTE *srcdata;
|
||||
UINT srcstride, srcdatasize;
|
||||
|
||||
srcstride = 4 * prc->Width;
|
||||
srcdatasize = srcstride * prc->Height;
|
||||
|
||||
srcdata = heap_alloc(srcdatasize);
|
||||
if (!srcdata) return E_OUTOFMEMORY;
|
||||
|
||||
hr = IWICBitmapSource_CopyPixels(This->source, prc, srcstride, srcdatasize, srcdata);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
INT x, y;
|
||||
BYTE *src = srcdata, *dst = pbBuffer;
|
||||
|
||||
for (y = 0; y < prc->Height; y++)
|
||||
{
|
||||
BYTE *cmyk = src;
|
||||
BYTE *bgr = dst;
|
||||
|
||||
for (x = 0; x < prc->Width; x++)
|
||||
{
|
||||
BYTE c = cmyk[0], m = cmyk[1], y = cmyk[2], k = cmyk[3];
|
||||
bgr[0] = (255 - y) * (255 - k) / 255; /* B */
|
||||
bgr[1] = (255 - m) * (255 - k) / 255; /* G */
|
||||
bgr[2] = (255 - c) * (255 - k) / 255; /* R */
|
||||
cmyk += 4;
|
||||
bgr += 3;
|
||||
}
|
||||
src += srcstride;
|
||||
dst += cbStride;
|
||||
}
|
||||
}
|
||||
|
||||
heap_free(srcdata);
|
||||
return hr;
|
||||
}
|
||||
return S_OK;
|
||||
|
||||
default:
|
||||
FIXME("Unimplemented conversion path!\n");
|
||||
return WINCODEC_ERR_UNSUPPORTEDOPERATION;
|
||||
|
|
|
@ -1176,20 +1176,9 @@ static HRESULT WINAPI GifDecoder_GetContainerFormat(IWICBitmapDecoder *iface,
|
|||
static HRESULT WINAPI GifDecoder_GetDecoderInfo(IWICBitmapDecoder *iface,
|
||||
IWICBitmapDecoderInfo **ppIDecoderInfo)
|
||||
{
|
||||
HRESULT hr;
|
||||
IWICComponentInfo *compinfo;
|
||||
|
||||
TRACE("(%p,%p)\n", iface, ppIDecoderInfo);
|
||||
|
||||
hr = CreateComponentInfo(&CLSID_WICGifDecoder, &compinfo);
|
||||
if (FAILED(hr)) return hr;
|
||||
|
||||
hr = IWICComponentInfo_QueryInterface(compinfo, &IID_IWICBitmapDecoderInfo,
|
||||
(void**)ppIDecoderInfo);
|
||||
|
||||
IWICComponentInfo_Release(compinfo);
|
||||
|
||||
return hr;
|
||||
return get_decoder_info(&CLSID_WICGifDecoder, ppIDecoderInfo);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI GifDecoder_CopyPalette(IWICBitmapDecoder *iface, IWICPalette *palette)
|
||||
|
|
|
@ -556,20 +556,9 @@ static HRESULT WINAPI IcoDecoder_GetContainerFormat(IWICBitmapDecoder *iface,
|
|||
static HRESULT WINAPI IcoDecoder_GetDecoderInfo(IWICBitmapDecoder *iface,
|
||||
IWICBitmapDecoderInfo **ppIDecoderInfo)
|
||||
{
|
||||
HRESULT hr;
|
||||
IWICComponentInfo *compinfo;
|
||||
|
||||
TRACE("(%p,%p)\n", iface, ppIDecoderInfo);
|
||||
|
||||
hr = CreateComponentInfo(&CLSID_WICIcoDecoder, &compinfo);
|
||||
if (FAILED(hr)) return hr;
|
||||
|
||||
hr = IWICComponentInfo_QueryInterface(compinfo, &IID_IWICBitmapDecoderInfo,
|
||||
(void**)ppIDecoderInfo);
|
||||
|
||||
IWICComponentInfo_Release(compinfo);
|
||||
|
||||
return hr;
|
||||
return get_decoder_info(&CLSID_WICIcoDecoder, ppIDecoderInfo);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI IcoDecoder_CopyPalette(IWICBitmapDecoder *iface,
|
||||
|
|
|
@ -477,7 +477,7 @@ static HRESULT WINAPI ComponentFactory_CreateBitmap(IWICComponentFactory *iface,
|
|||
{
|
||||
TRACE("(%p,%u,%u,%s,%u,%p)\n", iface, uiWidth, uiHeight,
|
||||
debugstr_guid(pixelFormat), option, ppIBitmap);
|
||||
return BitmapImpl_Create(uiWidth, uiHeight, 0, 0, NULL, pixelFormat, option, ppIBitmap);
|
||||
return BitmapImpl_Create(uiWidth, uiHeight, 0, 0, NULL, 0, pixelFormat, option, ppIBitmap);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI ComponentFactory_CreateBitmapFromSource(IWICComponentFactory *iface,
|
||||
|
@ -524,7 +524,7 @@ static HRESULT WINAPI ComponentFactory_CreateBitmapFromSource(IWICComponentFacto
|
|||
}
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
hr = BitmapImpl_Create(width, height, 0, 0, NULL, &pixelformat, option, &result);
|
||||
hr = BitmapImpl_Create(width, height, 0, 0, NULL, 0, &pixelformat, option, &result);
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
|
@ -606,7 +606,7 @@ static HRESULT WINAPI ComponentFactory_CreateBitmapFromMemory(IWICComponentFacto
|
|||
|
||||
if (!stride || !size || !buffer || !bitmap) return E_INVALIDARG;
|
||||
|
||||
hr = BitmapImpl_Create(width, height, stride, size, NULL, format, WICBitmapCacheOnLoad, bitmap);
|
||||
hr = BitmapImpl_Create(width, height, stride, size, NULL, 0, format, WICBitmapCacheOnLoad, bitmap);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
IWICBitmapLock *lock;
|
||||
|
@ -738,7 +738,8 @@ static HRESULT WINAPI ComponentFactory_CreateBitmapFromHBITMAP(IWICComponentFact
|
|||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
hr = BitmapImpl_Create(bm.bmWidth, bm.bmHeight, bm.bmWidthBytes, 0, NULL, &format, WICBitmapCacheOnLoad, bitmap);
|
||||
hr = BitmapImpl_Create(bm.bmWidth, bm.bmHeight, bm.bmWidthBytes, 0, NULL, 0, &format,
|
||||
WICBitmapCacheOnLoad, bitmap);
|
||||
if (hr != S_OK) return hr;
|
||||
|
||||
hr = IWICBitmap_Lock(*bitmap, NULL, WICBitmapLockWrite, &lock);
|
||||
|
@ -822,7 +823,7 @@ static HRESULT WINAPI ComponentFactory_CreateBitmapFromHICON(IWICComponentFactor
|
|||
stride = width * 4;
|
||||
size = stride * height;
|
||||
|
||||
hr = BitmapImpl_Create(width, height, stride, size, NULL,
|
||||
hr = BitmapImpl_Create(width, height, stride, size, NULL, 0,
|
||||
&GUID_WICPixelFormat32bppBGRA, WICBitmapCacheOnLoad, bitmap);
|
||||
if (hr != S_OK) goto failed;
|
||||
|
||||
|
@ -1209,15 +1210,19 @@ HRESULT WINAPI WICCreateBitmapFromSectionEx(UINT width, UINT height,
|
|||
REFWICPixelFormatGUID format, HANDLE section, UINT stride,
|
||||
UINT offset, WICSectionAccessLevel wicaccess, IWICBitmap **bitmap)
|
||||
{
|
||||
DWORD access;
|
||||
void *buffer;
|
||||
SYSTEM_INFO sysinfo;
|
||||
UINT bpp, access, size, view_offset, view_size;
|
||||
void *view;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("%u,%u,%s,%p,%u,%#x,%#x,%p\n", width, height, debugstr_guid(format),
|
||||
section, stride, offset, wicaccess, bitmap);
|
||||
TRACE("%u,%u,%s,%p,%u,%u,%#x,%p\n", width, height, debugstr_guid(format),
|
||||
section, stride, offset, wicaccess, bitmap);
|
||||
|
||||
if (!width || !height || !section || !bitmap) return E_INVALIDARG;
|
||||
|
||||
hr = get_pixelformat_bpp(format, &bpp);
|
||||
if (FAILED(hr)) return hr;
|
||||
|
||||
switch (wicaccess)
|
||||
{
|
||||
case WICSectionAccessLevelReadWrite:
|
||||
|
@ -1233,11 +1238,20 @@ HRESULT WINAPI WICCreateBitmapFromSectionEx(UINT width, UINT height,
|
|||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
buffer = MapViewOfFile(section, access, 0, offset, 0);
|
||||
if (!buffer) return HRESULT_FROM_WIN32(GetLastError());
|
||||
if (!stride) stride = (((bpp * width) + 31) / 32) * 4;
|
||||
size = stride * height;
|
||||
if (size / height != stride) return E_INVALIDARG;
|
||||
|
||||
hr = BitmapImpl_Create(width, height, stride, 0, buffer, format, WICBitmapCacheOnLoad, bitmap);
|
||||
if (FAILED(hr)) UnmapViewOfFile(buffer);
|
||||
GetSystemInfo(&sysinfo);
|
||||
view_offset = offset - (offset % sysinfo.dwAllocationGranularity);
|
||||
view_size = size + (offset - view_offset);
|
||||
|
||||
view = MapViewOfFile(section, access, 0, view_offset, view_size);
|
||||
if (!view) return HRESULT_FROM_WIN32(GetLastError());
|
||||
|
||||
offset -= view_offset;
|
||||
hr = BitmapImpl_Create(width, height, stride, 0, view, offset, format, WICBitmapCacheOnLoad, bitmap);
|
||||
if (FAILED(hr)) UnmapViewOfFile(view);
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -50,6 +50,7 @@
|
|||
|
||||
#include "wincodecs_private.h"
|
||||
|
||||
#include "wine/heap.h"
|
||||
#include "wine/debug.h"
|
||||
#include "wine/library.h"
|
||||
|
||||
|
@ -155,6 +156,7 @@ typedef struct {
|
|||
struct jpeg_error_mgr jerr;
|
||||
struct jpeg_source_mgr source_mgr;
|
||||
BYTE source_buffer[1024];
|
||||
UINT bpp, stride;
|
||||
BYTE *image_data;
|
||||
CRITICAL_SECTION lock;
|
||||
} JpegDecoder;
|
||||
|
@ -303,6 +305,8 @@ static HRESULT WINAPI JpegDecoder_Initialize(IWICBitmapDecoder *iface, IStream *
|
|||
int ret;
|
||||
LARGE_INTEGER seek;
|
||||
jmp_buf jmpbuf;
|
||||
UINT data_size, i;
|
||||
|
||||
TRACE("(%p,%p,%u)\n", iface, pIStream, cacheOptions);
|
||||
|
||||
EnterCriticalSection(&This->lock);
|
||||
|
@ -381,6 +385,55 @@ static HRESULT WINAPI JpegDecoder_Initialize(IWICBitmapDecoder *iface, IStream *
|
|||
return E_FAIL;
|
||||
}
|
||||
|
||||
if (This->cinfo.out_color_space == JCS_GRAYSCALE) This->bpp = 8;
|
||||
else if (This->cinfo.out_color_space == JCS_CMYK) This->bpp = 32;
|
||||
else This->bpp = 24;
|
||||
|
||||
This->stride = (This->bpp * This->cinfo.output_width + 7) / 8;
|
||||
data_size = This->stride * This->cinfo.output_height;
|
||||
|
||||
This->image_data = heap_alloc(data_size);
|
||||
if (!This->image_data)
|
||||
{
|
||||
LeaveCriticalSection(&This->lock);
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
while (This->cinfo.output_scanline < This->cinfo.output_height)
|
||||
{
|
||||
UINT first_scanline = This->cinfo.output_scanline;
|
||||
UINT max_rows;
|
||||
JSAMPROW out_rows[4];
|
||||
JDIMENSION ret;
|
||||
|
||||
max_rows = min(This->cinfo.output_height-first_scanline, 4);
|
||||
for (i=0; i<max_rows; i++)
|
||||
out_rows[i] = This->image_data + This->stride * (first_scanline+i);
|
||||
|
||||
ret = pjpeg_read_scanlines(&This->cinfo, out_rows, max_rows);
|
||||
if (ret == 0)
|
||||
{
|
||||
ERR("read_scanlines failed\n");
|
||||
LeaveCriticalSection(&This->lock);
|
||||
return E_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
if (This->bpp == 24)
|
||||
{
|
||||
/* libjpeg gives us RGB data and we want BGR, so byteswap the data */
|
||||
reverse_bgr8(3, This->image_data,
|
||||
This->cinfo.output_width, This->cinfo.output_height,
|
||||
This->stride);
|
||||
}
|
||||
|
||||
if (This->cinfo.out_color_space == JCS_CMYK && This->cinfo.saw_Adobe_marker)
|
||||
{
|
||||
/* Adobe JPEG's have inverted CMYK data. */
|
||||
for (i=0; i<data_size; i++)
|
||||
This->image_data[i] ^= 0xff;
|
||||
}
|
||||
|
||||
This->initialized = TRUE;
|
||||
|
||||
LeaveCriticalSection(&This->lock);
|
||||
|
@ -398,20 +451,9 @@ static HRESULT WINAPI JpegDecoder_GetContainerFormat(IWICBitmapDecoder *iface,
|
|||
static HRESULT WINAPI JpegDecoder_GetDecoderInfo(IWICBitmapDecoder *iface,
|
||||
IWICBitmapDecoderInfo **ppIDecoderInfo)
|
||||
{
|
||||
HRESULT hr;
|
||||
IWICComponentInfo *compinfo;
|
||||
|
||||
TRACE("(%p,%p)\n", iface, ppIDecoderInfo);
|
||||
|
||||
hr = CreateComponentInfo(&CLSID_WICJpegDecoder, &compinfo);
|
||||
if (FAILED(hr)) return hr;
|
||||
|
||||
hr = IWICComponentInfo_QueryInterface(compinfo, &IID_IWICBitmapDecoderInfo,
|
||||
(void**)ppIDecoderInfo);
|
||||
|
||||
IWICComponentInfo_Release(compinfo);
|
||||
|
||||
return hr;
|
||||
return get_decoder_info(&CLSID_WICJpegDecoder, ppIDecoderInfo);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI JpegDecoder_CopyPalette(IWICBitmapDecoder *iface,
|
||||
|
@ -601,104 +643,11 @@ static HRESULT WINAPI JpegDecoder_Frame_CopyPixels(IWICBitmapFrameDecode *iface,
|
|||
const WICRect *prc, UINT cbStride, UINT cbBufferSize, BYTE *pbBuffer)
|
||||
{
|
||||
JpegDecoder *This = impl_from_IWICBitmapFrameDecode(iface);
|
||||
UINT bpp;
|
||||
UINT stride;
|
||||
UINT data_size;
|
||||
UINT max_row_needed;
|
||||
jmp_buf jmpbuf;
|
||||
WICRect rect;
|
||||
|
||||
TRACE("(%p,%p,%u,%u,%p)\n", iface, prc, cbStride, cbBufferSize, pbBuffer);
|
||||
|
||||
if (!prc)
|
||||
{
|
||||
rect.X = 0;
|
||||
rect.Y = 0;
|
||||
rect.Width = This->cinfo.output_width;
|
||||
rect.Height = This->cinfo.output_height;
|
||||
prc = ▭
|
||||
}
|
||||
else
|
||||
{
|
||||
if (prc->X < 0 || prc->Y < 0 || prc->X+prc->Width > This->cinfo.output_width ||
|
||||
prc->Y+prc->Height > This->cinfo.output_height)
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
if (This->cinfo.out_color_space == JCS_GRAYSCALE) bpp = 8;
|
||||
else if (This->cinfo.out_color_space == JCS_CMYK) bpp = 32;
|
||||
else bpp = 24;
|
||||
|
||||
stride = bpp * This->cinfo.output_width;
|
||||
data_size = stride * This->cinfo.output_height;
|
||||
|
||||
max_row_needed = prc->Y + prc->Height;
|
||||
if (max_row_needed > This->cinfo.output_height) return E_INVALIDARG;
|
||||
|
||||
EnterCriticalSection(&This->lock);
|
||||
|
||||
if (!This->image_data)
|
||||
{
|
||||
This->image_data = HeapAlloc(GetProcessHeap(), 0, data_size);
|
||||
if (!This->image_data)
|
||||
{
|
||||
LeaveCriticalSection(&This->lock);
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
This->cinfo.client_data = jmpbuf;
|
||||
|
||||
if (setjmp(jmpbuf))
|
||||
{
|
||||
LeaveCriticalSection(&This->lock);
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
while (max_row_needed > This->cinfo.output_scanline)
|
||||
{
|
||||
UINT first_scanline = This->cinfo.output_scanline;
|
||||
UINT max_rows;
|
||||
JSAMPROW out_rows[4];
|
||||
UINT i;
|
||||
JDIMENSION ret;
|
||||
|
||||
max_rows = min(This->cinfo.output_height-first_scanline, 4);
|
||||
for (i=0; i<max_rows; i++)
|
||||
out_rows[i] = This->image_data + stride * (first_scanline+i);
|
||||
|
||||
ret = pjpeg_read_scanlines(&This->cinfo, out_rows, max_rows);
|
||||
|
||||
if (ret == 0)
|
||||
{
|
||||
ERR("read_scanlines failed\n");
|
||||
LeaveCriticalSection(&This->lock);
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
if (bpp == 24)
|
||||
{
|
||||
/* libjpeg gives us RGB data and we want BGR, so byteswap the data */
|
||||
reverse_bgr8(3, This->image_data + stride * first_scanline,
|
||||
This->cinfo.output_width, This->cinfo.output_scanline - first_scanline,
|
||||
stride);
|
||||
}
|
||||
|
||||
if (This->cinfo.out_color_space == JCS_CMYK && This->cinfo.saw_Adobe_marker)
|
||||
{
|
||||
DWORD *pDwordData = (DWORD*) (This->image_data + stride * first_scanline);
|
||||
DWORD *pDwordDataEnd = (DWORD*) (This->image_data + This->cinfo.output_scanline * stride);
|
||||
|
||||
/* Adobe JPEG's have inverted CMYK data. */
|
||||
while(pDwordData < pDwordDataEnd)
|
||||
*pDwordData++ ^= 0xffffffff;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
LeaveCriticalSection(&This->lock);
|
||||
|
||||
return copy_pixels(bpp, This->image_data,
|
||||
This->cinfo.output_width, This->cinfo.output_height, stride,
|
||||
return copy_pixels(This->bpp, This->image_data,
|
||||
This->cinfo.output_width, This->cinfo.output_height, This->stride,
|
||||
prc, cbStride, cbBufferSize, pbBuffer);
|
||||
}
|
||||
|
||||
|
|
|
@ -42,6 +42,9 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
|||
case DLL_PROCESS_ATTACH:
|
||||
DisableThreadLibraryCalls(hinstDLL);
|
||||
break;
|
||||
case DLL_PROCESS_DETACH:
|
||||
ReleaseComponentInfos();
|
||||
break;
|
||||
}
|
||||
|
||||
return WIC_DllMain(hinstDLL, fdwReason, lpvReserved);
|
||||
|
|
|
@ -829,20 +829,9 @@ static HRESULT WINAPI PngDecoder_GetContainerFormat(IWICBitmapDecoder *iface,
|
|||
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;
|
||||
return get_decoder_info(&CLSID_WICPngDecoder, ppIDecoderInfo);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI PngDecoder_CopyPalette(IWICBitmapDecoder *iface,
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "wincodecs_private.h"
|
||||
|
||||
#include <wine/debug.h>
|
||||
#include <wine/heap.h>
|
||||
#include <wine/library.h>
|
||||
|
||||
#endif /* !WINCODECS_PRECOMP_H */
|
||||
|
|
|
@ -360,20 +360,9 @@ static HRESULT WINAPI TgaDecoder_GetContainerFormat(IWICBitmapDecoder *iface,
|
|||
static HRESULT WINAPI TgaDecoder_GetDecoderInfo(IWICBitmapDecoder *iface,
|
||||
IWICBitmapDecoderInfo **ppIDecoderInfo)
|
||||
{
|
||||
HRESULT hr;
|
||||
IWICComponentInfo *compinfo;
|
||||
|
||||
TRACE("(%p,%p)\n", iface, ppIDecoderInfo);
|
||||
|
||||
hr = CreateComponentInfo(&CLSID_WineTgaDecoder, &compinfo);
|
||||
if (FAILED(hr)) return hr;
|
||||
|
||||
hr = IWICComponentInfo_QueryInterface(compinfo, &IID_IWICBitmapDecoderInfo,
|
||||
(void**)ppIDecoderInfo);
|
||||
|
||||
IWICComponentInfo_Release(compinfo);
|
||||
|
||||
return hr;
|
||||
return get_decoder_info(&CLSID_WineTgaDecoder, ppIDecoderInfo);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI TgaDecoder_CopyPalette(IWICBitmapDecoder *iface,
|
||||
|
|
|
@ -738,20 +738,9 @@ static HRESULT WINAPI TiffDecoder_GetContainerFormat(IWICBitmapDecoder *iface,
|
|||
static HRESULT WINAPI TiffDecoder_GetDecoderInfo(IWICBitmapDecoder *iface,
|
||||
IWICBitmapDecoderInfo **ppIDecoderInfo)
|
||||
{
|
||||
HRESULT hr;
|
||||
IWICComponentInfo *compinfo;
|
||||
|
||||
TRACE("(%p,%p)\n", iface, ppIDecoderInfo);
|
||||
|
||||
hr = CreateComponentInfo(&CLSID_WICTiffDecoder, &compinfo);
|
||||
if (FAILED(hr)) return hr;
|
||||
|
||||
hr = IWICComponentInfo_QueryInterface(compinfo, &IID_IWICBitmapDecoderInfo,
|
||||
(void**)ppIDecoderInfo);
|
||||
|
||||
IWICComponentInfo_Release(compinfo);
|
||||
|
||||
return hr;
|
||||
return get_decoder_info(&CLSID_WICTiffDecoder, ppIDecoderInfo);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI TiffDecoder_CopyPalette(IWICBitmapDecoder *iface,
|
||||
|
|
|
@ -155,7 +155,7 @@ extern HRESULT IcnsEncoder_CreateInstance(REFIID iid, void** ppv) DECLSPEC_HIDDE
|
|||
extern HRESULT TgaDecoder_CreateInstance(REFIID iid, void** ppv) DECLSPEC_HIDDEN;
|
||||
|
||||
extern HRESULT BitmapImpl_Create(UINT uiWidth, UINT uiHeight,
|
||||
UINT stride, UINT datasize, BYTE *bits,
|
||||
UINT stride, UINT datasize, void *view, UINT offset,
|
||||
REFWICPixelFormatGUID pixelFormat, WICBitmapCreateCacheOption option,
|
||||
IWICBitmap **ppIBitmap) DECLSPEC_HIDDEN;
|
||||
extern HRESULT BitmapScaler_Create(IWICBitmapScaler **scaler) DECLSPEC_HIDDEN;
|
||||
|
@ -188,7 +188,9 @@ extern HRESULT CreatePropertyBag2(const PROPBAG2 *options, UINT count,
|
|||
IPropertyBag2 **property) DECLSPEC_HIDDEN;
|
||||
|
||||
extern HRESULT CreateComponentInfo(REFCLSID clsid, IWICComponentInfo **ppIInfo) DECLSPEC_HIDDEN;
|
||||
extern void ReleaseComponentInfos(void) DECLSPEC_HIDDEN;
|
||||
extern HRESULT CreateComponentEnumerator(DWORD componentTypes, DWORD options, IEnumUnknown **ppIEnumUnknown) DECLSPEC_HIDDEN;
|
||||
extern HRESULT get_decoder_info(REFCLSID clsid, IWICBitmapDecoderInfo **info) DECLSPEC_HIDDEN;
|
||||
|
||||
typedef struct BmpDecoder BmpDecoder;
|
||||
|
||||
|
|
|
@ -196,7 +196,7 @@ reactos/dll/win32/version # Synced to WineStaging-3.9
|
|||
reactos/dll/win32/vssapi # Synced to WineStaging-2.9
|
||||
reactos/dll/win32/wbemdisp # Synced to WineStaging-3.3
|
||||
reactos/dll/win32/wbemprox # Synced to WineStaging-3.9
|
||||
reactos/dll/win32/windowscodecs # Synced to WineStaging-3.3
|
||||
reactos/dll/win32/windowscodecs # Synced to WineStaging-3.9
|
||||
reactos/dll/win32/windowscodecsext # Synced to WineStaging-2.9
|
||||
reactos/dll/win32/winemp3.acm # Synced to WineStaging-3.3
|
||||
reactos/dll/win32/wing32 # Synced to WineStaging-3.3
|
||||
|
|
Loading…
Reference in a new issue