Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2009
    Posts
    25
    Rep Power
    0

    Default How can I square(^2) the pic in the grid

    How can I square(^2) the pic in the grid?


    XML Code:
    public Picture makeGrid(int size)
    {
    Picture targetPicture = new Picture(this.getWidth()*size, this.getHeight()*size);
    Pixel sourcePixel = null;
    Pixel targetPixel = null;
    int targetX = 0;
    int targetY = 0;
    
    //loop through the source picture columns
    for(int sourceX = 0; sourceX < this.getWidth(); sourceX++)
    {
    //loop through the source picture rows
    for(int sourceY = 0; sourceY < this.getHeight(); sourceY++)
    {
    // get the source pixel
    sourcePixel = this.getPixel(sourceX,sourceY);
    
    // loop copying to the target y
    for(int indexY = 0; indexY <size; indexY++)
    {
    // loop copying to the target x
    for(int indexX = 0; indexX < size; indexX++)
    {
    targetX = sourceX + size*2 + indexX;
    targetY = sourceY + size*2 + indexY;
    targetPixel =targetPicture.getPixel(targetX, targetY);
    targetPixel.setColor(sourcePixel.getColor());
    }
    }
    }
    }
    return targetPicture;
    }
    my code give the following result:

    How can I square(^2) the pic in the grid-grid2.jpg for makeGrid(2)


    How can I square(^2) the pic in the grid-grid3.jpg for makeGrid(3)



    But the code should work like this as show:
    How can I square(^2) the pic in the grid-cater.jpg
    How can I square(^2) the pic in the grid-cater.jpg

    I just want to know how to multiply image ...

    I dont know how can I square the pic

    I am new to java
    Chris
    thx

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

  3. #3
    Join Date
    Oct 2009
    Posts
    25
    Rep Power
    0

    Default

    what do you mean by replies ? Nobody gave me a reasonable answer.

Similar Threads

  1. How can I square(^2) the pic in the grid
    By racewithferrari in forum New To Java
    Replies: 1
    Last Post: 11-01-2009, 10:16 PM
  2. Display Square Roots
    By hypes057 in forum New To Java
    Replies: 8
    Last Post: 08-25-2009, 10:34 AM
  3. change the square to triangle java
    By anotsu in forum New To Java
    Replies: 3
    Last Post: 07-09-2009, 11:17 AM
  4. Simple square root problem!
    By nortski in forum New To Java
    Replies: 7
    Last Post: 04-01-2009, 02:11 PM
  5. 8-Square puzzle loop
    By SapphireSpark in forum New To Java
    Replies: 7
    Last Post: 12-04-2008, 07:21 PM

Tags for this Thread

Posting Permissions

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