Reputation:
I am learning F# by converting a program in C# to F#
The problem is with WritableBitmap, the compiler complains that:
The type tableBitmap is not defined
this is the code:
module MandelbrotBitmap
open System.Windows.Media
open System.Windows.Media.Imaging
type Mandelbrot(width:int) as this =
let mutable _width = width
let mutable _height = 10
let mutable bitmap = new WritableBitmap( _width, _heights, 96.0, 96.0,
PixelFormats.Bgr32, None)
member this.Width
with get() = _width
and set(newVal) = _width <- newVal
The None
in the instanciation is my try to replace null
in the original expression.
I have PresentationCore
and WindowsBase
in my references.
bitmap = new WriteableBitmap(
(int)sizeInfo.NewSize.Width,
(int)sizeInfo.NewSize.Height,
96, 96, PixelFormats.Bgr32, null);
WriteableBitmap is described in this msdn article
My question is; What is the compiler complaining about?
Upvotes: 2
Views: 218
Reputation: 22307
You have two typos: WritableBitmap should be WriteableBitmap, and _heights should be _height. Also, null
and None
are not interchangeable, when you are using .NET framework classes often times you must use null
, which is a interop feature of F#. One last problem, if you want to break apart your arguments across lines in the WriteableBitmap constructor, you need to make sure the next line is farther indented than new
since whitespace is significant in F#. Here is the final, fixed WriteableBitmap constructor call:
new WriteableBitmap( _width, _height, 96.0, 96.0,
PixelFormats.Bgr32, null)
Upvotes: 6
Reputation: 9423
It's just a typo:
let mutable bitmap = new WriteableBitmap( _width, _heights, 96.0, 96.0,
PixelFormats.Bgr32, None)
Upvotes: 2