| | |
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 |
2dgraphics account android api apple applet application arguments array arrays automation banking binary binarytree bluetooth chat chatprogramusingobjects class client code color component count database derby design eclipse eclipsedevelopment encryption error fractal game givemetehcodez graphics gridlayout gui homework html ide if_statement image integer interface j2me java javadesktopapplications javaprojects jlabel jni jpanel jtextfield julia keyword linux list macintosh map method methods midlethttpconnection mobile netbeans newbie nullpointerexception object open-source os problem producer program programming project projectideas property read recursion reference replaysolutions ria scanner search server set size sms sort sourcelabs splash sql sqlite stop string swing threads transforms tree ui unicode validation windows





