Created
December 14, 2015 22:26
-
-
Save neildanson/a8a6a40960788c3c2d8e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type ColorF(r : float, g : float, b : float) = | |
new(r : byte, g : byte, b : byte) = ColorF(float r / 255.0, float g / 255.0, float b / 255.0) | |
member __.R = r | |
member __.G = g | |
member __.B = b | |
member color.RGBA = | |
let r = int (r * 255.0) | |
let g = int (g * 255.0) | |
let b = int (b * 255.0) | |
(255 <<< 24) ||| (r <<< 16) ||| (g <<< 8) ||| b | |
let writeableBitmap = WriteableBitmap(1024, 1024, 96.0, 96.0, PixelFormats.Bgra32, null) | |
do writeableBitmap.Lock() | |
let backbuffer = NativePtr.ofNativeInt<int> writeableBitmap.BackBuffer | |
let stride = writeableBitmap.BackBufferStride | |
let plot_pixel x y (color:ColorF) = NativePtr.set backbuffer (x + ((stride / 4) * y)) (color.RGBA) | |
//Set some pixels using plot_pixel function | |
do writeableBitmap.AddDirtyRect(Int32Rect(0, 0, 1024, 1024)) | |
do writeableBitmap.Unlock() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment