| | |
Making a Grid with a picture
![]() |
•
•
Join Date: Nov 2009
Posts: 3
Reputation:
Solved Threads: 0
Alright, I posted earlier with help on compiling my method, now it compiles and now I am stuck again. Help would be great since this awful head cold is getting the best of me.
Ok so, so far I have my method almost where I need it, I have my picture that opens up in to a black area in the upper left hand corner. Now the tricky part, multiplying that image within these parameters. So if I do makeGrid(2) I should see 4 of the same picture in a grid like manner. Here is my code again:
Any helpful hints or suggestions would be much appreciated! Thanks =D
Ok so, so far I have my method almost where I need it, I have my picture that opens up in to a black area in the upper left hand corner. Now the tricky part, multiplying that image within these parameters. So if I do makeGrid(2) I should see 4 of the same picture in a grid like manner. Here is my code again:
Java Syntax (Toggle Plain Text)
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 + indexX; targetY = sourceY * size + indexY; targetPixel =targetPicture.getPixel(targetX, targetY); targetPixel.setColor(sourcePixel.getColor()); } } } } return targetPicture; } }
Any helpful hints or suggestions would be much appreciated! Thanks =D
![]() |
Similar Threads
- linked list, assigning cars to random positions (C)
- Hello JavaGuys/Ladies! Panel Layers being funny... (Java)
- how to open picture in vb by oading internet explorer (Visual Basic 4 / 5 / 6)
- directx-c#: making a grid with different colors (Game Development)
- Adding custom events (C#)
- Help with making animated Picture (Graphics and Multimedia)
- need help with java (Java)
Other Threads in the Java Forum
- Previous Thread: Put ArrayList in HashMap
- Next Thread: Regarding Coverting multiple images to a single pdf in an applet
| Thread Tools | Search this Thread |
911 actionlistener addressbook android api append applet application array arrays automation binary blackberry block bluetooth character chat class client code component consumer csv database desktop developmenthelp eclipse error fractal ftp game givemetehcodez graphics gui html ide image integer j2me j2seprojects japplet java javaarraylist javac javaee javaprojects jni jpanel julia lego linked linux list loops mac map method methods mobile netbeans newbie number objects online oriented panel printf problem program programming project projects properties recursion replaydirector reporting researchinmotion rotatetext rsa scanner se server set singleton sms sort sql string swing test textfields threads time title tree tutorial-sample ubuntu update windows working





