Advertisement
Jimi2000

Image Reduction + Gamma Adjustment

Feb 5th, 2020
771
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     Dim img = Image.FromFile([The Image Path], True)
  2.  
  3.     Dim maxHeight As Single = 284.0F
  4.     Dim newWidth As Single = img.Width * (maxHeight / img.Height)
  5.     Dim imageCopy = New Bitmap(CInt(newWidth), CInt(maxHeight), PixelFormat.Format32bppArgb)
  6.  
  7.     imageCopy.SetResolution(img.HorizontalResolution, img.VerticalResolution)
  8.  
  9.     Using g = Graphics.FromImage(imageCopy),
  10.         attributes = New ImageAttributes()
  11.         attributes.SetGamma(1.12F, ColorAdjustType.Bitmap)
  12.  
  13.         g.SmoothingMode = SmoothingMode.None
  14.         g.PixelOffsetMode = PixelOffsetMode.Half
  15.         g.InterpolationMode = InterpolationMode.HighQualityBilinear
  16.         g.DrawImage(img, New Rectangle(0, 0, imageCopy.Width, imageCopy.Height), 0, 0, img.Width, img.Height, GraphicsUnit.Pixel, attributes)
  17.     End Using
  18.     img.Dispose()
  19.     Return imageCopy
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement