Пример #1
0
 // returns a value specifying some kind of average brightness in the image.
 protected int getAverageBrightness(BufferedImage img) {
   Raster r = img.getData();
   int total = 0;
   for (int y = 0; y < r.getHeight(); y++) {
     for (int x = 0; x < r.getWidth(); x++) {
       total += r.getSample(r.getMinX() + x, r.getMinY() + y, 0);
     }
   }
   return (int) (total / ((r.getWidth() / factorD) * (r.getHeight() / factorD)));
 }
Пример #2
0
 public Raster getData() {
   return _i.getData();
 }
Пример #3
0
 public static BufferedImage getImageFromArray(int[] pixels, int width, int height) {
   BufferedImage imageBI = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
   WritableRaster raster = (WritableRaster) imageBI.getData();
   raster.setPixels(0, 0, width, height, pixels);
   return imageBI;
 }