×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Registered User
    Join Date
    Nov 2008
    Posts
    47

    add text like photo editor

    hi i really need help.

    any idea of how to add a text to a current photo whereby i able to use the keypres and set the suitable place on the photo and set it there?

    its similar to editing photo functions in the mobile where they allow user to add text content to the photo and set the location.

    Any ideas how to do it? or any codes references for me?
    I am using J2me and netbeans

    Thank You in advance =)

  2. #2
    Nokia Developer Moderator
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: add text like photo editor

    There is no point in starting several identical threads. You already have on here, in the Mobile Java Media subforum.

  3. #3
    Nokia Developer Champion
    Join Date
    Nov 2007
    Location
    Rome, Italy
    Posts
    2,405

    Re: add text like photo editor

    Hi,

    about adding text to an Image, here's a hopefully useful code snippet:
    Code:
    //load the original image here
    Image originalImage = Image.createImage("...");
    
    //create a mutable Image
    Image modifiedImage = Image.createImage(originalImage.getWidth(), originalImage.getHeight());
    
    Graphics modifiedGraphics = modifiedImage.getGraphics();
    
    //copy the original image into the mutable one
    modifiedGraphics.drawImage(originalImage, 0, 0, Graphics.TOP | Graphics.LEFT);
    
    //set the Font you prefer
    modifiedGraphics.setFont(Font.getDefaultFont());
    modifiedGraphics.setColor(0x000000);
    
    //draw the text over the original image content
    modifiedGraphics.drawString("Your text", 0, 0, Graphics.TOP | Graphics.LEFT);
    About the keypress-related feature: you should implement this by using Canvas and its keyPressed() method.

    Pit

    EDIT: I've missed the duplicate thread in the Java Media board. Feel free to move my reply

  4. #4
    Registered User
    Join Date
    Nov 2008
    Posts
    31

    Re: add text like photo editor

    Quote Originally Posted by jappit View Post
    EDIT: I've missed the duplicate thread in the Java Media board. Feel free to move my reply
    Hi, i would like to ask about the keypress method.
    i have already done it after i set the text into the picture, i can move the text to whereever i want in the picture.

    But then i press the FIRE button, i need to set it in place, kind of like combine the text with the picture.

    How do i go about doing it?
    im using j2me Netbeans also.
    Thanks ^^

    EDIT: the following code you given, is for normal image extensions right?
    because im current using SVG image as my images. i tried importing my SVG images in your code samples, doesn't seems to work =(
    Thanks ^^
    Last edited by shirodas; 2008-11-12 at 03:28.

  5. #5
    Nokia Developer Champion
    Join Date
    Nov 2007
    Location
    Rome, Italy
    Posts
    2,405

    Re: add text like photo editor

    Hi shirodas,

    to work with SVG images you need to use JSR 226, and above code will not work with it. You can start having a look at Java ME Developer's Library:

    http://www.forum.nokia.com/document/...97CCD7FFE.html

    Then, if you have any questions, feel free to post them here

    Pit

  6. #6
    Registered User
    Join Date
    Nov 2008
    Posts
    47

    Re: add text like photo editor

    hi jappit. in the source codes u gave
    Image originalImage = Image.createImage("...");

    i put Image originalImage = Image.createImage("/pictures/background1.png");

    it has some illegal arguements. so does it means we cannot take the background image?

    in this case how am i able to set my original background to the canvas and then draw the text there and allow the user to shift it to their position and set it on the background image?

  7. #7
    Nokia Developer Champion
    Join Date
    Nov 2007
    Location
    Rome, Italy
    Posts
    2,405

    Re: add text like photo editor

    Have you bundled 'background.png' image into your project 'res' folder, inside a 'picture/' subfolder?

    Pit

  8. #8
    Registered User
    Join Date
    Nov 2008
    Posts
    47

    Re: add text like photo editor

    yes i did it is in the folder. mutable cannot create image from folder?

  9. #9
    Nokia Developer Champion
    Join Date
    Nov 2007
    Location
    Rome, Italy
    Posts
    2,405

    Re: add text like photo editor

    When you create an Image from a (local or remote) resource, you're actually creating an immutable Image. This is the reason why, in the code snipped provided before, you have to create a mutable Image to write your text on.

    About your problem: are you getting an Exception? If yes, which one?

    Pit

Similar Threads

  1. How to make text editor exactly like S60 default sms editor?
    By madsum in forum Symbian User Interface
    Replies: 9
    Last Post: 2009-11-10, 09:02
  2. Rich text editor in CAknSettingItemList
    By er_benji in forum Symbian User Interface
    Replies: 0
    Last Post: 2008-08-28, 11:12
  3. Resizeable EDWIN text editor??????
    By shahzadamin in forum News and Announcements
    Replies: 0
    Last Post: 2007-10-29, 10:33
  4. Replies: 0
    Last Post: 2004-11-24, 18:49
  5. Java MIDP text editor
    By torpo in forum Mobile Java Media (Graphics & Sounds)
    Replies: 0
    Last Post: 2003-05-16, 09:20

Posting Permissions

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