首页 > 解决方案 > ImgUtil 函数和 colorAt

问题描述

我怎么解决这个问题?

使用 ImgUtil 函数和 colorAt 创建函数 makePicture: string -> figure -> int -> int -> unit 这样名称 makePicture 文件名 figure bh 创建一个名为 filename.png 的图像文件,其中图像的宽度为 b 和高度 h。在没有颜色的点(参见 colorAt),颜色必须为灰色(由 RGB 值 (128,128,128) 定义)。您可以使用此功能来测试您的任务。

标签: functioncolorbox

解决方案


let makePicture filename figur b h = let bmp =
//bmp = 位图 ImgUtil.init b h (fun (x,y) -> //x,y = 图中的位置 let c = match colourAt (x,y) figur with | None -> (128,128,128) | Some c -> c in ImgUtil.fromRgb c) //c = 画布

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


推荐阅读