Advertisement
frisco

Untitled

Sep 15th, 2014
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. private void magic() throws IOException {
  2. File file = new File("images/mango.png");
  3. BufferedImage img = ImageIO.read(file);
  4. int pixel;
  5. Color col;
  6. String text = "";
  7. // float[] hsb = new float[3];
  8. byte[] array = new byte[img.getWidth() * 3];
  9. FileOutputStream fos = new FileOutputStream("filename.7z");
  10. for (int y = 0; y < img.getHeight(); y++) {
  11. for (int i = 0; i < img.getWidth(); i++) {
  12. pixel = img.getRGB(i, y);
  13. col = new Color(pixel);
  14. array[i*3] = (byte) (col.getRed());
  15. array[i*3 + 1] = (byte) (col.getGreen());
  16. array[i*3 + 2] = (byte) (col.getBlue());
  17. }
  18. fos.write(array);
  19. // System.out.println(text);
  20. // text = "";
  21. }
  22. fos.close();
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement