×

Discussion Board

Results 1 to 12 of 12
  1. #1
    Registered User
    Join Date
    Aug 2013
    Posts
    37

    [moved] code to take screenshot in j2me

    I want a working j2me code for taking screenshot of the canvas.. I have already searched the forum and got many codes.. I have tried all of them but none works.. So please give me a working code along with the paint method..

  2. #2
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    686

    Re: [help] code to take screenshot in j2me

    there is no code to take the actual screenshot of the device.
    You can however (if your using canvas or gamecanvas) save an image of your own app screen.
    create an image with the dimmensions of your canvas using Image.createImage(width,height)
    save its Graphics object using Image.getGraphics();
    call your canvas Paint method with the image Graphics object.
    now you have a copy image of the canvas screen, now all you need is to save it as an image to the file system.
    You can save it as bitmap (which is the easiest since your saving each pixel data and there is no compression of any kind so just traversing over the Image RGB array)
    or you can save it as a PNG or JPG which means you will need to "encode" the image RGB data (which you obtain using Image.getRGB(...)) you can right your own or google for such (here is a png encoder that is good for j2me http://www.chrfr.de/software/midp_png.html i've tested it and it works)

  3. #3
    Registered User
    Join Date
    Aug 2013
    Posts
    37

    Re: [help] code to take screenshot in j2me

    I have already tested that and it also saves the image in png format to my memory card but the problem is that the image cannot be opened.

  4. #4
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,179

    Re: [help] code to take screenshot in j2me

    I suppose you are then saving it wrongly. So do check what was said on saving the image., Also you need to set the extension right, since who ever opens the image, likely will not use any data recognistion for opening it, and simply relies on the extension to match the actual data inside the image file.

  5. #5
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    686

    Re: [help] code to take screenshot in j2me

    subha095: i can guarantee that it does work because i have used it in the past, infact you can check out my app Snowman Builder http://store.ovi.com/content/357751 that saves the image you create on the screen to the phone file system and it uses the same (with some extra stuff i've put it to make the PNG compressed)
    If you liked the app dont forget to give it a nice 5 star rating and if you need extra help i'm here.

  6. #6
    Registered User
    Join Date
    Aug 2013
    Posts
    37

    Re: [help] code to take screenshot in j2me

    About your previous message after converting the image into int[] if I save the image with .png extention will i work. And the png.java file's link you gave has a command toPNG() which my compiler cant recognize.
    Last edited by subha095; 2013-08-26 at 01:29.

  7. #7
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    686

    Re: [help] code to take screenshot in j2me

    Sorry but i couldnt understand your message, can you please try and explain again what isnt working for you with the link i gave you and perhaps also attached your source code of your implementation of this.

  8. #8
    Registered User
    Join Date
    Aug 2013
    Posts
    37

    Re: [help] code to take screenshot in j2me

    The link which was given to me has toPNG() command which my compiles doesnt understand.. Now what to do.

  9. #9
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    686

    Re: [help] code to take screenshot in j2me

    why does your compiler doesnt "understand that command"?
    toPng() needs 6 parameters
    width of the png
    height of the png
    a byte[] of alpha channel
    a byte[] of red channel
    a byte[] of green channel
    a byte[] of blue channel

    have you include the png.java in your source code folder?
    have you added the proper import in your code to use PNG class?
    what is the error you are getting?
    As i've said before its working fine for me, if you want better help please attach more details such as your source code of your implementation, screenshots of errors your getting, etc.

  10. #10
    Registered User
    Join Date
    Aug 2013
    Posts
    37

    Re: [help] code to take screenshot in j2me

    I cant compile code due to this command.. Maybe any import part is wrong. I have import javax.microedition.lcdui.*;

  11. #11
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    686

    Re: [help] code to take screenshot in j2me

    There is no problem with the toPNG command i just tested it again on a test project.
    Did you make sure to change the package decleration of the PNG class or place it in its default gfx package?
    If you want further help then i say again please attach more details such as your source code of your implementation, screenshots of errors your getting, etc.

  12. #12
    Registered User
    Join Date
    Aug 2013
    Posts
    37

    Re: [help] code to take screenshot in j2me

    Quote Originally Posted by shai.i View Post
    There is no problem with the toPNG command i just tested it again on a test project.
    Did you make sure to change the package decleration of the PNG class or place it in its default gfx package?
    If you want further help then i say again please attach more details such as your source code of your implementation, screenshots of errors your getting, etc.
    thanks it works.. Superb idea..

Similar Threads

  1. [moved] register my location (coordinate ) using J2ME code
    By souhir in forum Mobile Java General
    Replies: 12
    Last Post: 2013-02-13, 18:12
  2. TAKING SCREENSHOT IN SYMBIAN S60 USING J2ME
    By ajay.hakke in forum Mobile Java Media (Graphics & Sounds)
    Replies: 2
    Last Post: 2012-04-10, 15:31
  3. Can I call Symbian C++ code from J2me code?
    By Rupa in forum Mobile Java General
    Replies: 6
    Last Post: 2010-11-24, 14:31
  4. Replies: 2
    Last Post: 2010-06-23, 11:33
  5. J2ME Screenshot of a Canvas
    By mtgbe in forum Mobile Java General
    Replies: 9
    Last Post: 2010-01-19, 17:05

Posting Permissions

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