ExtensionMethod.NET Home of 880 C#, Visual Basic, F# and Javascript extension methods

LoadBitmapFromResource

Create new Bitmap from resource image

Source

public static Bitmap LoadBitmapFromResource(this Assembly assembly, string imageResourcePath) {
    var stream = assembly.GetManifestResourceStream(imageResourcePath);
    return stream != null ? new Bitmap(stream) : null;
}

Example

Bitmap bitmap = Assembly.GetExecutingAssembly().LoadBitmapFromResource("Resources.Progress.gif");

Author: Algel

Submitted on: 16 dec. 2009

Language: C#

Type: System.Reflection.Assembly

Views: 4910