private void FrmMain_Load(object sender, EventArgs e) { imgBkgPvw = new Bitmap(ImageFormator.BackgroundImage(512, 32)); imgBkgZoom = new Bitmap(ImageFormator.BackgroundImage(256, 32)); picPvw.AllowDrop = true; zoomW = 256 / 2; zoomH = 256 / 2; }
private void BtnOpenIcon_Click(object sender, EventArgs e) { var dlg = new IconDialog(); if (dlg.ShowDialog() == DialogResult.OK) { imgIco = ImageFormator.GetIconImage(dlg.FileName, dlg.IconIndex); imgPvw = PixelFormator.PixelIcon(imgIco, 1, 512); picPvw.Refresh(); chkPixel.Enabled = true; btnSaveIco.Enabled = true; } }
private void BtnOpenImg_Click(object sender, EventArgs e) { var dlg = new OpenFileDialog() { Filter = "Image Files (*.bmp;*.jpg;*.png;*.svg;*.webp)|*.bmp;*.jpg;*.png;*.svg;*.webp" }; if (dlg.ShowDialog() == DialogResult.OK) { imgIco = ImageFormator.PreviewImage(ImageFormator.GetPictureImage(dlg.FileName), 512, 512, rdoScale.Checked); imgPvw = new Bitmap(imgIco); picPvw.Refresh(); chkPixel.Enabled = true; btnSaveIco.Enabled = true; } }
private bool CheckDropFile(DragEventArgs e) { bool isImage; string file = ((string[])e.Data.GetData(DataFormats.FileDrop))[0]; string ext = Path.GetExtension(file).ToLower(); try { if (ext == ".ico" || ext == ".exe" || ext == ".dll") { imgThn = ImageFormator.ThumbnailImage(ImageFormator.GetIconImage(file, 0), 128, 128); } else { imgThn = ImageFormator.ThumbnailImage(ImageFormator.GetPictureImage(file), 128, 128); } isImage = true; } catch { isImage = false; } return(isImage); }
private void PicPvw_DragDrop(object sender, DragEventArgs e) { string file = ((string[])e.Data.GetData(DataFormats.FileDrop))[0]; string ext = Path.GetExtension(file).ToLower(); if (ext == ".ico" || ext == ".exe" || ext == ".dll") { imgIco = ImageFormator.GetIconImage(file, 0); } else { imgIco = ImageFormator.PreviewImage(ImageFormator.GetPictureImage(file), 512, 512, rdoScale.Checked); } imgThn = new Bitmap(128, 128); imgPvw = new Bitmap(512, 512); using (var g = Graphics.FromImage(imgPvw)) { g.DrawImage(imgIco, new Point((512 - imgIco.Width) / 2, (512 - imgIco.Height) / 2)); } picPvw.Refresh(); chkPixel.Enabled = true; btnSaveIco.Enabled = true; }