Advertisement
Guest User

Untitled

a guest
Nov 7th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
F# 0.89 KB | None | 0 0
  1. let processImage f (path:string) =
  2.     let bitmap_in = new Bitmap(path)
  3.     let bitmap_out = new Bitmap(bitmap_in.Width, bitmap_in.Height)  
  4.     let filename = Path.GetFileName(path)
  5.     for i in 0..(bitmap_in.Width-1) do
  6.         for j in 0..(bitmap_in.Height-1) do
  7.             bitmap_out.SetPixel(i,j,bitmap_in.GetPixel(i,j))
  8.     bitmap_out |> f
  9.     bitmap_out.Save(Path.Combine(Path.GetDirectoryName(path), filename.Insert(filename.Length - 4, "-1")),
  10.             ImageFormat.Jpeg)
  11.     bitmap_in.Dispose()
  12.     bitmap_out.Dispose()
  13.  
  14. let mirrorTrans (image: Bitmap) =
  15.     for i in 0..(image.Height-1) do
  16.         for j in 0..(image.Width-1) do
  17.             let pix = min (image.Width - 1) (max 0 (j + int (sin(float i / 20.0) * 30.0)))
  18.             image.SetPixel(j, i, image.GetPixel(pix,i))
  19.  
  20. processImage mirrorTrans @"/Users/emilfataliev/Desktop/F#/fp-lab4-EmilFataliev/images/selfi.jpg"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement