×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Regular Contributor
    Join Date
    Aug 2006
    Location
    Rawalpindi, Pakistan
    Posts
    486

    Zooming in and Zooming out of Images

    hi guys

    i need some help out here. i have an image of size 600x800 i have manage to get it into byte array using file connection api. i am using nokia 6680 and problem is it only displays image with maximum size of 256x256. this means i need to include Zoom in and Out Functionality. can abody give me some advice how i can do that. i am using cldc 1.1 and MIDP 2.0
    any kind of code, advice will be appreciated.
    Regards
    Nouman

  2. #2
    Regular Contributor
    Join Date
    Jan 2006
    Posts
    90

    Re: Zooming in and Zooming out of Images

    hi
    Hope that this will help u

    public Image createThumbnail(Image image, int thumbWidth,
    int thumbHeight) {
    int sourceWidth = image.getWidth();
    int sourceHeight = image.getHeight();

    if (thumbHeight == -1)
    thumbHeight = thumbWidth * sourceHeight / sourceWidth;

    Image thumb = Image.createImage(thumbWidth, thumbHeight);
    Graphics g = thumb.getGraphics();

    for (int y = 0; y < thumbHeight; y++) {
    for (int x = 0; x < thumbWidth; x++) {
    g.setClip(x, y, 1, 1);
    int dx = x * sourceWidth / thumbWidth;
    int dy = y * sourceHeight / thumbHeight;
    g
    .drawImage(image, x - dx, y - dy, Graphics.LEFT
    | Graphics.TOP);
    }
    }

    Image immutableThumb = Image.createImage(thumb);

    return immutableThumb;
    }

    jini

  3. #3
    Regular Contributor
    Join Date
    Aug 2006
    Location
    Rawalpindi, Pakistan
    Posts
    486

    Re: Zooming in and Zooming out of Images

    thanx pal that did help. but i have another problem. i am facing a problem that i need to give zoom in and zoom out options. when from thumb nail image i zoom in to lets say 100 percent then the mobile doesnt dispalay my image. this is probably because mobile only display images upto 255x255.
    and form.append(ImageItem)
    where ImageItem is representing my image.

    Now if u could please tell me how can i display an image which is bigger then mobile screen size. i have a 600x800 size image. do i need to create a some special canvas and any other things.
    how can i manage an image bigger then mobile screen size
    Regards
    Nouman

  4. #4
    Regular Contributor
    Join Date
    Jan 2006
    Posts
    90

    Re: Zooming in and Zooming out of Images


  5. #5
    Regular Contributor
    Join Date
    Aug 2006
    Location
    Rawalpindi, Pakistan
    Posts
    486

    Re: Zooming in and Zooming out of Images

    does anyone has an idea how photo editor is handling images. i know its a long shot. but whats wrong in askin
    Regards
    Nouman

  6. #6
    Registered User
    Join Date
    Dec 2005
    Location
    Brazil
    Posts
    1,884

    Re: Zooming in and Zooming out of Images

    Hi Nouman,

    Check this link:

    http://www.java-tips.org/java-me-tip...-zoom-out.html

    I have not tested it, though.

    I hope this helps!

    Juarez Junior
    Juarez Alvares Barbosa Junior - Brazil

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

    Re: Zooming in and Zooming out of Images

    And if you want smoother (but slower and more memory consuming) scaling you can base your code on this.

    shmoove

  8. #8
    Regular Contributor
    Join Date
    Aug 2006
    Location
    Rawalpindi, Pakistan
    Posts
    486

    Re: Zooming in and Zooming out of Images

    thanx guys for all of ur help.

    i have manage to display a thumbnail image. thanks for the code above and then zoom it again thanx for the code. but i have a problem. there is a vertical scroll which are shown by the small arrows for up and down which works fine. but my image also needs a horizontal scroll to move left and right but they arent been shown does. anybody know how i can do that?
    Regards
    Nouman

Posting Permissions

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