Tuesday, 15 September 2015

java - Compose two Shaders (Color Picker) -


In my application, I am using my custom color picker widget. In the onDraw method I mix two shaders using the following code:

  composeshader mShader = new composeshader (mValShader, mSatShader, PorterDuff .Mode. Multiplied);   

However, the result I get is not what I would like to receive. Below you can see what looks like the shader mentioned above:
Image Details Here Enter +  Enter image details here =  Enter image details here

As you can see it does not work completely ...
Result of Results ( More or less) should look:
enter image details here

edit (Possible solutions):

To work, I have to use the following code:

  if (Build.VERSION.SDK_INT> = Build.VERSION_CODES .HONEYCOMB) {setLayerType (see PLAYERLAYER_TYPE_SOFTWARE, tap); }  
  • Although I really can not understand how this line of code affects my application. I mean the IU understands that it sets hardware acceleration , is there any result of doing this for my application? Should I turn it on after the Shader drawing? Can anyone be explained?

    It is intended for Android 4+, in which hardware acceleration (AA) is enabled by default. Before 4.0, you may optionally be enabled in your AndroidManifest.xml.

    Hardware acceleration completes all drawing tasks, which are done on the canvas of the view using GPU, which is good because it should be fast but when the HA is enabled, some drawing method is not supported Are there. You can use only a subset of drawing methods to use acceleration.

    There is a problem with your case, because the documentation says (see), that

      composeshader can have only different types of shaders (for example a bitmap shader and one Rainiergradian, but not two examples of bitmapshare)   



    Disabling hardware acceleration.

    You can find your Android manifest.XML

      & lt; Apps Android: Hardware Expected = "False" ... & gt;   

    or per activity

      & lt; Application Android: Hardware Expected = "True" & gt; & Lt; Activity ... /> & Lt; Activity Android: Hardware Expected = "False" /> & Lt; / Application & gt;   

    or per view as you are now

    Please note that there is a bug in Android which is fixed in 4.1 (view) And as a result your setLayerType (see PLAYER_LAYER_TE_SOFTWARE, null) calls will be ignored in some Android versions (for example 4.0.2).

    If you disable a view for a scene, then you do not have to enable it back, because it only affects the drawing of your view.

No comments:

Post a Comment