×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 26
  1. #1
    Registered User
    Join Date
    Aug 2008
    Location
    Gurgaon, India
    Posts
    155

    Unhappy writing an image to mobile using JSR 75

    how can I save a png image to mobile memory using jsr-75

    thanks
    Vineet Billorey "The Great"

  2. #2
    Regular Contributor
    Join Date
    Mar 2008
    Posts
    198

    Re: writing an image to mobile using JSR 75

    Quote Originally Posted by vineetbillorey View Post
    how can I save a png image to mobile memory using jsr-75
    There's no easy way to convert an Image into the correct format for saving as a PNG file. You can get the RGB values of an Image, but then you need to convert that into the PNG format, for which you will need to read the PNG documentation.

    - Mike
    NAVTEQ Network for Developers
    The community for developing innovative location-based applications
    http://NN4D.com
    Last edited by mikemoore; 2009-03-26 at 13:22.

  3. #3
    Registered User
    Join Date
    Aug 2008
    Location
    Gurgaon, India
    Posts
    155

    Unhappy Re: writing an image to mobile using JSR 75

    sorry,

    can't get
    Vineet Billorey "The Great"

  4. #4
    Super Contributor
    Join Date
    Sep 2008
    Location
    Noida, U.P.
    Posts
    1,330

    Thumbs up Re: writing an image to mobile using JSR 75

    Hi,
    convert the image to byte[],
    open fileconnection/// FileConnection conn = (FileConnection)Connector.open("file:///E:/image.png");
    open outputstream with that connection // OutputStream stream = conn.openOutPutStream();
    write the byte[] to the stream /// stream.write(byte[]);
    fflush the stream,
    close the stream
    close the connection
    thanks,
    jitu_goldie..

    KEEP TRYING..

  5. #5
    Regular Contributor
    Join Date
    Oct 2005
    Location
    Cairo,Egypt
    Posts
    72

    Re: writing an image to mobile using JSR 75

    Dear vineetbillorey,
    The image class have function that get the RGB of the image BUT this data is the RAW image data.
    the Images Extensions PNG and BMP and JPG all have their own format for saving this RAW data so you will search about the target extention format and save this RAW data on their required format.
    i think you will find the BMP format is the easist one because it doesn't have any compression.
    just some headers values you will specify then the RAW data in simple format.

    Hope it help
    Wael Nabil
    Product Manager
    CITGlobal MOBiDIV
    Egypt.

  6. #6
    Registered User
    Join Date
    Aug 2008
    Location
    Gurgaon, India
    Posts
    155

    Unhappy Re: writing an image to mobile using JSR 75

    file is being created but in improper format.
    code is as follows:

    Code:
    public void run()
    {	try
    	{	FileConnection fc=(FileConnection)Connector.open("file:///root1/copy.png",Connector.READ_WRITE);
    		if(!fc.exists())
    			fc.create();
    		OutputStream os=fc.openOutputStream();
    		int iw=img.getWidth();int ih=img.getHeight();
    		int[] rawInt=new int[iw*ih];
    		img.getRGB(rawInt,0,iw,0,0,iw,ih);
    		ByteArrayOutputStream baos=new ByteArrayOutputStream();
    		for(int i=0;i<rawInt.length;i++)
    			baos.write(rawInt[i]);
    		byte byteData[]=baos.toByteArray();
    		baos.close();
    		os.write(byteData);
    		os.flush();
    		os.close();
    		f.append("\n\nImage Copied..\n");
    	}catch(java.io.IOException ioe){f.append(ioe.toString());}
    }
    Vineet Billorey "The Great"

  7. #7
    Regular Contributor
    Join Date
    Oct 2005
    Location
    Cairo,Egypt
    Posts
    72

    Re: writing an image to mobile using JSR 75

    Dear vineetbillorey,
    Here you saved the RAW data which will not be viewed by the mobile device because it doesn't have any Meta data in the header.
    let have the example again.
    let me say you want to save it BMP.
    so you will get BMP format and you can use the following.
    http://en.wikipedia.org/wiki/BMP_file_format

    then write out the header as they specify in the format.
    then write those RAW data you have as they specify then you can view it.

    Thanks
    Wael Nabil
    Product Manager
    CITGlobal MOBiDIV
    Egypt.

  8. #8
    Super Contributor
    Join Date
    Sep 2008
    Location
    Noida, U.P.
    Posts
    1,330

    Thumbs up Re: writing an image to mobile using JSR 75

    Hi vinnetbillorey,

    can u tell me that what is the source of ur image. Server or Resource folder.
    thanks,
    jitu_goldie..

    KEEP TRYING..

  9. #9
    Registered User
    Join Date
    Aug 2008
    Location
    Gurgaon, India
    Posts
    155

    Unhappy Re: writing an image to mobile using JSR 75

    hi,
    following method is my source of image which fades it and returns a new image to be written to mobile memory
    Code:
    public Image fadeImage(Image img,int mAlpha)
    {	int iw=img.getWidth();
    	int ih=img.getHeight();
    	int[] rawInt=new int[iw*ih];
    	img.getRGB(rawInt,0,iw,0,0,iw,ih);
    	int len=rawInt.length;
    	int color=0,alpha=0;
    	for(int i=0;i<len;i++)
    	{	color=(rawInt[i] & 0x00FFFFFF);
    		alpha=mAlpha<<24;
    		color+=alpha;
    		rawInt[i]=color;
    	}
    	Image temp=Image.createRGBImage(rawInt,iw,ih,true);
    	return temp;
    }
    Last edited by vineetbillorey; 2009-03-27 at 09:01.
    Vineet Billorey "The Great"

  10. #10
    Regular Contributor
    Join Date
    Mar 2008
    Posts
    198

    Re: writing an image to mobile using JSR 75

    Your code returns RGB format. You now need to convert it to PNG format. There is no functionality to do this in Java Micro Edition.

    - Mike
    NAVTEQ Network for Developers
    The community for developing innovative location-based applications
    http://NN4D.com

  11. #11
    Registered User
    Join Date
    Aug 2008
    Location
    Gurgaon, India
    Posts
    155

    Unhappy Re: writing an image to mobile using JSR 75

    can u suggest some external file..??
    Vineet Billorey "The Great"

  12. #12
    Regular Contributor
    Join Date
    Mar 2008
    Posts
    198

    Re: writing an image to mobile using JSR 75

    Quote Originally Posted by vineetbillorey View Post
    can u suggest some external file..??
    I'm sorry, I don't understand your question. Do you mean, is there a some code somewhere that converts Java Micro Edition RGB to PNG, then I haven't been able to find one. You might like to post your version here when you create it.

    - Mike
    NAVTEQ Network for Developers
    The community for developing innovative location-based applications
    http://NN4D.com
    Last edited by mikemoore; 2009-03-27 at 11:45.

  13. #13
    Registered User
    Join Date
    Aug 2008
    Location
    Gurgaon, India
    Posts
    155

    Unhappy Re: writing an image to mobile using JSR 75

    yeah,

    i ve got one,

    http://www.chrfr.de/software/midp_png.html

    but it also does not save in proper format

    can u try it..??
    Vineet Billorey "The Great"

  14. #14
    Super Contributor
    Join Date
    Sep 2008
    Location
    Noida, U.P.
    Posts
    1,330

    Thumbs up Re: writing an image to mobile using JSR 75

    Hi,
    Quote Originally Posted by vineetbillorey View Post
    hi,
    following method is my source of image which fades it and returns a new image to be written to mobile memory
    Code:
    public Image fadeImage(Image img,int mAlpha)
    {	int iw=img.getWidth();
    	int ih=img.getHeight();
    	int[] rawInt=new int[iw*ih];
    	img.getRGB(rawInt,0,iw,0,0,iw,ih);
    	int len=rawInt.length;
    	int color=0,alpha=0;
    	for(int i=0;i<len;i++)
    	{	color=(rawInt[i] & 0x00FFFFFF);
    		alpha=mAlpha<<24;
    		color+=alpha;
    		rawInt[i]=color;
    	}
    	Image temp=Image.createRGBImage(rawInt,iw,ih,true);
    	return temp;
    }
    I dont mean this. Actually i want to know that form where u get the image. Are u downloading the image from server or reading from resource?
    thanks,
    jitu_goldie..

    KEEP TRYING..

  15. #15
    Registered User
    Join Date
    Aug 2008
    Location
    Gurgaon, India
    Posts
    155

    Red face Re: writing an image to mobile using JSR 75

    i m reading it from the following folder:
    Code:
    Image img=Image.createImage("/gallery/Picture1.png");
    Vineet Billorey "The Great"

Similar Threads

  1. How to take image by mobile phone even without taking snap shot
    By sprateek in forum Mobile Java General
    Replies: 1
    Last Post: 2009-02-18, 18:00
  2. FPC Bench, Database API and a lot more...
    By sblantipodi in forum Mobile Java Tools & SDKs
    Replies: 4
    Last Post: 2008-03-23, 01:47
  3. --- ???save image problem??? ---
    By ferenn in forum Mobile Java Media (Graphics & Sounds)
    Replies: 6
    Last Post: 2007-10-01, 14:33
  4. HELP: Mutable Image to Immutable Image?
    By rj_cybersilver in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2005-03-26, 09:58

Posting Permissions

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