How to change the BackColor of a transparent image to White using GDI objects without losing the content of the image.
When I tried to change it using the command
this.image.backcolor
, the content of the image is lost.
How to change the BackColor of a transparent image to White using GDI objects without losing the content of the image.
When I tried to change it using the command
this.image.backcolor
, the content of the image is lost.
First you create a new image with the desired backcolor and the same size as your original image. Then you draw the original image on the new image using Graphics.DrawImage.
create a bit map for image you want to change and use bitmap.clear(color u want);
Even if you want to use CSS trick
to do this, Here is the solution:-
CSS
.reverse{-webkit-filter: invert(100%); filter: invert(100%);}
HTML
<img src="src path" class="reverse">
Same way many other options are available in CSS
.
Hope this post will help you :).
Try this,
var newImage = new Bitmap(oldImage.Width, oldImage.Height);
using (var g = Graphics.FromImage(newImage))
{
g.Clear(Color.White);
g.DrawImage(oldImage, new Point(0, 0));
}