Wednesday, March 17, 2021

C# - How to draw image with Gamma or Threshold effect

var rectDest = new Rectangle( 0, 0, this.m_bitmap_source.Width, this.m_bitmap_source.Height );
using ( var graphics = Graphics.FromImage( this.m_bitmap_dest ) ) using ( var attr = new ImageAttributes() ) { attr.SetGamma( 0.2f ); graphics.DrawImage( this.m_bitmap_source, rectDest, 0, 0, this.m_bitmap_source.Width, this.m_bitmap_source.Height, GraphicsUnit.Pixel, attr ); }
You can use Threshold effect too (replace row with Gamma):
attr.SetThreshold( 0.4f );

No comments:

Post a Comment