Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static uint GetBlockColor(Bitmap bmd) {
- uint r = 0, g = 0, b = 0;
- for (int x = 0; x < bmd.Height; x++){
- for (int y = 0; y < bmd.Width; y++){
- uint color = ColorToUInt(bmd.GetPixel(x, y));
- r += (color & 0xff0000) >> 16;
- g += (color & 0x00ff00) >> 8;
- b += (color & 0x0000ff);
- }
- }
- r /= (uint)(bmd.Width * bmd.Height); //256
- g /= (uint)(bmd.Width * bmd.Height); //256
- b /= (uint)(bmd.Width * bmd.Height); //256
- return 0xff000000 | (r << 16) | (g << 8) | (b << 0);
- }
- private static uint ColorToUInt(Color color) => (uint)((color.A << 24) | (color.R << 16) | (color.G << 8) | (color.B << 0));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement