Browse Source

Merge pull request #3 from CraigOates/0.3-proto

update the drawGrid function to work with images with indexed pixels.
master
Craig Oates 6 years ago committed by GitHub
parent
commit
48bbd1fe3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 19
      DeathSocket/ImageServices.fs

19
DeathSocket/ImageServices.fs

@ -18,16 +18,17 @@
Point ((interval * point), height)|]|]
let drawGrid spec =
let img = Bitmap.FromFile spec.originalPath
let graphics = Graphics.FromImage(img)
let pen = new Pen (spec.colour, width = spec.penWidth)
// The temp. file is used as a way to convert images with index pixels.
use original = Bitmap.FromFile spec.originalPath
use temp = new Bitmap(original)
use clone = temp.Clone(new Rectangle(0, 0, temp.Width, temp.Height), PixelFormat.Format32bppArgb)
use graphics = Graphics.FromImage(clone)
use pen = new Pen (spec.colour, width = spec.penWidth)
graphics.DrawImage(original,new Rectangle(0, 0, clone.Width, clone.Height))
let horizontalLines =
createHorizontalLines (img.Size.Width) (img.Size.Height) (spec.rows)
createHorizontalLines (clone.Size.Width) (clone.Size.Height) (spec.rows)
let verticalLines =
createVerticalLines (img.Size.Width) (img.Size.Height) (spec.columns)
createVerticalLines (clone.Size.Width) (clone.Size.Height) (spec.columns)
for line in horizontalLines do graphics.DrawLines (pen, line)
for line in verticalLines do graphics.DrawLines (pen, line)
img.Save (spec.savePath)
img.Dispose()
graphics.Dispose()
pen.Dispose()
clone.Save (spec.savePath)
Loading…
Cancel
Save