Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# create monochrome bitmap

Bitmap bmp = new Bitmap(300, 300);
           using (Graphics g = Graphics.FromImage(bmp))
           {
               Font font = new Font("Arial", 20, FontStyle.Bold, GraphicsUnit.Point);
               g.Clear(Color.White);
               g.DrawString("Hello", font, Brushes.Black, 0, 0);
           }
           System.Drawing.Imaging.BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format1bppIndexed);
           Bitmap newBitmap = new Bitmap(300, 300, bmpData.Stride, System.Drawing.Imaging.PixelFormat.Format1bppIndexed, bmpData.Scan0);
           newBitmap.Save(@"c:xx.bmp");
Comment

PREVIOUS NEXT
Code Example
Csharp :: show a message box in c# 
Csharp :: c# md5 hash bouncycastle encypt decrypt with key 
Csharp :: move dotnet dlls to another folder 
Csharp :: cefsharp not passing keydown to form 
Csharp :: how to make physics in unity 
Csharp :: get path revit link unloaded 
Csharp :: c# creat pen 
Csharp :: razor preview 
Csharp :: unity wrap around value 
Csharp :: Store Images In SQL Server Using EF Core And ASP.NET Core 
Csharp :: how do make internet 
Csharp :: C# oledb excel select column with space 
Csharp :: c# arithmetic operators 
Csharp :: alpahbet incremnet in c# 
Csharp :: calculated field gridview asp.net 
Csharp :: Computing a Cartesian product or Combinations with LINQ 
Csharp :: Cannot convert type child to type parent c# 
Csharp :: variable with letters and numbers in C# 
Csharp :: c# string is all zeros 
Csharp :: close windows by esc wpf 
Csharp :: recursively fing root of tree 
Csharp :: ArgumentOutOfRangeException when sorting a DataGridView using a custom IComparer 
Csharp :: ms transform 
Csharp :: asp.net web hooks 
Csharp :: c# string size in bytes 
Csharp :: unity run all interfaces 
Csharp :: how to center a window in monogame 
Csharp :: pem file string reader c# 
Csharp :: wpf create rectangle c# 
Csharp :: c# array does not contain a definition for cast 
ADD CONTENT
Topic
Content
Source link
Name
8+8 =