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
);
}
}
}
}
}
Смотрите видео how to build Image converter software using c# онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Ruwaid Hemud 19 Февраль 2020, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 324 раз и оно понравилось 14 людям.