Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6602233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:51:08+00:00 2026-05-25T18:51:08+00:00

The following function changes contrast and brightness in the picture successfully. Bitmap bmp; ImageView

  • 0

The following function changes contrast and brightness in the picture successfully.

Bitmap bmp;
ImageView alteredImageView;
...
public void drawAlteredImage(float contr,float bright) {
    Bitmap alteredBitmap = Bitmap.createBitmap(bmp.getWidth(), bmp.getHeight(), bmp.getConfig());
    Canvas canvas = new Canvas(alteredBitmap);
    Paint paint = new Paint();
    ColorMatrix cm = new ColorMatrix();

    cm.set(new float[] { 
            contr, 0, 0, 0, bright, 
            0, contr, 0, 0, bright, 
            0, 0, contr, 0, bright, 
            0, 0, 0, 1, 0 });

    paint.setColorFilter(new ColorMatrixColorFilter(cm));
    Matrix matrix = new Matrix();
    canvas.drawBitmap(bmp, matrix, paint);
    alteredImageView.setImageBitmap(alteredBitmap);
}

But when I added setSaturation method to ColorMatrix the contrast and brightness altering ceased to work. The code:

public void drawAlteredImage(float contr,float bright,float satur) {
    Bitmap alteredBitmap = Bitmap.createBitmap(bmp.getWidth(), bmp.getHeight(), bmp.getConfig());
    Canvas canvas = new Canvas(alteredBitmap);
    Paint paint = new Paint();
    ColorMatrix cm = new ColorMatrix();

    cm.set(new float[] { 
            contr, 0, 0, 0, bright, 
            0, contr, 0, 0, bright, 
            0, 0, contr, 0, bright, 
            0, 0, 0, 1, 0 });
    cm.setSaturation(satur);
    paint.setColorFilter(new ColorMatrixColorFilter(cm));
    Matrix matrix = new Matrix();
    canvas.drawBitmap(bmp, matrix, paint);
    alteredImageView.setImageBitmap(alteredBitmap);
}

Only the saturation effect is applying in this case. Why does this problem happening? How can I fix it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T18:51:09+00:00Added an answer on May 25, 2026 at 6:51 pm

    The setSaturation(...) method replaces all the values in the matrix. You can either create a matrix that combines both operations, or do the operations with two separate drawBitmap(...) calls.

    Try:

    cm.setSaturation(satur);
    final float m[] = cm.getArray();
    final float c = contr;
    cm.set(new float[] { 
            m[ 0] * c, m[ 1] * c, m[ 2] * c, m[ 3] * c, m[ 4] * c + bright, 
            m[ 5] * c, m[ 6] * c, m[ 7] * c, m[ 8] * c, m[ 9] * c + bright, 
            m[10] * c, m[11] * c, m[12] * c, m[13] * c, m[14] * c + bright, 
            m[15]    , m[16]    , m[17]    , m[18]    , m[19] }); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the following function that changes a calendar selection at a set time
I have the following function: public class InfrStadium { private InfrStadium(int iTeamId) { _teamId
I have the following function that changes row color based on a particular selection.
I have the following function call: public static MvcHtmlString NavLinks( this HtmlHelper helper, IList<MenuItem>
i have the following function function change() { var input = document.getElementById('pas'); var input2
i have to use the following function, to change the input's type <input class=input
I have the following jquery code: jQuery(function(){ jQuery(select#rooms).change(function(){ var options = ''; jQuery.getJSON(/admin/selection.php,{id: jQuery(this).val(),
The following function System.Threading.Thread.Sleep(); delay the thread in millisecond, and take the integer value
/** The following function checks the red black tree black height * @param n
The following function generates a 'stack level too deep (SystemStackError)' for n = 5,000

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.