Discussion Board

Results 1 to 4 of 4
  1. #1
    Regular Contributor vineetbillorey's Avatar
    Join Date
    Aug 2008
    Location
    Gurgaon, India
    Posts
    155
    hi all,

    i m resizing an image and returning it to display in canvas.

    it displays fine in j2mewtk 2.5.2 emulator, but when i run the .jar file in LG KG195, it returns the image, but doesn't show on screen.

    code is as follows:
    Code:
    public Image rescaleImage(Image image, int width, int height)
    {	int sourceWidth = image.getWidth();
    	int sourceHeight = image.getHeight();
    	Image newImage = Image.createImage(width, height);
    	Graphics g = newImage.getGraphics();
    	for(int y=0; y<height; y++)
    	{	for(int x=0; x<width; x++)
    		{	g.setClip(x, y, 1, 1);
    			int dx = x * sourceWidth / width;
    			int dy = y * sourceHeight / height;
    			g.drawImage(image,x-dx,y-dy,Graphics.LEFT|Graphics.TOP);
    		}
    	}
    	return Image.createImage(newImage);
    }
    thanx in advance
    Vineet Billorey "The Great"

  2. #2
    Nokia Developer Champion raj_J2ME's Avatar
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,314
    Quote Originally Posted by vineetbillorey View Post
    hi all,

    i m resizing an image and returning it to display in canvas.

    it displays fine in j2mewtk 2.5.2 emulator, but when i run the .jar file in LG KG195, it returns the image, but doesn't show on screen.

    code is as follows:
    Code:
    public Image rescaleImage(Image image, int width, int height)
    {	int sourceWidth = image.getWidth();
    	int sourceHeight = image.getHeight();
    	Image newImage = Image.createImage(width, height);
    	Graphics g = newImage.getGraphics();
    	for(int y=0; y<height; y++)
    	{	for(int x=0; x<width; x++)
    		{	g.setClip(x, y, 1, 1);
    			int dx = x * sourceWidth / width;
    			int dy = y * sourceHeight / height;
    			g.drawImage(image,x-dx,y-dy,Graphics.LEFT|Graphics.TOP);
    		}
    	}
    	return Image.createImage(newImage);
    }
    thanx in advance
    Hi,
    How you know that the image is created and the issue is related to drawing of the image?

    Can you check that the image is actually created successfully?
    can you check that the device displays the other image correctly...?
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  3. #3
    Regular Contributor vineetbillorey's Avatar
    Join Date
    Aug 2008
    Location
    Gurgaon, India
    Posts
    155
    Hi,
    it displays the height and width of the returned image
    also, the midlet runs fine for other options/images in mobile
    Code is as follows:

    Code:
    	Image img1=rescaleImage(img,width,height);
    	iw=img1.getWidth();
    	ih=img1.getHeight();
    	g.setColor(0,0,255);
    	//Following line displays the height and width of the returned image
    	//This shows that an image is actually being returned
    	g.drawString(iw+","+ih,2,4,g.TOP|g.LEFT);
    	g.drawImage(img1,(x,y,g.TOP|g.LEFT);
    	//but the image is not being displayed here
    Thanx in advance
    Vineet Billorey "The Great"

  4. #4
    Nokia Developer Champion raj_J2ME's Avatar
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,314
    Hi,
    Can you check this code works for the other devices to...either the Nokia of LG..
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

Similar Threads

  1. J2ME or C++ for VoIP on Mobile Phone
    By sandeepkumar03 in forum Mobile Java Media (Graphics & Sounds)
    Replies: 2
    Last Post: 2008-11-13, 20:14
  2. how to do image compression in j2me
    By proj_sumaiya in forum Mobile Java General
    Replies: 2
    Last Post: 2008-02-04, 12:46
  3. cature and save image using J2ME?
    By gr8umm in forum Mobile Java General
    Replies: 11
    Last Post: 2007-04-19, 20:48
  4. query on image processing using j2me
    By rj_cybersilver in forum Mobile Java Media (Graphics & Sounds)
    Replies: 4
    Last Post: 2005-02-03, 10:05
  5. Image capturing using MMAPI of J2ME in series 60
    By adhiyal in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2004-10-01, 07:25

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved