Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void magic() throws IOException {
- File file = new File("images/mango.png");
- BufferedImage img = ImageIO.read(file);
- int pixel;
- Color col;
- String text = "";
- // float[] hsb = new float[3];
- byte[] array = new byte[img.getWidth() * 3];
- FileOutputStream fos = new FileOutputStream("filename.7z");
- for (int y = 0; y < img.getHeight(); y++) {
- for (int i = 0; i < img.getWidth(); i++) {
- pixel = img.getRGB(i, y);
- col = new Color(pixel);
- array[i*3] = (byte) (col.getRed());
- array[i*3 + 1] = (byte) (col.getGreen());
- array[i*3 + 2] = (byte) (col.getBlue());
- }
- fos.write(array);
- // System.out.println(text);
- // text = "";
- }
- fos.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement