fefrei
fefrei

Reputation: 905

Programmatically draw and show / copy / save an image

I'd like to draw an image (like a bar code) pixel-by-pixel in a Visual Basic .NET WPF Application and …

  1. show the image in my UI
  2. copy it to the clipboard
  3. save it as a .BMP-File.

It should also be possible to add Paint-like editing features later.

What is a good approach?

System.Drawing.Bitmap works internally, but the only way I could show it is to convert it to an ImageSource and show it inside an Image control. Is there any better way?

Upvotes: 1

Views: 678

Answers (1)

brunnerh
brunnerh

Reputation: 184296

I think WriteableBitmap might help, it already is an ImageSource. Check out the documentation for some usage examples. I have not used this for a long time so i cannot help you with it, possibly searches on this site may turn up some useful info as well.

As WriteableBitmap is a BitmapSource you can just use Clipboard.SetImage to copy it.

To save images you can in general use a subclass ob BitmapEncoder (also see doc for usage; you probably want to use the BmpBitmapEncoder).

Upvotes: 1

Related Questions