Results 1 to 3 of 3
Thread: Syntax Error w/ my method
- 11-11-2012, 02:36 AM #1
Member
- Join Date
- Nov 2012
- Posts
- 11
- Rep Power
- 0
Syntax Error w/ my method
Hello everyone, I am having trouble with this syntax error w/ my program.
I am suppose to mirror a picture and copy that mirrored picture onto another picture.
I have been reading through the textbook, rearranging my method, adding in parameters. I am just lost now. If someone can just point me into the right direction w/ this program I would greatly appreciate it.
public void copyPic(Picture pict, int xStart, int yStart)
{
Pixel sourcePixel = null;
Pixel targetPixel = null;
for(int sourceX =0, targetX = xStart; sourceX < pict.getWidth(); sourceX++, targetX++)
{
for(int sourceY =0, targetY = yStart; sourceY < pict.getHeight(); sourceY++, targetY++)
{
sourcePixel = pict.getPixel(sourceX, sourceY);
targetPixel= this.getPixel(targetX, targetY);
targetPixel.setColor(sourcePixel.getColor());
}
}
}
public void mirrorPic(Picture pict)
{
int height = this.getHeight();
int mirrorPoint = height / 2;
Pixel topPixel = null;
Pixel bottomPixel = null;
Pixel sourcePixel = null;
Pixel targetPixel = null;
for(int sourceX =0, targetX =100; sourceX < pict.getWidth(); sourceX++, targetX++)
{
for(int sourceY =0, targetY = 145; sourceY < pict.getHeight(); sourceY++, targetY++)
{
sourcePixel = pict.getPixel(sourceX, sourceY);
targetPixel = this.getPixel(targetX, targetY);
targetPixel.setColor(sourcePixel.getColor());
for(int x =0; x < pict.getHeight(); x++)
{
for(int y =0; y < mirrorPoint; y++)
{
topPixel = pict.getPixel(x, y);
bottomPixel = this.getPixel(x,height - 1 - y);
bottomPixel.setColor(topPixel.getColor());
}
}
}
}
}
public static void main (String[] args)
{
FileChooser.setMediaPath("C:/Users/runner/Documents/mediasources/");
String backgroundFileName = FileChooser.pickAFile();
Picture background = new Picture(backgroundFileName);
Picture flower = new Picture(FileChooser.pickAFile());
background.copyPic(flower, 10, 10);
background.explore();
background.mirrorPic(flower);
background.show();
}
This is the syntax error: ------> java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!
at sun.awt.image.ByteInterleavedRaster.getDataElement s(Unknown Source)
at java.awt.image.BufferedImage.getRGB(Unknown Source)
at SimplePicture.getBasicPixel(SimplePicture.java:259 )
- 11-13-2012, 05:42 PM #2
Re: Syntax Error w/ my method
Hello and welcome! Please use [code][/code] tags when posting code so we can easily read it!
Forum Rules
Guide For New Members
BB Code List - Java Programming Forum
- 11-13-2012, 07:44 PM #3
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,414
- Blog Entries
- 7
- Rep Power
- 17
Re: Syntax Error w/ my method
Why have you abandoned your other thread? Help to rotate a pic 180 degrees (upside down)
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
Similar Threads
-
Simple Syntax Error(s)
By Vinx in forum New To JavaReplies: 2Last Post: 05-18-2012, 02:55 AM -
No more syntax error
By ideyatech in forum Java SoftwareReplies: 2Last Post: 04-22-2010, 04:20 AM -
how to write method syntax ?
By Bader in forum New To JavaReplies: 2Last Post: 03-14-2010, 05:58 PM -
how to solve syntax error
By pro85 in forum Java AppletsReplies: 5Last Post: 04-06-2009, 11:20 AM -
syntax error
By gabriel in forum New To JavaReplies: 3Last Post: 08-03-2007, 03:26 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks