Load Bitmap - CSharp System.Drawing

CSharp examples for System.Drawing:Bitmap

Description

Load Bitmap

Demo Code


using System.Threading.Tasks;
using System.Text;
using System.Runtime.InteropServices;
using System.Linq;
using System.IO;//from w  ww.  j  a v  a  2s  .co  m
using System.Drawing.Imaging;
using System.Drawing;
using System.Collections.Generic;
using System;

public class Main{

        public static Bitmap LoadBitmap(string fileName)
        {

            var firstBmp = new Bitmap(fileName);
            var secondBmp = new Bitmap(firstBmp.Width, firstBmp.Height, firstBmp.PixelFormat);
            var gr = Graphics.FromImage(secondBmp);
            gr.DrawImage(firstBmp, 0, 0);
            gr.Dispose();
            firstBmp.Dispose();
            return secondBmp;
  
        }
}

Related Tutorials