Java tutorial
//package com.java2s; /***************************************************************************** ** ANGRYBIRDS AI AGENT FRAMEWORK ** Copyright (c) 2013,XiaoYu (Gary) Ge, Stephen Gould,Jochen Renz ** Sahan Abeyasinghe, Jim Keys, Kar-Wai Lim, Zain Mubashir, Andrew Wang, Peng Zhang ** All rights reserved. **This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. **To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/ *or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA. *****************************************************************************/ import java.awt.image.*; import java.util.*; public class Main { public static int[] columnChecksums(BufferedImage img) { int[] sums = new int[img.getWidth()]; Arrays.fill(sums, 0); for (int y = 0; y < img.getHeight(); y++) { for (int x = 0; x < img.getWidth(); x++) { final int colour = img.getRGB(x, y); sums[x] += (int) ((colour & 0x00ff0000) >> 16); sums[x] += (int) ((colour & 0x0000ff00) >> 8); sums[x] += (int) (colour & 0x000000ff); } } for (int x = 0; x < img.getWidth(); x++) { sums[x] %= 256; } return sums; } }