Here you go.   BTW, I have to give credit to where it's due.  This is
a port of ColorMatrix by Grant Skinner.

                protected float cleanValue(float p_val, float p_limit) {
                        return Math.min(p_limit,Math.max(-p_limit,p_val));
                }


On May 16, 12:16 am, nayana urs <[email protected]> wrote:
> hi thanks for your solution can u please tell me what implementation should
> be there in cleanvalue(float,float)method
> with regards
>    Nayana
>
>
>
> On Sat, May 15, 2010 at 2:39 AM, pkc <[email protected]> wrote:
> > Just wanted to share my solution.  I got this idea from a flash
> > script.
>
> > I have a slider that adjust the "value", where is ranges from 0 to
> > 360.
>
> >                public void adjustHue(ColorMatrix cm, float value) {
> >                        value = cleanValue(value,180f)/180f*(float)Math.PI;
> >                        if (value == 0 ) { return; }
> >                        float cosVal = (float)Math.cos(value);
> >                        float sinVal = (float)Math.sin(value);
> >                        float lumR = 0.213f;
> >                        float lumG = 0.715f;
> >                        float lumB = 0.072f;
> >                        float[] mat = new float[] {
>
> >  lumR+cosVal*(1-lumR)+sinVal*(-lumR),lumG+cosVal*(-lumG)+sinVal*(-
> > lumG),lumB+cosVal*(-lumB)+sinVal*(1-lumB),0,0,
>
> >  lumR+cosVal*(-lumR)+sinVal*(0.143f),lumG+cosVal*(1-lumG)
> > +sinVal*(0.140f),lumB+cosVal*(-lumB)+sinVal*(-0.283f),0,0,
>
> >  lumR+cosVal*(-lumR)+sinVal*(-(1-lumR)),lumG+cosVal*(-lumG)
> > +sinVal*(lumG),lumB+cosVal*(1-lumB)+sinVal*(lumB),0,0,
> >                                0f,0f,0f,1f,0f,
> >                                0f,0f,0f,0f,1f
> >                        };
> >                        cm.postConcat(new ColorMatrix(mat));
> >                }
>
> > On May 10, 1:52 am, rsung <[email protected]> wrote:
> > > I want to create a slider that changes thehueon an image.  I tried
> > > using ColorMatrix but it's not working as expected.
> > > Any help would much appreciated.  Thanks.
>
> > > --
> > > You received this message because you are subscribed to the Google
> > > Groups "Android Developers" group.
> > > To post to this group, send email to [email protected]
> > > To unsubscribe from this group, send email to
> > > [email protected]<android-developers%[email protected]>
> > > For more options, visit this group athttp://
> > groups.google.com/group/android-developers?hl=en
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to [email protected]
> > To unsubscribe from this group, send email to
> > [email protected]<android-developers%[email protected]>
> > For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group 
> athttp://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to