Android BitmapShader changes color

I need a little help on what I want to achieve. I use BitmapShaderin my application for painting on canvas. I am setting a custom png file as a shader for my paint variable, and I want to change the color of the shader.

Here is an example of the code I'm using:

    Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.particle_point);
    BitmapShader shader = new BitmapShader(bitmap, Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);
    mPaint.setShader(shader);
    ColorFilter filter = new LightingColorFilter(0xFFFFFFFF , 0x000000FF );
    mPaint.setColorFilter(filter);

I find that I can change its color using:

ColorFilter filter = new LightingColorFilter(0xFFFFFFFF , 0x000000FF );

but I need to change the color using a special pick-up colors which returns a color code similar to this: -234423123.

So, is there a way I can use this color code and set it as the color for my paint variable.

Thanks in advance!

+3
source share
3 answers

, hex, : FFFFFFFFF206FCAD. , 8 Fs:

int color = -234423123;//0xFFFFFFFFF206FCAD
int myColor = 0x00000000FFFFFFFF & color;

myColor .

+3

. , myColor , , , myColor LightingColorFilter :

ColorFilter filter = new LightingColorFilter(myColor , myColor );

.

+1

:

"#"+Integer.toHexString(n));

int, !

ColorFilter filter = new LightingColorFilter(0xFFFFFFFF , 0x000000FF );

, , int colorpicker... ( 0x , )...

, !

0

All Articles