开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜