functioncolorbox

ImgUtil functions and colorAt


how can I solve this problem?

Use the ImgUtil functions and colorAt to create a function makePicture: string -> figure -> int -> int -> unit such that the name makePicture filename figure b h creates an image file named filename.png with an image of figure with width b and height h. At points that have no color (cf. colorAt), the color must be gray (defined by the RGB value (128,128,128)). You can use this feature to test your tasks.


Solution

  • let makePicture filename figur b h = let bmp =
    //bmp = bit map ImgUtil.init b h (fun (x,y) -> //x,y = the position in the map let c = match colourAt (x,y) figur with | None -> (128,128,128) | Some c -> c in ImgUtil.fromRgb c) //c = canvas

    let target = Filename + ".png" do ImgUtil.toPngFile target bmp do printfn "Wrote filbe: %s" target