开发者

Open a picture (jpg.) in F#

I would like to open several pictures (.jpg) with F#. All my pictures开发者_StackOverflow中文版 are stored in afile (filepath). I would like to show them to the user. How can I do this using F#?

To open one picture, it tried something like :

open System.IO
let editPicture filepath = 
    let  fileStream = File.Open(filepath,FileMode.Open)
    fileStream.Visible <- True

but it doesn t work.


Here is a minimal quick and dirty WinForms F# snippet that shows a .jpg image on a screen:

open System
open System.Windows.Forms
open System.Drawing

let form = new Form()
let pb = new PictureBox()
pb.Image <- Image.FromFile(path-to-file-with-your-jpg-image)
pb.SizeMode <- PictureBoxSizeMode.AutoSize
form.Controls.Add(pb)

[<STAThread>]
do
    Application.Run(form)

This may give you some initial traction and feel on what is involved into reaching your goal. But overall I agree with Carsten König that learning curve for doing UIs with F# is quite steep.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜