C# .ico çevirici program

canbozkurt

Yetkin
Katılım
25 Nisan 2024
Mesajlar
219
Makaleler
24
Çözümler
6
Beğeniler
406
Yer
Ötüken
Herkese merhabalar,

Bu program ile .png formatındaki simgelerimizi uygulamaya sürükle bırak yaparak otomatik olarak .ico dosyalarına çevirebileceğiz.

.ico dosya formatı web sitelerin faviconlarında veya masaüstü programların simgelerinde kullanabileceğiniz ikon formatıdır.

Bu uygulama ile de bu çevirmeyi kolay bir şekilde gerçekleştirebilirsiniz.

Tek yapmanız gereken png formatındaki simgeyi programa sürükleyip bırakmak, programın olduğu dizine aynı ad ile .ico formatında dosyayı oluşturacak.

Uygulama bağlantısı :

Virüstotal :






[CODE title="ico çevirici"]using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Windows.Forms;

namespace ico_cevirici
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.AllowDrop = true;
this.DragEnter += new DragEventHandler(Form1_DragEnter);
this.DragDrop += new DragEventHandler(Form1_DragDrop);
}

private void Form1_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
e.Effect = DragDropEffects.Copy;
else
e.Effect = DragDropEffects.None;
}

private void Form1_DragDrop(object sender, DragEventArgs e)
{
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
foreach (string file in files)
{
if (Path.GetExtension(file).ToLower() == ".png")
{
ConvertToIcon(file);
MessageBox.Show("İcon başarıyla oluşturuldu.");
}
else
{
MessageBox.Show("Lütfen PNG formatında bir resim dosyası sürükleyip bırakınız.");
}
}
}

private void ConvertToIcon(string pngFilePath)
{
using (Bitmap bm = new Bitmap(pngFilePath))
{
Icon ico = Icon.FromHandle(bm.GetHicon());
string icoFilePath = Path.ChangeExtension(pngFilePath, ".ico");
using (FileStream fs = new FileStream(icoFilePath, FileMode.OpenOrCreate))
{
ico.Save(fs);
}
}
}


}
}
[/CODE]
 
Son düzenleyen: Moderatör:
Bu siteyi kullanmak için çerezler gereklidir. Siteyi kullanmaya devam etmek için çerezleri kabul etmelisiniz. Daha Fazlasını Öğren.…