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 );

Friday, March 5, 2021

C# - How to initialize List items in new statement

One possibility:
image.Normalize( new List() { new Rectangle( 100, 100, 300, 100 ) }  );
Another possibility with setting accessible properties by name:
image.Normalize( new List()
{ 
  new Rectangle() { X=100, Y=100, Width=300, Height=100 }, 
  new Rectangle() { X=200, Y=250, Width=200, Height=50 }
}  
);

Monday, March 1, 2021

C# - How to check installed .NET SDK

With this command tool dotnet.exe you can list for example installed .NET SDK.
Tip: If you want make .NET 5 app, create .NET CORE x project and then you can change it into .NET 5 (Feb 2021).