J# invalid paramater at runtime

Reply

Join Date: Nov 2007
Posts: 26
Reputation: alcoheca is an unknown quantity at this point 
Solved Threads: 0
alcoheca alcoheca is offline Offline
Light Poster

J# invalid paramater at runtime

 
0
  #1
Apr 24th, 2008
Hi, I have this issue with a J# project I need to complete for uni.

  1. public class Sprite
  2. {
  3. private Image m_image;
  4.  
  5. public Sprite(Image image)
  6. {
  7. m_image = image;
  8. }
  9.  
  10. public int getWidth()
  11. {
  12. return m_image.get_Width();
  13. }
  14.  
  15. public int getHeight()
  16. {
  17. return m_image.get_Height();
  18. }
  19.  
  20. public void draw(Graphics g, int x, int y)
  21. {
  22. g.DrawImage(this.m_image, x, y);
  23. }
  24. }

This compiles fine, however when I run the program the Image member variable m_image ends up with a Bitmap type rather than an Image.

Here's is the code where the bitmap is loaded, at no point do I cast, or use the bitmap type, so I'm left unsure how to fix it...

  1. public Sprite getSprite(String ref)
  2. {
  3. /* check for cached sprite */
  4.  
  5. if (imageCache.get(ref) != null)
  6. {
  7. return (Sprite)imageCache.get(ref);
  8. }
  9.  
  10. /* not found, load in bitmap now */
  11.  
  12. Image inputFile = null;
  13.  
  14. try
  15. {
  16. inputFile = Image.FromFile(ref + ".bmp");
  17. }
  18. catch (Exception e)
  19. {
  20. System.err.println("Load failed: " + ref + ".bmp");
  21. System.exit(0);
  22.  
  23. }
  24.  
  25. // create a sprite, add it the cache then return it
  26.  
  27. Sprite sprite = new Sprite(inputFile);
  28. imageCache.put(ref, sprite);
  29.  
  30. return sprite;
  31. }
This cause an exception of "invalid paramater".

edit: I'm using the windows classes System.Drawing.* which is why I haven't posted this on the Java forum.
Last edited by alcoheca; Apr 24th, 2008 at 1:15 pm.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 26
Reputation: alcoheca is an unknown quantity at this point 
Solved Threads: 0
alcoheca alcoheca is offline Offline
Light Poster

Re: J# invalid paramater at runtime

 
0
  #2
Apr 30th, 2008
No one has any idea?

start of rant:
MSDN Forums are dead, no one is using J#, my lecturer is useless.. why force us to use this language with such limited support docs, examples, etc...
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Legacy and Other Languages Forum
Thread Tools Search this Thread



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

©2003 - 2009 DaniWeb® LLC