Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RickStrahl/5d7d2916fc2bff75c8b3a0d3ca6b463d to your computer and use it in GitHub Desktop.
Save RickStrahl/5d7d2916fc2bff75c8b3a0d3ca6b463d to your computer and use it in GitHub Desktop.
[TestMethod]
public void BitmapWpfPngSaveTest()
{
Assert.IsTrue(System.Windows.Clipboard.ContainsImage(), "No image on clipboard");
string of = "c:\\temp\\test_Bitmap.png";
var bmpSource = System.Windows.Clipboard.GetImage();
using (var fileStream = new FileStream(of, FileMode.Create))
{
BitmapEncoder encoder = null;
encoder = new PngBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(bmpSource));
encoder.Save(fileStream);
//if (ext == ".png")
// mmFileUtils.OptimizePngImage(sd.FileName,5); // async
}
Assert.IsTrue(File.Exists(of));
ShellUtils.GoUrl(of);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment