Last active
March 10, 2019 12:16
-
-
Save ezhov-da/1f749ffbdac22128ee1207b0c5524fd6 to your computer and use it in GitHub Desktop.
java read image file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BufferedImage img = null; | |
try { | |
img = ImageIO. read(new File("Image. png") ) ; | |
int height = img. getHeight() ; | |
int width = img. getWidth() ; | |
int[] [] data = new int[height] [width] ; | |
for (int i = 0; i < height; i++) { | |
for (int j = 0; j < width; j ++) { | |
int rgb = img. getRGB(i, j ) ; // negative integers | |
data[i] [j ] = rgb; | |
} | |
} | |
} catch (IOException e) { | |
// handle exception | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment