1 Reply Latest reply: Apr 29, 2013 12:03 PM by 1006163 RSS

    Image.createImage exception

    1005373
      Hi all, I have problem with loading image to my application. If I create image with method
      Image.createImage(String name)
      everything is ok and image shows up, but when I want to use just part of this image and I call method
      Image.createImage(Image image, int x, int y, int width, int height, int transform)
      the Exception is thrown.

      Part of my code:
      - works correct:
      try { 
          String name = "name.png"; 
          Image img = Image.createImage(name); 
      
          g.drawImage(img, imageX, imageY, 0); 
      } catch (IOException ioex) { 
          System.err.println(ioex); 
      }
      - throws Exception:
      try { 
          String name = "name.png"; 
          Image img = Image.createImage(name); 
      
          img = Image.createImage(img, 0, 0, img.getWidth(), img.getWidth(), Sprite.TRANS_NONE);    // the whole image is 26x364 and I'd like to use just 26x26 from the top left corner
      
          g.drawImage(img, imageX, imageY, 0); 
      } catch (IOException ioex) { 
          System.err.println(ioex); 
      } catch (IllegalArgumentException iaex) { 
          System.err.println(iaex); 
      }
      Any idea what could be wrong? Thank you.