how to build Image converter software using c#

Published: 19 February 2020
on channel: Ruwaid Hemud
324
14

in this tutorial iam going to show u how to build image converter software using c# and gdi+ to save images with custom size without loosing quality enjoy , dont forget to subscribe and like see u in the the next video



songs in the video
1)   • Diplo - Revolution (feat. Faustix & I...  
2)   • Aero Chord feat. DDARK - Shootin Star...  
3)   • Video  


source code for the form:-
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing.Imaging;
namespace Saving_Image_With_DifferentSize
{
public partial class Form1 : Form
{
private string filename;
private Image currImg = null;
public Form1()
{
InitializeComponent();
}

private void UploadBtn_Click(object sender, EventArgs e)
{
if(openFileDialog2.ShowDialog()==DialogResult.OK)
{
filename = openFileDialog2.FileName;
currImg = Image.FromFile(filename);
this.Invalidate();
}
}

private void Form1_Paint(object sender, PaintEventArgs e)
{
if(currImg!=null)
{
pictureBox1.Image = currImg;
}
}

private void SaveBtn_Click(object sender, EventArgs e)
{
if (currImg == null)
return;
int h = Convert.ToInt16(HeightTxt.Text);
int w = Convert.ToInt16(WidthTxt.Text);
SaveFileDialog saveFile = new SaveFileDialog();
saveFile.Title = "Save image as";
saveFile.OverwritePrompt = true;
saveFile.CheckPathExists = true;
saveFile.Filter = "BitMap File(*.bmp)|*.bmp|Gif File(*.gif)|*.gif|" +
"JPEG File(*.jpg)|*.jpg";
saveFile.ShowHelp = true;
if(saveFile.ShowDialog()==DialogResult.OK)
{
string filename = saveFile.FileName;
string extension = filename.Substring(filename.Length - 3, 3);
Bitmap newimg = new Bitmap(currImg, new Size(w, h));
if(extension.Equals("bmp"))
{
newimg.Save(filename, ImageFormat.Bmp
);
}
else if (extension.Equals("gif"))
{
newimg.Save(filename, ImageFormat.Gif
);
}
else if (extension.Equals("jpg"))
{
newimg.Save(filename, ImageFormat.Jpeg
);
}

}
}
}
}


Watch video how to build Image converter software using c# online without registration, duration hours minute second in high quality. This video was added by user Ruwaid Hemud 19 February 2020, don't forget to share it with your friends and acquaintances, it has been viewed on our site 324 once and liked it 14 people.