Ok I'm converting a program from Java to C# and currently stuck on a certain aspect of it.


Ok I have;

private Graphics g1;
private Bitmap picture;
picture = new Bitmap(x1, y1);
g1 = Graphics.FromImage(picture);
pbMand.Image = picture;

pbMand is the name of my picture box, which I will use to display the image (not drawing directly to form, using PB).

Then further on I have...

g1.setColor(Color.FromArgb(Convert.ToInt16(h), Convert.ToInt16(0.8f), Convert.ToInt16(b)));
                        //djm test
                        Color col = Color.getHSBColor(h, 0.8f, b);

I can't find an equivilent form javas setColor to something in C#...It seems to lack anything colour related in g1's methods.

And the error it gives is...
Error 1 'System.Drawing.Graphics' does not contain a definition for 'setColor' and no extension method 'setColor' accepting a first argument of type 'System.Drawing.Graphics' could be found (are you missing a using directive or an assembly reference?

Any help to solve this issue would be appreciated. I'm not sure what other information I can give either, so feel free to ask questions :)

Recommended Answers

All 2 Replies

The BitMap class has a SetPixel method.
Call it like this SetPixel(x,y,aColor);
x,y : coordinates in int.
aColor : Color

Thanks for the help, I'll look into that. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.