mirror of
https://github.com/colhountech/DarkUI.Net5.git
synced 2024-10-17 07:16:49 +03:00
2246e6e645
Added toolstrip & menu renderers. Added extension methods for changing bitmap colours and upgraded to .NET 4.0 for easier implementation of these methods.
38 lines
1.1 KiB
C#
38 lines
1.1 KiB
C#
using System.Drawing;
|
|
|
|
namespace DarkUI
|
|
{
|
|
public static class BitmapExtensions
|
|
{
|
|
public static Bitmap SetColor(this Bitmap bitmap, Color color)
|
|
{
|
|
var newBitmap = new Bitmap(bitmap.Width, bitmap.Height);
|
|
for (int i = 0; i < bitmap.Width; i++)
|
|
{
|
|
for (int j = 0; j < bitmap.Height; j++)
|
|
{
|
|
var pixel = bitmap.GetPixel(i, j);
|
|
if (pixel.A > 0)
|
|
newBitmap.SetPixel(i, j, color);
|
|
}
|
|
}
|
|
return newBitmap;
|
|
}
|
|
|
|
public static Bitmap ChangeColor(this Bitmap bitmap, Color oldColor, Color newColor)
|
|
{
|
|
var newBitmap = new Bitmap(bitmap.Width, bitmap.Height);
|
|
for (int i = 0; i < bitmap.Width; i++)
|
|
{
|
|
for (int j = 0; j < bitmap.Height; j++)
|
|
{
|
|
var pixel = bitmap.GetPixel(i, j);
|
|
if (pixel == oldColor)
|
|
newBitmap.SetPixel(i, j, newColor);
|
|
}
|
|
}
|
|
return newBitmap;
|
|
}
|
|
}
|
|
}
|