using System.Drawing; using System.IO; using System.Windows.Forms; namespace FastReport.Utils { partial class ResourceLoader { /// /// Gets a bitmap from specified assembly resource. /// /// Assembly name. /// Resource name. /// Bitmap object. public static Bitmap GetBitmap(string assembly, string resource) { Stream stream = GetStream(assembly, resource); if (stream == null) return null; Bitmap bmp = new Bitmap(stream); // To avoid the requirement to keep a stream alive, we clone a bitmap. Bitmap result = ImageHelper.CloneBitmap(bmp); bmp.Dispose(); stream.Dispose(); return result; } /// /// Gets a bitmap from specified FastReport assembly resource. /// /// Resource name. /// Bitmap object. public static Bitmap GetBitmap(string resource) { return GetBitmap("FastReport", resource); } /// /// Gets a cursor from specified assembly resource. /// /// Assembly name. /// Resource name. /// Cursor object. public static Cursor GetCursor(string assembly, string resource) { Stream stream = GetStream(assembly, resource); Cursor result = new Cursor(stream); stream.Dispose(); return result; } /// /// Gets a cursor from specified FastReport assembly resource. /// /// Resource name. /// Cursor object. public static Cursor GetCursor(string resource) { return GetCursor("FastReport", resource); } /// /// Gets an icon from specified assembly resource. /// /// Assembly name. /// Resource name. /// Icon object. public static Icon GetIcon(string assembly, string resource) { Stream stream = GetStream(assembly, resource); Icon result = new Icon(stream); stream.Dispose(); return result; } /// /// Gets an icon from specified FastReport assembly resource. /// /// Resource name. /// Icon object. public static Icon GetIcon(string resource) { return GetIcon("FastReport", resource); } } }