Created
March 20, 2013 11:38
-
-
Save dellis1972/5204016 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static void PreMultiplyImage(string infile, string outfile) | |
{ | |
using (System.Drawing.Image image = System.Drawing.Image.FromFile(infile)) | |
{ | |
int w = image.Width; | |
int h = image.Height; | |
System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(image); | |
for (int i = 0; i != bitmap.Width; ++i) | |
{ | |
for (int j = 0; j != bitmap.Height; ++j) | |
{ | |
System.Drawing.Color pixel = bitmap.GetPixel(i, j); | |
System.Drawing.Color prepxiel = System.Drawing.Color.FromArgb( | |
pixel.A, | |
(pixel.R * pixel.A / 255), | |
(pixel.G * pixel.A / 255), | |
(pixel.B * pixel.A / 255) | |
); | |
bitmap.SetPixel(i,j,prepxiel); | |
} | |
} | |
bitmap.Save(outfile); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment