private void BtnSwitch_Click(object sender, EventArgs e) { if (0 == SelectFileFullName.Length) { MessageBox.Show("请选择正确的图片!"); return; } Bitmap bitmap = new Bitmap(SelectFileFullName); if (null == bitmap) { MessageBox.Show("文件格式错误!"); return; } Color col = bitmap.GetPixel(0, 0); Debug.WriteLine("SelectFileNameWE:" + SelectFileNameWE); Debug.WriteLine("(" + 0 + "," + 0 + ") col:" + col); Debug.WriteLine("Bitmap size " + bitmap.Width + "x" + bitmap.Height); if (0 == EditSavePath.Text.Length) { MessageBox.Show("请选择正确的保存路径"); return; } PictureCompress.GetInterface().PictureCompressRLE(bitmap, EditSavePath.Text, SelectFileNameWE, ListboxCompress.SelectedIndex); }
public static PictureCompress GetInterface() { if (null == PicCompressInterface) { PicCompressInterface = new PictureCompress(); } return(PicCompressInterface); }
private void BtnScan_Click(object sender, EventArgs e) { openFileDialog1.InitialDirectory = LastSelectPath; if (this.openFileDialog1.ShowDialog() == DialogResult.OK) { LastSelectPath = Path.GetDirectoryName(this.openFileDialog1.FileName); SelectFileFullName = openFileDialog1.FileName; SelectFileName = Path.GetFileName(openFileDialog1.FileName); SelectFileNameWE = Path.GetFileNameWithoutExtension(openFileDialog1.FileName); if ((0 == SelectFileFullName.Length) || (false == PictureCompress.GetInterface().IsPicture(SelectFileFullName))) { MessageBox.Show("请选择正确的图片!"); return; } LabelPicShowNotice.Visible = false; EditFileSelect.Text = SelectFileFullName;//显示文件的名字 EditSavePath.Text = LastSelectPath + "\\" + SelectFileNameWE + ".c"; Bitmap bitmap = new Bitmap(SelectFileFullName); LabelPicSize.Text = bitmap.Width + "x" + bitmap.Height; switch (bitmap.PixelFormat.ToString()) { case "Format24bppRgb": LablePixelFormat.Text = "24bpp"; break; case "Format32bppArgb": LablePixelFormat.Text = "32bpp"; break; default: LablePixelFormat.Text = "Unknow"; break; } Debug.WriteLine("Select directory:" + LastSelectPath); Debug.WriteLine("SelectFileFullName:" + SelectFileFullName); Debug.WriteLine("SelectFileName:" + SelectFileName); Debug.WriteLine("SelectFileNameWE:" + SelectFileNameWE); try { this.PicPreview.Load(SelectFileFullName); } catch (Exception ex) { Debug.Write(ex.Message); } } }