Last active
August 29, 2015 14:02
-
-
Save RyuaNerin/15b9e1105e9418da1282 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
public static void Png32ToPna(Bitmap image) | |
{ | |
BitmapData data = image.LockBits(new Rectangle(0, 0, image.Width, image.Height), ImageLockMode.ReadWrite, image.PixelFormat); | |
try | |
{ | |
unsafe | |
{ | |
byte* ptr = (byte*)data.Scan0; | |
for (int i = 0; i < data.Height; i++) | |
{ | |
for (int j = 0; j < data.Width; j++) | |
{ | |
ptr[1] = ptr[2] = ptr[3] = ptr[0]; | |
ptr += 3; | |
} | |
ptr += data.Stride - data.Width * 4; | |
} | |
} | |
} | |
finally | |
{ | |
image.UnlockBits(data); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment