开发者

How do I use Color[] Colors in C#? [closed]

开发者 https://www.devze.com 2023-03-16 19:17 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. For help clari
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

Ok so , I found this cool code and I can't use it. You see ... We have to input an Image which I can do it 开发者_开发百科but we also need to Input Colors which I dont know how to do it...

public static Bitmap Colorize(Bitmap Image, Color[] Colors)
{
    if (Colors.Length < 256)
       return null;
    Bitmap TempBitmap = new Bitmap(Image.Width, Image.Height);
    for (int x = 0; x < Image.Width; ++x)
    {
        for (int y = 0; y < Image.Height; ++y)
        {
           int ColorUsing = Image.GetPixel(x, y).R;
            TempBitmap.SetPixel(x, y, Colors[ColorUsing]);
        }
    }
    return TempBitmap;
}


You need to pass in an array of Color objects, as follows:

        Bitmap bitmapToColorize = new Bitmap(@"C:\bitmap.bmp");
        Color[] colors = new Color[2];
        colors[0] = Color.Blue;
        colors[1] = Color.Green;

        Colorize(bitmapToColorize, colors);

Of course, looking at the method, it looks like you need to fill the Color array with at least 256 colors.

I would recommend you read up on arrays.

0

精彩评论

暂无评论...
验证码 换一张
取 消