Note that there are some explanatory texts on larger screens.

plurals
  1. POI want to set Brightness of an image on SeekBar OnProgres change event in Android?
    primarykey
    data
    text
    <p>I want to set Brightness of an image on SeekBar OnProgres change event? I am showing an image in imageview and below that there is an SeekBar to change the Brightness of an image.</p> <p><strong>1)</strong> I am using following function to set brightness</p> <pre><code>private static void setBrightness(ColorMatrix cm, float contrast) { float scale = contrast + 1.f; float translate = (-.5f * scale + .5f) * 255.f; cm.set(new float[] { 1, 0, 0, 0, translate, 0, 1, 0, 0, translate, 0, 0, 1, 0, translate, 0, 0, 0, 1, 0 }); } </code></pre> <p><strong>2)</strong> I was able to set brightness of an image using following code</p> <pre><code>@Override protected void onDraw(Canvas canvas) { Paint paint = mPaint; float x = 20; float y = 20; float[]pos={5,5}; canvas.drawColor(Color.WHITE); paint.setColorFilter(null); canvas.drawText("Original Image", 5,20, paint); canvas.drawBitmap(mBitmap, x, y, paint); ColorMatrix cm = new ColorMatrix(); mAngle += 2; if (mAngle &gt; 180) { mAngle = 0; } //convert our animated angle [-180...180] to a contrast value of [-1..1] float contrast = mAngle / 180.f; canvas.drawText("Brightness", 5,y + 60, paint); setBrightness(cm, contrast);//Brightness paint.setColorFilter(new ColorMatrixColorFilter(cm)); canvas.drawBitmap(mBitmap, x ,y + mBitmap.getWidth() + 10, paint); invalidate(); } </code></pre> <p><strong>3)</strong> Now I want to change the brightness of an image on SeekBar OnProgress change event, but for that I require to have an relationship between ColorMatrix and Bitmap.</p> <p>Because I don't want to draw an image I want to modify an existing image. i.e. I am showing an image in imageview and below that there is an SeekBar to change the Brightness of an image.</p> <p>Please help me to change the Brightness of an image onSeekBar Progressed change event.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload