Hey i write a programm that takes screenshots of the whole screen and searches for special RGB but the .getRed .getBlue ... Methodes are very slow so i heard if i convert the buffered to a byte arry and then search there for the special color is much faster so my question is how can i check this byte for the special RGB and how can i convert the BufferedImage to the Byte ??
Here my Code:
But when i try this with a loaded 1 Pixel .png i get ervery time i run the methode different outputs.
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.awt.Robot;
import java.awt.event.InputEvent;
import java.awt.event.MouseEvent;
import java.awt.event.KeyEvent;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import javax.imageio.ImageIO;
import java.io.File;
public class Algorythmus
{
static Robot Robo;
static byte[] data;
public static void test()
{
try
{
Robo = new Robot();
BufferedImage originalImage = Robo.createScreenCapture(null);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(originalImage,"png", baos );
data = baos.toByteArray();
System.out.println(data);
}
catch(Exception e)
{
}
}
}

