Exemplo n.º 1
0
 public SD.Bitmap LoadImage(DevIL.ImageImporter ImImport, MemoryStream mStream, int width = 128, int height = 128)
 {
     try
     {
         DevIL.Image IconImg = ImImport.LoadImageFromStream(mStream);
         IconImg.Bind();
         var            img  = new SD.Bitmap(IconImg.Width, IconImg.Height, SDI.PixelFormat.Format32bppArgb);
         SD.Rectangle   rect = new SD.Rectangle(0, 0, IconImg.Width, IconImg.Height);
         SDI.BitmapData data = img.LockBits(rect, SDI.ImageLockMode.WriteOnly, SDI.PixelFormat.Format32bppArgb);
         DevIL.Unmanaged.IL.CopyPixels(0, 0, 0, IconImg.Width, IconImg.Height, 1, DevIL.DataFormat.BGRA, DevIL.DataType.UnsignedByte, data.Scan0);
         img.UnlockBits(data);
         return(img);
     }
     catch
     {
         return(new SD.Bitmap(width, height));
     }
 }
Exemplo n.º 2
0
 public Bitmap LoadImage(DevIL.ImageImporter ImImport, MemoryStream mStream, int width = 128, int height = 128)
 {
     try
     {
         Bitmap img2 = null;
         using (DevIL.Image IconImg = ImImport.LoadImageFromStream(mStream))
         {
             IconImg.Bind();
             using (var img = new Bitmap(IconImg.Width, IconImg.Height, PixelFormat.Format32bppArgb))
             {
                 Rectangle  rect = new Rectangle(0, 0, IconImg.Width, IconImg.Height);
                 BitmapData data = img.LockBits(rect, ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
                 DevIL.Unmanaged.IL.CopyPixels(0, 0, 0, IconImg.Width, IconImg.Height, 1, DevIL.DataFormat.BGRA, DevIL.DataType.UnsignedByte, data.Scan0);
                 img.UnlockBits(data);
                 img2 = (Bitmap)img.Clone();
             }
         }
         return(img2);
     }
     catch
     {
         return(new Bitmap(width, height));
     }
 }