Back to project page android-imgpro-lib.
The source code is released under:
MIT License
If you think the Android project android-imgpro-lib listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package net.akhyar.android.imgpro.actions; /*from w w w .j a v a2 s . c om*/ import net.akhyar.android.imgpro.Action; import android.graphics.Color; public class Contrast extends Action { private int value; private double contrast; public Contrast(int value) { this.value = value; this.contrast = Math.pow((100 + value) / 100, 2); } @Override protected void adjustPixels(int[] pixels) { int A, R, G, B; for (int i = 0; i < pixels.length; i++) { A = Color.alpha(pixels[i]); R = Color.red(pixels[i]); R = (int) (((((R / 255.0) - 0.5) * contrast) + 0.5) * 255.0); G = Color.green(pixels[i]); G = (int) (((((G / 255.0) - 0.5) * contrast) + 0.5) * 255.0); B = Color.blue(pixels[i]); B = (int) (((((B / 255.0) - 0.5) * contrast) + 0.5) * 255.0); R = clamp(R); G = clamp(G); B = clamp(B); pixels[i] = Color.argb(A, R, G, B); } } public float getAmount() { return value; } public void setAmount(int amount) { this.value = amount; } }