package grafik.bildbearbeitung; import java.awt.BorderLayout; import java.awt.Color; import java.awt.image.BufferedImage; import java.awt.image.ColorModel; import java.awt.image.WritableRaster; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.SwingUtilities; import javax.swing.border.LineBorder; public class ManipulateImage { private static final long serialVersionUID = 1L; JPanel panel; JLabel label; ImageIcon icon; BufferedImage image; public ManipulateImage() { //processImage(); makeImage(); icon = new ImageIcon(image); label = new JLabel(icon); label.setBorder(new LineBorder(Color.WHITE)); panel = new JPanel(); panel.setLayout(new BorderLayout()); panel.setBackground(Color.DARK_GRAY); panel.add(label, BorderLayout.CENTER); JFrame frame = new JFrame("Pixel manipulieren"); frame.getContentPane().add(panel); frame.pack(); frame.setLocationRelativeTo(null); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } private void processImage(){ File file = new File("test.jpg"); try { this.image = ImageIO.read(file); } catch (IOException ex) { ex.printStackTrace(); } ColorModel model = image.getColorModel(); WritableRaster raster = image.getRaster(); for(int i=0; i50 && i<150 && j>50 && j<150){ raster.setDataElements(i, j, data2); } } } } public static void main(String args[]) { SwingUtilities.invokeLater(() -> new ManipulateImage()); } }