gdiplus: Increase refcount of the source stream when loading a bitmap instead of cloning it.
This commit is contained in:
parent
55f160db34
commit
174b74bab2
@ -262,7 +262,7 @@ struct GpAdustableArrowCap{
|
|||||||
|
|
||||||
struct GpImage{
|
struct GpImage{
|
||||||
IPicture *picture;
|
IPicture *picture;
|
||||||
IStream *stream; /* a copy of the source stream */
|
IStream *stream; /* source stream */
|
||||||
ImageType type;
|
ImageType type;
|
||||||
GUID format;
|
GUID format;
|
||||||
UINT flags;
|
UINT flags;
|
||||||
|
@ -2775,6 +2775,8 @@ end:
|
|||||||
bitmap->image.frame_count = frame_count;
|
bitmap->image.frame_count = frame_count;
|
||||||
bitmap->image.current_frame = active_frame;
|
bitmap->image.current_frame = active_frame;
|
||||||
bitmap->image.stream = stream;
|
bitmap->image.stream = stream;
|
||||||
|
/* Pin the source stream */
|
||||||
|
IStream_AddRef(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
@ -2842,7 +2844,7 @@ static GpStatus decode_image_olepicture_metafile(IStream* stream, REFCLSID clsid
|
|||||||
*image = GdipAlloc(sizeof(GpMetafile));
|
*image = GdipAlloc(sizeof(GpMetafile));
|
||||||
if(!*image) return OutOfMemory;
|
if(!*image) return OutOfMemory;
|
||||||
(*image)->type = ImageTypeMetafile;
|
(*image)->type = ImageTypeMetafile;
|
||||||
(*image)->stream = stream;
|
(*image)->stream = NULL;
|
||||||
(*image)->picture = pic;
|
(*image)->picture = pic;
|
||||||
(*image)->flags = ImageFlagsNone;
|
(*image)->flags = ImageFlagsNone;
|
||||||
(*image)->frame_count = 1;
|
(*image)->frame_count = 1;
|
||||||
@ -3011,42 +3013,21 @@ GpStatus WINGDIPAPI GdipImageSelectActiveFrame(GpImage *image, GDIPCONST GUID *d
|
|||||||
return stat;
|
return stat;
|
||||||
}
|
}
|
||||||
|
|
||||||
GpStatus WINGDIPAPI GdipLoadImageFromStream(IStream *source, GpImage **image)
|
GpStatus WINGDIPAPI GdipLoadImageFromStream(IStream *stream, GpImage **image)
|
||||||
{
|
{
|
||||||
GpStatus stat;
|
GpStatus stat;
|
||||||
LARGE_INTEGER seek;
|
LARGE_INTEGER seek;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
const struct image_codec *codec=NULL;
|
const struct image_codec *codec=NULL;
|
||||||
IStream *stream;
|
|
||||||
|
|
||||||
hr = IStream_Clone(source, &stream);
|
|
||||||
if (FAILED(hr))
|
|
||||||
{
|
|
||||||
STATSTG statstg;
|
|
||||||
|
|
||||||
hr = IStream_Stat(source, &statstg, STATFLAG_NOOPEN);
|
|
||||||
if (FAILED(hr)) return hresult_to_status(hr);
|
|
||||||
|
|
||||||
stat = GdipCreateStreamOnFile(statstg.pwcsName, GENERIC_READ, &stream);
|
|
||||||
if(stat != Ok) return stat;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* choose an appropriate image decoder */
|
/* choose an appropriate image decoder */
|
||||||
stat = get_decoder_info(stream, &codec);
|
stat = get_decoder_info(stream, &codec);
|
||||||
if (stat != Ok)
|
if (stat != Ok) return stat;
|
||||||
{
|
|
||||||
IStream_Release(stream);
|
|
||||||
return stat;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* seek to the start of the stream */
|
/* seek to the start of the stream */
|
||||||
seek.QuadPart = 0;
|
seek.QuadPart = 0;
|
||||||
hr = IStream_Seek(stream, seek, STREAM_SEEK_SET, NULL);
|
hr = IStream_Seek(stream, seek, STREAM_SEEK_SET, NULL);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr)) return hresult_to_status(hr);
|
||||||
{
|
|
||||||
IStream_Release(stream);
|
|
||||||
return hresult_to_status(hr);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* call on the image decoder to do the real work */
|
/* call on the image decoder to do the real work */
|
||||||
stat = codec->decode_func(stream, &codec->info.Clsid, 0, image);
|
stat = codec->decode_func(stream, &codec->info.Clsid, 0, image);
|
||||||
@ -3058,7 +3039,6 @@ GpStatus WINGDIPAPI GdipLoadImageFromStream(IStream *source, GpImage **image)
|
|||||||
return Ok;
|
return Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
IStream_Release(stream);
|
|
||||||
return stat;
|
return stat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2693,7 +2693,7 @@ static GpImage *load_image(const BYTE *image_data, UINT image_size)
|
|||||||
|
|
||||||
refcount = IStream_Release(stream);
|
refcount = IStream_Release(stream);
|
||||||
if (image_type == ImageTypeBitmap)
|
if (image_type == ImageTypeBitmap)
|
||||||
todo_wine ok(refcount >= 1, "expected stream refcount != 0\n");
|
ok(refcount >= 1, "expected stream refcount != 0\n");
|
||||||
else
|
else
|
||||||
ok(refcount == 0, "expected stream refcount 0, got %d\n", refcount);
|
ok(refcount == 0, "expected stream refcount 0, got %d\n", refcount);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user