×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Jun 2007
    Posts
    2

    Post Image.getGraphics() Problem

    Hello,

    I am currently developing a tile based game for various mobile phones. One of my colleges believes there was a problem with the getGraphics() method when it was being generated from an Image on some nokia phones. I have not been able to find any information about it (which makes me think he is confused about another make/bug) so I thought I would try this forum to get a definitive answer on the matter.

    The code which he has a problem with is partially listed below
    Code:
    		private Image generateImage(String value,boolean isNumber) throws Exception
    	{
    		Image gen;
    		Image tile;
    		tile =  Image.createImage("/res/puzzle/numbers/tile0.png");
    		gen = Image.createImage(SQUARE_SIZE, SQUARE_SIZE);
    		Graphics g = gen.getGraphics();
    		g.drawImage(tile, 0, 0, Graphics.TOP|Graphics.LEFT);
    		g.setColor(0,0,0);
    		g.drawString(value,SQUARE_SIZE/2,10,0);
    		return gen;
    	}
    Thanks in advance.

  2. #2
    Registered User
    Join Date
    Jun 2007
    Location
    Mumbai, India
    Posts
    1,998

    Re: Image.getGraphics() Problem

    Quote Originally Posted by aclelland2
    Hello,

    I am currently developing a tile based game for various mobile phones. One of my colleges believes there was a problem with the getGraphics() method when it was being generated from an Image on some nokia phones. I have not been able to find any information about it (which makes me think he is confused about another make/bug) so I thought I would try this forum to get a definitive answer on the matter.

    The code which he has a problem with is partially listed below
    Code:
    		private Image generateImage(String value,boolean isNumber) throws Exception
    	{
    		Image gen;
    		Image tile;
    		tile =  Image.createImage("/res/puzzle/numbers/tile0.png");
    		gen = Image.createImage(SQUARE_SIZE, SQUARE_SIZE);
    		Graphics g = gen.getGraphics();
    		g.drawImage(tile, 0, 0, Graphics.TOP|Graphics.LEFT);
    		g.setColor(0,0,0);
    		g.drawString(value,SQUARE_SIZE/2,10,0);
    		return gen;
    	}
    Thanks in advance.
    Hi,

    Can you ellaborate what exactly was ur problem or what was the error message you received.

  3. #3
    Super Contributor
    Join Date
    Mar 2003
    Location
    Israel
    Posts
    2,280

    Re: Image.getGraphics() Problem

    I don't see any problems with the code you posted. With getGraphics() you can run into trouble if you try to call it on an immutable image (in your code, tile.getGraphics() would throw an exception I think). Maybe that is what your colleage noticed?

    shmoove

Similar Threads

  1. Problem with eglSwapBuffers and heap corruption
    By greatape in forum Symbian Media (Closed)
    Replies: 2
    Last Post: 2007-05-24, 03:35
  2. netcards - Problem with opening adapter
    By kernj in forum Symbian Tools & SDKs
    Replies: 5
    Last Post: 2007-01-10, 08:56
  3. WAP service problem on Apache
    By bigg_o in forum Browsing and Mark-ups
    Replies: 3
    Last Post: 2005-04-17, 16:05
  4. Problem: S60 SDK for CW in PC with .NET
    By anttij in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 1
    Last Post: 2005-02-28, 11:36

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •