×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Regular Contributor
    Join Date
    Jul 2008
    Posts
    72

    Displyaing image blocks in canvas

    Hello friends,

    I have a problem where i need to display 4 images(which are blocks of a single image). A single image is splitted in to 4 small images. Now the problem is how do i display all the 4 images in canvas. Is there any way of displaying images like the following:

    Image 1 Image 2




    Image 3 Image 4




    Thanks

  2. #2
    Super Contributor
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: Displyaing image blocks in canvas

    Hi,

    The way I see it, all you have to do is specify the appropriate coordinates (x and y) for each image. For example:
    Code:
    int x=10, y=20;
    g.drawImage(img1, x, y, Graphics.TOP|Graphics.LEFT);
    Note that the image is drawn with its top-left corner at (x, y) in this graphics context's coordinate space.

    If I understood your question, doing that for each image (with appropriate x and y for each image) should be the solution.
    Last edited by bogdan.galiceanu; 2008-09-16 at 14:40.

  3. #3
    Regular Contributor
    Join Date
    Jul 2008
    Posts
    72

    Re: Displyaing image blocks in canvas

    Thanks for the reply.


    Is there any way from which i can know in which position of the image am I looking? I mean am I at the top or at the center of one image?

    And how do i know within the four images, in which image am i viewing?

    Looking for your reply

  4. #4
    Super Contributor
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: Displyaing image blocks in canvas

    The x and y coordinates refer to the image's top-left corner. You can use each image's getHeight() and getWidth() methods to see how much you should modify the x and y so that the next image will be drawn in the correct location.

Similar Threads

  1. Replies: 2
    Last Post: 2008-06-19, 07:02
  2. modifying image on display in canvas
    By aqibarain in forum Mobile Java General
    Replies: 1
    Last Post: 2007-11-30, 09:01
  3. Opening a JPEG Image
    By ummarbhutta in forum Mobile Java Media (Graphics & Sounds)
    Replies: 8
    Last Post: 2007-02-15, 06:34
  4. how to cut some part of Image
    By mshouab in forum Mobile Java Media (Graphics & Sounds)
    Replies: 2
    Last Post: 2006-08-04, 09:05
  5. Nokia Image Converter
    By davidpurdie in forum General Development Questions
    Replies: 0
    Last Post: 2004-02-18, 15:31

Posting Permissions

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