Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Remove !! from System.Drawing.Common.
  • Loading branch information
teo-tsirpanis committed Apr 19, 2022
commit 7eeb1dec3ca8cceec8bdd90b13dfd33210c27968
17 changes: 13 additions & 4 deletions src/libraries/System.Drawing.Common/src/System/Drawing/Bitmap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ public Bitmap(Stream stream) : this(stream, false)
{
}

public unsafe Bitmap(Stream stream!!, bool useIcm)
public unsafe Bitmap(Stream stream, bool useIcm)
{
ArgumentNullException.ThrowIfNull(stream);

using DrawingCom.IStreamWrapper streamWrapper = DrawingCom.GetComWrapper(new GPStream(stream));

IntPtr bitmap = IntPtr.Zero;
Expand All @@ -78,8 +80,11 @@ public Bitmap(Type type, string resource) : this(GetResourceStream(type, resourc
{
}

private static Stream GetResourceStream(Type type!!, string resource!!)
private static Stream GetResourceStream(Type type, string resource)
{
ArgumentNullException.ThrowIfNull(type);
ArgumentNullException.ThrowIfNull(resource);

Stream? stream = type.Module.Assembly.GetManifestResourceStream(type, resource);
if (stream == null)
{
Expand All @@ -93,8 +98,10 @@ public Bitmap(int width, int height) : this(width, height, PixelFormat.Format32b
{
}

public Bitmap(int width, int height, Graphics g!!)
public Bitmap(int width, int height, Graphics g)
{
ArgumentNullException.ThrowIfNull(g);

IntPtr bitmap;
int status = Gdip.GdipCreateBitmapFromGraphics(width, height, new HandleRef(g, g.NativeGraphics), out bitmap);
Gdip.CheckStatus(status);
Expand Down Expand Up @@ -128,8 +135,10 @@ public Bitmap(Image original, Size newSize) : this(original, newSize.Width, newS
{
}

public Bitmap(Image original!!, int width, int height) : this(width, height, PixelFormat.Format32bppArgb)
public Bitmap(Image original, int width, int height) : this(width, height, PixelFormat.Format32bppArgb)
{
ArgumentNullException.ThrowIfNull(original);

using (Graphics g = Graphics.FromImage(this))
{
g.Clear(Color.Transparent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ public GraphicsPath(FillMode fillMode)

public GraphicsPath(PointF[] pts, byte[] types) : this(pts, types, FillMode.Alternate) { }

public unsafe GraphicsPath(PointF[] pts!!, byte[] types, FillMode fillMode)
public unsafe GraphicsPath(PointF[] pts, byte[] types, FillMode fillMode)
{
ArgumentNullException.ThrowIfNull(pts);

if (pts.Length != types.Length)
throw Gdip.StatusException(Gdip.InvalidParameter);

Expand All @@ -43,8 +45,10 @@ public unsafe GraphicsPath(PointF[] pts!!, byte[] types, FillMode fillMode)

public GraphicsPath(Point[] pts, byte[] types) : this(pts, types, FillMode.Alternate) { }

public unsafe GraphicsPath(Point[] pts!!, byte[] types, FillMode fillMode)
public unsafe GraphicsPath(Point[] pts, byte[] types, FillMode fillMode)
{
ArgumentNullException.ThrowIfNull(pts);

if (pts.Length != types.Length)
throw Gdip.StatusException(Gdip.InvalidParameter);

Expand Down Expand Up @@ -242,8 +246,10 @@ public bool IsOutlineVisible(float x, float y, Pen pen, Graphics? graphics)
return IsOutlineVisible(new PointF(x, y), pen, graphics);
}

public bool IsOutlineVisible(PointF pt, Pen pen!!, Graphics? graphics)
public bool IsOutlineVisible(PointF pt, Pen pen, Graphics? graphics)
{
ArgumentNullException.ThrowIfNull(pen);

Gdip.CheckStatus(Gdip.GdipIsOutlineVisiblePathPoint(
new HandleRef(this, _nativePath),
pt.X, pt.Y,
Expand All @@ -260,8 +266,10 @@ public bool IsOutlineVisible(PointF pt, Pen pen!!, Graphics? graphics)

public bool IsOutlineVisible(int x, int y, Pen pen, Graphics? graphics) => IsOutlineVisible(new Point(x, y), pen, graphics);

public bool IsOutlineVisible(Point pt, Pen pen!!, Graphics? graphics)
public bool IsOutlineVisible(Point pt, Pen pen, Graphics? graphics)
{
ArgumentNullException.ThrowIfNull(pen);

Gdip.CheckStatus(Gdip.GdipIsOutlineVisiblePathPointI(
new HandleRef(this, _nativePath),
pt.X, pt.Y,
Expand All @@ -279,8 +287,10 @@ public void AddLine(float x1, float y1, float x2, float y2)
Gdip.CheckStatus(Gdip.GdipAddPathLine(new HandleRef(this, _nativePath), x1, y1, x2, y2));
}

public unsafe void AddLines(PointF[] points!!)
public unsafe void AddLines(PointF[] points)
{
ArgumentNullException.ThrowIfNull(points);

if (points.Length == 0)
throw new ArgumentException(null, nameof(points));

Expand All @@ -297,8 +307,10 @@ public void AddLine(int x1, int y1, int x2, int y2)
Gdip.CheckStatus(Gdip.GdipAddPathLineI(new HandleRef(this, _nativePath), x1, y1, x2, y2));
}

public unsafe void AddLines(Point[] points!!)
public unsafe void AddLines(Point[] points)
{
ArgumentNullException.ThrowIfNull(points);

if (points.Length == 0)
throw new ArgumentException(null, nameof(points));

Expand Down Expand Up @@ -348,8 +360,10 @@ public void AddBezier(float x1, float y1, float x2, float y2, float x3, float y3
x1, y1, x2, y2, x3, y3, x4, y4));
}

public unsafe void AddBeziers(PointF[] points!!)
public unsafe void AddBeziers(PointF[] points)
{
ArgumentNullException.ThrowIfNull(points);

fixed (PointF* p = points)
{
Gdip.CheckStatus(Gdip.GdipAddPathBeziers(new HandleRef(this, _nativePath), p, points.Length));
Expand All @@ -368,8 +382,10 @@ public void AddBezier(int x1, int y1, int x2, int y2, int x3, int y3, int x4, in
x1, y1, x2, y2, x3, y3, x4, y4));
}

public unsafe void AddBeziers(params Point[] points!!)
public unsafe void AddBeziers(params Point[] points)
{
ArgumentNullException.ThrowIfNull(points);

if (points.Length == 0)
return;

Expand All @@ -382,16 +398,20 @@ public unsafe void AddBeziers(params Point[] points!!)
/// <summary>
/// Add cardinal splines to the path object
/// </summary>
public unsafe void AddCurve(PointF[] points!!)
public unsafe void AddCurve(PointF[] points)
{
ArgumentNullException.ThrowIfNull(points);

fixed (PointF* p = points)
{
Gdip.CheckStatus(Gdip.GdipAddPathCurve(new HandleRef(this, _nativePath), p, points.Length));
}
}

public unsafe void AddCurve(PointF[] points!!, float tension)
public unsafe void AddCurve(PointF[] points, float tension)
{
ArgumentNullException.ThrowIfNull(points);

if (points.Length == 0)
return;

Expand All @@ -401,68 +421,84 @@ public unsafe void AddCurve(PointF[] points!!, float tension)
}
}

public unsafe void AddCurve(PointF[] points!!, int offset, int numberOfSegments, float tension)
public unsafe void AddCurve(PointF[] points, int offset, int numberOfSegments, float tension)
{
ArgumentNullException.ThrowIfNull(points);

fixed (PointF* p = points)
{
Gdip.CheckStatus(Gdip.GdipAddPathCurve3(
new HandleRef(this, _nativePath), p, points.Length, offset, numberOfSegments, tension));
}
}

public unsafe void AddCurve(Point[] points!!)
public unsafe void AddCurve(Point[] points)
{
ArgumentNullException.ThrowIfNull(points);

fixed (Point* p = points)
{
Gdip.CheckStatus(Gdip.GdipAddPathCurveI(new HandleRef(this, _nativePath), p, points.Length));
}
}

public unsafe void AddCurve(Point[] points!!, float tension)
public unsafe void AddCurve(Point[] points, float tension)
{
ArgumentNullException.ThrowIfNull(points);

fixed (Point* p = points)
{
Gdip.CheckStatus(Gdip.GdipAddPathCurve2I(
new HandleRef(this, _nativePath), p, points.Length, tension));
}
}

public unsafe void AddCurve(Point[] points!!, int offset, int numberOfSegments, float tension)
public unsafe void AddCurve(Point[] points, int offset, int numberOfSegments, float tension)
{
ArgumentNullException.ThrowIfNull(points);

fixed (Point* p = points)
{
Gdip.CheckStatus(Gdip.GdipAddPathCurve3I(
new HandleRef(this, _nativePath), p, points.Length, offset, numberOfSegments, tension));
}
}

public unsafe void AddClosedCurve(PointF[] points!!)
public unsafe void AddClosedCurve(PointF[] points)
{
ArgumentNullException.ThrowIfNull(points);

fixed (PointF* p = points)
{
Gdip.CheckStatus(Gdip.GdipAddPathClosedCurve(
new HandleRef(this, _nativePath), p, points.Length));
}
}

public unsafe void AddClosedCurve(PointF[] points!!, float tension)
public unsafe void AddClosedCurve(PointF[] points, float tension)
{
ArgumentNullException.ThrowIfNull(points);

fixed (PointF* p = points)
{
Gdip.CheckStatus(Gdip.GdipAddPathClosedCurve2(new HandleRef(this, _nativePath), p, points.Length, tension));
}
}

public unsafe void AddClosedCurve(Point[] points!!)
public unsafe void AddClosedCurve(Point[] points)
{
ArgumentNullException.ThrowIfNull(points);

fixed (Point* p = points)
{
Gdip.CheckStatus(Gdip.GdipAddPathClosedCurveI(new HandleRef(this, _nativePath), p, points.Length));
}
}

public unsafe void AddClosedCurve(Point[] points!!, float tension)
public unsafe void AddClosedCurve(Point[] points, float tension)
{
ArgumentNullException.ThrowIfNull(points);

fixed (Point* p = points)
{
Gdip.CheckStatus(Gdip.GdipAddPathClosedCurve2I(new HandleRef(this, _nativePath), p, points.Length, tension));
Expand All @@ -476,8 +512,10 @@ public void AddRectangle(RectangleF rect)
rect.X, rect.Y, rect.Width, rect.Height));
}

public unsafe void AddRectangles(RectangleF[] rects!!)
public unsafe void AddRectangles(RectangleF[] rects)
{
ArgumentNullException.ThrowIfNull(rects);

if (rects.Length == 0)
throw new ArgumentException(null, nameof(rects));

Expand All @@ -495,8 +533,10 @@ public void AddRectangle(Rectangle rect)
rect.X, rect.Y, rect.Width, rect.Height));
}

public unsafe void AddRectangles(Rectangle[] rects!!)
public unsafe void AddRectangles(Rectangle[] rects)
{
ArgumentNullException.ThrowIfNull(rects);

if (rects.Length == 0)
throw new ArgumentException(null, nameof(rects));

Expand Down Expand Up @@ -547,8 +587,10 @@ public void AddPie(int x, int y, int width, int height, float startAngle, float
sweepAngle));
}

public unsafe void AddPolygon(PointF[] points!!)
public unsafe void AddPolygon(PointF[] points)
{
ArgumentNullException.ThrowIfNull(points);

fixed (PointF* p = points)
{
Gdip.CheckStatus(Gdip.GdipAddPathPolygon(new HandleRef(this, _nativePath), p, points.Length));
Expand All @@ -558,16 +600,20 @@ public unsafe void AddPolygon(PointF[] points!!)
/// <summary>
/// Adds a polygon to the current figure.
/// </summary>
public unsafe void AddPolygon(Point[] points!!)
public unsafe void AddPolygon(Point[] points)
{
ArgumentNullException.ThrowIfNull(points);

fixed (Point* p = points)
{
Gdip.CheckStatus(Gdip.GdipAddPathPolygonI(new HandleRef(this, _nativePath), p, points.Length));
}
}

public void AddPath(GraphicsPath addingPath!!, bool connect)
public void AddPath(GraphicsPath addingPath, bool connect)
{
ArgumentNullException.ThrowIfNull(addingPath);

Gdip.CheckStatus(Gdip.GdipAddPathPath(
new HandleRef(this, _nativePath), new HandleRef(addingPath, addingPath._nativePath), connect));
}
Expand All @@ -582,8 +628,10 @@ public void AddString(string s, FontFamily family, int style, float emSize, Poin
AddString(s, family, style, emSize, new Rectangle(origin.X, origin.Y, 0, 0), format);
}

public void AddString(string s, FontFamily family!!, int style, float emSize, RectangleF layoutRect, StringFormat? format)
public void AddString(string s, FontFamily family, int style, float emSize, RectangleF layoutRect, StringFormat? format)
{
ArgumentNullException.ThrowIfNull(family);

Gdip.CheckStatus(Gdip.GdipAddPathString(
new HandleRef(this, _nativePath),
s,
Expand All @@ -595,8 +643,10 @@ public void AddString(string s, FontFamily family!!, int style, float emSize, Re
new HandleRef(format, format?.nativeFormat ?? IntPtr.Zero)));
}

public void AddString(string s, FontFamily family!!, int style, float emSize, Rectangle layoutRect, StringFormat? format)
public void AddString(string s, FontFamily family, int style, float emSize, Rectangle layoutRect, StringFormat? format)
{
ArgumentNullException.ThrowIfNull(family);

Gdip.CheckStatus(Gdip.GdipAddPathStringI(
new HandleRef(this, _nativePath),
s,
Expand All @@ -608,8 +658,10 @@ public void AddString(string s, FontFamily family!!, int style, float emSize, Re
new HandleRef(format, format?.nativeFormat ?? IntPtr.Zero)));
}

public void Transform(Matrix matrix!!)
public void Transform(Matrix matrix)
{
ArgumentNullException.ThrowIfNull(matrix);

if (matrix.NativeMatrix == IntPtr.Zero)
return;

Expand Down Expand Up @@ -649,8 +701,10 @@ public void Flatten(Matrix? matrix, float flatness)

public void Widen(Pen pen, Matrix? matrix) => Widen(pen, matrix, Flatness);

public void Widen(Pen pen!!, Matrix? matrix, float flatness)
public void Widen(Pen pen, Matrix? matrix, float flatness)
{
ArgumentNullException.ThrowIfNull(pen);

// GDI+ wrongly returns an out of memory status when there is nothing in the path, so we have to check
// before calling the widen method and do nothing if we dont have anything in the path.
if (PointCount == 0)
Expand All @@ -672,8 +726,10 @@ public void Warp(PointF[] destPoints, RectangleF srcRect, Matrix? matrix, WarpMo
Warp(destPoints, srcRect, matrix, warpMode, 0.25f);
}

public unsafe void Warp(PointF[] destPoints!!, RectangleF srcRect, Matrix? matrix, WarpMode warpMode, float flatness)
public unsafe void Warp(PointF[] destPoints, RectangleF srcRect, Matrix? matrix, WarpMode warpMode, float flatness)
{
ArgumentNullException.ThrowIfNull(destPoints);

fixed (PointF* p = destPoints)
{
Gdip.CheckStatus(Gdip.GdipWarpPath(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,8 +476,10 @@ public void ResetTransform()

public void MultiplyTransform(Matrix matrix) => MultiplyTransform(matrix, MatrixOrder.Prepend);

public void MultiplyTransform(Matrix matrix!!, MatrixOrder order)
public void MultiplyTransform(Matrix matrix, MatrixOrder order)
{
ArgumentNullException.ThrowIfNull(matrix);

// Multiplying the transform by a disposed matrix is a nop in GDI+, but throws
// with the libgdiplus backend. Simulate a nop for compatability with GDI+.
if (matrix.NativeMatrix == IntPtr.Zero)
Expand Down
Loading