User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Legacy and Other Languages section within the Software Development category of DaniWeb, a massive community of 423,744 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,422 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Legacy and Other Languages advertiser: Programming Forums
Views: 939 | Replies: 1
Reply
Join Date: Nov 2007
Posts: 26
Reputation: alcoheca is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
alcoheca alcoheca is offline Offline
Light Poster

J# invalid paramater at runtime

  #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 12:15 pm.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Nov 2007
Posts: 26
Reputation: alcoheca is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
alcoheca alcoheca is offline Offline
Light Poster

Re: J# invalid paramater at runtime

  #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  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Legacy and Other Languages Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the Legacy and Other Languages Forum

All times are GMT -4. The time now is 1:35 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC