So, i solved it after i looked into your source code. You treading every gdi image as an normal bitmap, thats ok if you want to display images without loss of quality, but if you want to display loaded jpeg files thats not nessesary and a waste of memory.
I added the following code to your XImage Class:
Code:
/// <summary>
/// Creates an image from the specified stream.
/// </summary>
/// <param name="stream">The stream to a BMP, PNG, GIF, JPEG, TIFF, or PDF file.</param>
public static XImage FromStream(Stream stream)
{
if (stream == null)
throw new ArgumentNullException("stream");
if (stream.Length == 0)
throw new ArgumentException("Provided stream is empty", "stream");
return new XImage(stream);
}
/// <summary>
/// Conversion from Image to a jpeg based (compressed) XImage.
/// </summary>
public static XImage FromGdiPlusToJpegImage(Image image)
{
if (image == null)
throw new ArgumentNullException("image");
using (MemoryStream memStrm = new MemoryStream())
{
image.Save(memStrm, ImageFormat.Jpeg);
memStrm.Position = 0;
return FromStream(memStrm);
}
}
Feel free to use/modify my addition in your future releases.
Greets David Tielke