import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.awt.image.DataBufferByte;
import java.io.File;
import java.io.IOException;
public class Main{
public static void main(String[] args) {
File f =new File("C:\\Users\\lenovo\\Desktop\\3mleurHJjZA.jpg");
try {
BufferedImage input = ImageIO.read(f);
int width = input.getWidth();
int height = input.getHeight();
System.out.println(width+"\t "+height);
byte []byfim=((DataBufferByte)input.getRaster().getDataBuffer()).getData();
System.out.println( byfim.length);
byte g=10;
for (int i=0;i<byfim.length;i++){
byfim[i]= (byte) (byfim[i]+g);
}
int ss=0;
for (int i=0;i<height;i++){
for (int b=0;b<width;b++){
input.setRGB(b,i, ((int)byfim[(ss*3)]+(int)byfim[(ss*3)+1] +(int)byfim[(ss*3)+2]));
ss++;
}}
NewFrame frame=new NewFrame();
frame.Newframe1(input);
} catch (IOException e) {
e.printStackTrace();
}
}
}
import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;
public class NewFrame {
public void Newframe1(BufferedImage bufferedImage){
JFrame frame=new JFrame("HELLO");
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.setResizable(false);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
Canvas canvas=new Canvas();
canvas.setSize(new Dimension(807,1080));
Graphics g=canvas.getGraphics();
g.drawImage(bufferedImage,0,0,null);
frame.getContentPane().add(canvas);
frame.pack();
}
}
Exception in thread "main" java.lang.NullPointerException
at NewFrame.Newframe1(NewFrame.java:16)
at Main.main(Main.java:33)
Что ему не нравится, я уже всю голову сломал