Skip to content

Commit

Permalink
Improve error checking
Browse files Browse the repository at this point in the history
svn path=/trunk/mcs/; revision=24285
  • Loading branch information
migueldeicaza committed Mar 18, 2004
1 parent 9360275 commit a4b9a48
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
7 changes: 6 additions & 1 deletion mcs/class/System.Drawing/System.Drawing/Bitmap.cs
Expand Up @@ -152,7 +152,12 @@ public Bitmap (string filename, bool useIcm)

public Bitmap (Type type, string resource)
{
throw new NotImplementedException ();
using (Stream s = type.Assembly.GetManifestResourceStream (resource)){
if (s == null)
throw new FileNotFoundException ("Resource name was not found: `" + resource + "'");

InitFromStream (s);
}
}

public Bitmap (Image original, int width, int heigth)
Expand Down
8 changes: 7 additions & 1 deletion mcs/class/System.Drawing/System.Drawing/Graphics.cs
Expand Up @@ -34,6 +34,8 @@ public sealed class Graphics : MarshalByRefObject, IDisposable

private Graphics (IntPtr nativeGraphics)
{
if (nativeGraphics == IntPtr.Zero)
Console.WriteLine ("Here: " + Environment.StackTrace);
nativeObject = nativeGraphics;
}

Expand Down Expand Up @@ -1040,7 +1042,11 @@ public void Flush (FlushIntention intention)
public static Graphics FromHdc (IntPtr hdc)
{
int graphics;
GDIPlus.GdipCreateFromHDC (hdc, out graphics);
if (GDIPlus.GdipCreateFromHDC (hdc, out graphics) != Status.Ok){
Console.WriteLine ("Graphics.FromHdc: the HDC is an invalid handle");
return null;
}

Graphics result = new Graphics ((IntPtr) graphics);
return result;
}
Expand Down

0 comments on commit a4b9a48

Please sign in to comment.