ich versuche hier alle Punkte um die an einen Punkt angrenzen und die selbe farb
e haben
doch leider liefert mir
eine ClassCastException und ich weiß nicht wie ich aus dder Arraylist Pojnt[] kriege
Kann mir jemand dabei helfen?
e haben
Code:
static Point[] getUmliegendePixel(Point pixel, BufferedImage bild, int ausgangs_farbe)
{
if(pixel !=null)
{
ArrayList<Point> Points = new ArrayList<Point>();
Point[] last_Points=new Point[0];
if(bild.getRGB(pixel.x-1, pixel.y) == ausgangs_farbe )
{
Points.add(new Point(pixel.x-1, pixel.y));
}
if(bild.getRGB(pixel.x+1, pixel.y) == ausgangs_farbe )
{
Points.add(new Point(pixel.x+1, pixel.y));
}
if(bild.getRGB(pixel.x, pixel.y-1) == ausgangs_farbe )
{
Points.add(new Point(pixel.x, pixel.y-1));
}
if(bild.getRGB(pixel.x, pixel.y+1) == ausgangs_farbe )
{
Points.add(new Point(pixel.x, pixel.y+1));
}
//Point[] punkte={};
return (Point[]) Points.toArray();
}
return null;
}
doch leider liefert mir
Code:
return (Point[]) Points.toArray();
Kann mir jemand dabei helfen?