O'Reilly logo

Windows Presentation Foundation 4.5 Cookbook by Pavel Yosifovich

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Manipulating a bitmap programmatically

Bitmaps are used in one form or another mainly to display existing images. These typically are placed as a source of an Image element. When a static image is added to a project and set to the Image.Source property, a BitmapImage is created behind the scenes. This simple class provides a read-only view to the bitmap's bits.

Sometime it's desirable to manipulate a bitmap's bit values dynamically based on a runtime algorithm. WPF provides the WriteableBitmap that allows us to do just that. Let's look at how to use this capability.

Getting ready

Make sure Visual Studio is up and running.

How to do it...

We'll create an application that displays the famous Mandelbrot set, requiring calculating colors for each pixel ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required