@msdn=http://search.microsoft.com/search/results.aspx?qu=$$$ @pinvoke=http://pinvoke.net/$$$.htm Summary: TODO - GdipLoadImageFromFile loads an image about 100x faster than System.Drawing because it does not perform any image validation. !!!!C# Signature: [DllImport("gdiplus.dll", CharSet=CharSet.Unicode)] public static extern int GdipLoadImageFromFile(string filename, out IntPtr image); !!!!VB Signature: !!!!User-Defined Types: None. !!!!Notes: You must have [SecurityPermissionFlag].UnmanagedCode to run this code. !!!!Tips & Tricks: !!!!Sample Code: public class FastImageGdiPlus { [DllImport("gdiplus.dll", CharSet=CharSet.Unicode)] public static extern int GdipLoadImageFromFile(string filename, out IntPtr image); private FastImageGdiPlus() { } private static Type imageType = typeof(System.Drawing.Bitmap); [SecurityPermission(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)] internal static Image FastFromFile(string filename) { try { filename = Path.GetFullPath(filename); IntPtr loadingImage = IntPtr.Zero; // We are not using ICM at all, fudge that, this should be FAAAAAST! if ( GdipLoadImageFromFile(filename, out loadingImage) != 0 ) { throw new Exception("GDI+ threw a status error code."); } return (Bitmap) imageType.InvokeMember("FromGDIplus", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.InvokeMethod, null, null, new object[] { loadingImage }); } catch(SecurityException) { return Image.FromFile(filename); } } } !!!!Alternative Managed API: ""System.Drawing.Image.FromFile"". Documentation: GdipLoadImage@msdn on MSDN
Edit gdi32.GdipLoadImage
You do not have permission to change this page. If you feel this is in error, please send feedback with the contact link on the main page.