944,141 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 1173
  • C# RSS
Oct 31st, 2009
0

Converting Java to C# GDI problem

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


Ok I have;

Java Syntax (Toggle Plain Text)
  1. private Graphics g1;
  2. private Bitmap picture;
  3. picture = new Bitmap(x1, y1);
  4. g1 = Graphics.FromImage(picture);
  5. 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...
java Syntax (Toggle Plain Text)
  1. g1.setColor(Color.FromArgb(Convert.ToInt16(h), Convert.ToInt16(0.8f), Convert.ToInt16(b)));
  2. //djm test
  3. 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
Last edited by peter_budo; Nov 2nd, 2009 at 7:31 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ronson is offline Offline
5 posts
since Mar 2009
Oct 31st, 2009
0
Re: Converting Java to C# GDI problem
The BitMap class has a SetPixel method.
Call it like this SetPixel(x,y,aColor);
x,y : coordinates in int.
aColor : Color
Reputation Points: 2035
Solved Threads: 645
Senior Poster
ddanbe is offline Offline
3,740 posts
since Oct 2008
Nov 1st, 2009
0
Re: Converting Java to C# GDI problem
Thanks for the help, I'll look into that.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ronson is offline Offline
5 posts
since Mar 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: help !!!!!!!
Next Thread in C# Forum Timeline: sqlException--invalid expression





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC