Imported Upstream version 5.8.0.22

Former-commit-id: df344e34b07851d296efb3e6604c8db42b6f7aa3
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-10-19 20:04:20 +00:00
parent 5f4a27cc8a
commit 7d05485754
5020 changed files with 114082 additions and 186061 deletions

View File

@@ -10,6 +10,7 @@
//
// Copyright (C) 2002 Ximian, Inc. http://www.ximian.com
// Copyright (C) 2004, 2007 Novell, Inc (http://www.novell.com)
// Copyright (C) 2013 Kristof Ralovich, changes are available under the terms of the MIT X11 license
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -168,6 +169,12 @@ public abstract class Image : MarshalByRefObject, IDisposable , ICloneable, ISer
return img;
}
// For compatiblity with CoreFX sources
internal static Image CreateImageObject (IntPtr nativeImage)
{
return CreateFromHandle (nativeImage);
}
internal static Image CreateFromHandle (IntPtr handle)
{
ImageType type;
@@ -324,7 +331,7 @@ public abstract class Image : MarshalByRefObject, IDisposable , ICloneable, ISer
try {
status = GDIPlus.GdipGetEncoderParameterList (nativeObject, ref encoder, sz, rawEPList);
eps = EncoderParameters.FromNativePtr (rawEPList);
eps = EncoderParameters.ConvertFromMemory (rawEPList);
GDIPlus.CheckStatus (status);
}
finally {
@@ -450,7 +457,7 @@ public abstract class Image : MarshalByRefObject, IDisposable , ICloneable, ISer
if (encoderParams == null) {
st = GDIPlus.GdipSaveImageToFile (nativeObject, filename, ref guid, IntPtr.Zero);
} else {
IntPtr nativeEncoderParams = encoderParams.ToNativePtr ();
IntPtr nativeEncoderParams = encoderParams.ConvertToMemory ();
st = GDIPlus.GdipSaveImageToFile (nativeObject, filename, ref guid, nativeEncoderParams);
Marshal.FreeHGlobal (nativeEncoderParams);
}
@@ -477,7 +484,7 @@ public abstract class Image : MarshalByRefObject, IDisposable , ICloneable, ISer
if (encoderParams == null)
nativeEncoderParams = IntPtr.Zero;
else
nativeEncoderParams = encoderParams.ToNativePtr ();
nativeEncoderParams = encoderParams.ConvertToMemory ();
try {
if (GDIPlus.RunningOnUnix ()) {
@@ -501,7 +508,7 @@ public abstract class Image : MarshalByRefObject, IDisposable , ICloneable, ISer
{
Status st;
IntPtr nativeEncoderParams = encoderParams.ToNativePtr ();
IntPtr nativeEncoderParams = encoderParams.ConvertToMemory ();
st = GDIPlus.GdipSaveAdd (nativeObject, nativeEncoderParams);
Marshal.FreeHGlobal (nativeEncoderParams);
GDIPlus.CheckStatus (st);
@@ -511,7 +518,7 @@ public abstract class Image : MarshalByRefObject, IDisposable , ICloneable, ISer
{
Status st;
IntPtr nativeEncoderParams = encoderParams.ToNativePtr ();
IntPtr nativeEncoderParams = encoderParams.ConvertToMemory ();
st = GDIPlus.GdipSaveAddImage (nativeObject, image.NativeObject, nativeEncoderParams);
Marshal.FreeHGlobal (nativeEncoderParams);
GDIPlus.CheckStatus (st);
@@ -529,16 +536,30 @@ public abstract class Image : MarshalByRefObject, IDisposable , ICloneable, ISer
public void SetPropertyItem(PropertyItem propitem)
{
throw new NotImplementedException ();
/*
GdipPropertyItem pi = new GdipPropertyItem ();
GdipPropertyItem.MarshalTo (pi, propitem);
unsafe {
Status status = GDIPlus.GdipSetPropertyItem (nativeObject, &pi);
if (propitem == null)
throw new ArgumentNullException ("propitem");
int nItemSize = Marshal.SizeOf (propitem.Value[0]);
int size = nItemSize * propitem.Value.Length;
IntPtr dest = Marshal.AllocHGlobal (size);
try {
GdipPropertyItem pi = new GdipPropertyItem ();
pi.id = propitem.Id;
pi.len = propitem.Len;
pi.type = propitem.Type;
Marshal.Copy (propitem.Value, 0, dest, size);
pi.value = dest;
unsafe {
Status status = GDIPlus.GdipSetPropertyItem (nativeObject, &pi);
GDIPlus.CheckStatus (status);
GDIPlus.CheckStatus (status);
}
}
finally {
Marshal.FreeHGlobal (dest);
}
*/
}
// properties
@@ -611,7 +632,7 @@ public abstract class Image : MarshalByRefObject, IDisposable , ICloneable, ISer
try {
st = GDIPlus.GdipGetImagePalette (nativeObject, palette_data, bytes);
GDIPlus.CheckStatus (st);
ret.setFromGDIPalette (palette_data);
ret.ConvertFromMemory (palette_data);
return ret;
}
@@ -625,7 +646,7 @@ public abstract class Image : MarshalByRefObject, IDisposable , ICloneable, ISer
if (palette == null) {
throw new ArgumentNullException("palette");
}
IntPtr palette_data = palette.getGDIPalette();
IntPtr palette_data = palette.ConvertToMemory ();
if (palette_data == IntPtr.Zero) {
return;
}
@@ -776,6 +797,13 @@ public abstract class Image : MarshalByRefObject, IDisposable , ICloneable, ISer
nativeObject = value;
}
}
// For compatiblity with CoreFX sources
internal IntPtr nativeImage {
get {
return nativeObject;
}
}
public void Dispose ()
{