Okay I need to get the program to scan the screen for a certain rgb value then change it to bright pink. I made the program and so far it scans the screen for a certain color. I do not know how to get it to change the pixel color. I think I need to upload a picture instead of having it scan the screen. But if I do that I still wouldn't know how to change the pixels.
Here's my code so far.
import java.awt.AWTException;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.awt.image.DataBuffer;
import java.awt.image.DataBufferInt;
import java.awt.image.WritableRaster;
public class FindRgbOnScreen extends Thread{
public Rectangle captureSize;
public FindRgbOnScreen() {
captureSize = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
}
public void run() {
try {
Robot robot = new Robot();
while(true){
BufferedImage img = robot.createScreenCapture(captureSize);
WritableRaster r = img.getRaster();
DataBuffer db = r.getDataBuffer();
DataBufferInt dbi = (DataBufferInt)db;
int[] data = dbi.getData();
for (int x_scale = 0; x_scale < captureSize.width; x_scale += 1) { //this scans the screen
for(int y_scale = 0; y_scale < captureSize.height; y_scale += 1) {
int rgb = data[x_scale + captureSize.width * y_scale];
if (rgb == -5381164){
//change pixel to pink
}
else{
//change pixel to grey
}
}
}
}
}
catch(AWTException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
new FindRgbOnScreen().start();
}
}