Finding the dominant color of an image in an Android @drawable

后端 未结 8 802
情深已故
情深已故 2020-11-28 20:42

You can understand why I\'m trying to find the dominant color in an image if you use Windows 7. When your mouse over a program in the taskbar, the background of that partic

8条回答
  •  春和景丽
    2020-11-28 20:55

    There is also an another solution, it's more approximative but if you don't want to have long delay for searching color, it can do the job.

    public static int getDominantColor(Bitmap bitmap) {
        Bitmap newBitmap = Bitmap.createScaledBitmap(bitmap, 1, 1, true);
        final int color = newBitmap.getPixel(0, 0);
        newBitmap.recycle();
        return color;
    }
    

提交回复
热议问题