Java tutorial
//package com.java2s; /* * Copyright (C) 2015 Henrique Rocha * Copyright (C) 2014 Fonpit AG * * License * ------- * Creative Commons Attribution 2.5 License: * http://creativecommons.org/licenses/by/2.5/ * * Thanks * ------ * Simon Oualid - For creating java-colorthief * available at https://github.com/soualid/java-colorthief * * Lokesh Dhakar - for the original Color Thief javascript version * available at http://lokeshdhakar.com/projects/color-thief/ * */ import android.graphics.Bitmap; import java.util.ArrayList; import java.util.List; public class Main { private static List<int[]> getPixels(Bitmap image) { int width = image.getWidth(); int height = image.getHeight(); List<int[]> res = new ArrayList<>(); List<Integer> t = new ArrayList<>(); for (int row = 0; row < height; row++) { for (int col = 0; col < width; col++) { if (!image.isRecycled()) t.add(image.getPixel(col, row)); } } for (int i = 0; i < t.size(); i += 10) { int[] rr = new int[3]; int argb = t.get(i); rr[0] = (argb >> 16) & 0xFF; rr[1] = (argb >> 8) & 0xFF; rr[2] = (argb) & 0xFF; if (!(rr[0] > 250 && rr[1] > 250 && rr[2] > 250)) { res.add(rr); } } return res; } }