Converting Java to C# GDI problem

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Mar 2009
Posts: 5
Reputation: ronson is an unknown quantity at this point 
Solved Threads: 0
ronson ronson is offline Offline
Newbie Poster

Converting Java to C# GDI problem

 
0
  #1
Oct 31st, 2009
Ok I'm converting a program from Java to C# and currently stuck on a certain aspect of it.


Ok I have;

  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...
  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)
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 1,984
Reputation: ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of 
Solved Threads: 289
ddanbe's Avatar
ddanbe ddanbe is offline Offline
Posting Virtuoso
 
0
  #2
Oct 31st, 2009
The BitMap class has a SetPixel method.
Call it like this SetPixel(x,y,aColor);
x,y : coordinates in int.
aColor : Color
Today is a gift, that's why it is called "The Present".
Make love, no war. Cave ab homine unius libri.
Danny
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 5
Reputation: ronson is an unknown quantity at this point 
Solved Threads: 0
ronson ronson is offline Offline
Newbie Poster
 
0
  #3
Nov 1st, 2009
Thanks for the help, I'll look into that.
Reply With Quote Quick reply to this message  
Reply

Tags
bitmap, gdi+

Message:



Other Threads in the C# Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC