1<HTML> 2<BODY> 3<p>Provides classes that allow you to apply a variety of visual effects to images and 4videos. For example, you can easily fix red-eye, convert an image to grayscale, 5adjust brightness, adjust saturation, rotate an image, apply a fisheye effect, and much more. The 6system performs all effects processing on the GPU to obtain maximum performance.</p> 7 8<p>For maximum performance, effects are applied directly to OpenGL textures, so your application 9must have a valid OpenGL context before it can use the effects APIs. The textures to which you apply 10effects may be from bitmaps, videos or even the camera. However, there are certain restrictions that 11textures must meet:</p> 12<ol> 13<li>They must be bound to a {@link android.opengl.GLES20#GL_TEXTURE_2D} texture image</li> 14<li>They must contain at least one mipmap level</li> 15</ol> 16 17<p>An {@link android.media.effect.Effect} object defines a single media effect that you can apply to 18an image frame. The basic workflow to create an {@link android.media.effect.Effect} is:</p> 19 20<ol> 21<li>Call {@link android.media.effect.EffectContext#createWithCurrentGlContext 22EffectContext.createWithCurrentGlContext()} from your OpenGL ES 2.0 context.</li> 23<li>Use the returned {@link android.media.effect.EffectContext} to call {@link 24android.media.effect.EffectContext#getFactory EffectContext.getFactory()}, which returns an instance 25of {@link android.media.effect.EffectFactory}.</li> 26<li>Call {@link android.media.effect.EffectFactory#createEffect createEffect()}, passing it an 27effect name from @link android.media.effect.EffectFactory}, such as {@link 28android.media.effect.EffectFactory#EFFECT_FISHEYE} or {@link 29android.media.effect.EffectFactory#EFFECT_VIGNETTE}.</li> 30</ol> 31 32<p>You can adjust an effect’s parameters by calling {@link android.media.effect.Effect#setParameter 33setParameter()} and passing a parameter name and parameter value. Each type of effect accepts 34different parameters, which are documented with the effect name. For example, {@link 35android.media.effect.EffectFactory#EFFECT_FISHEYE} has one parameter for the {@code scale} of the 36distortion.</p> 37 38<p>To apply an effect on a texture, call {@link android.media.effect.Effect#apply apply()} on the 39{@link 40android.media.effect.Effect} and pass in the input texture, its width and height, and the output 41texture. The input texture must be bound to a {@link android.opengl.GLES20#GL_TEXTURE_2D} texture 42image (usually done by calling the {@link android.opengl.GLES20#glTexImage2D glTexImage2D()} 43function). You may provide multiple mipmap levels. If the output texture has not been bound to a 44texture image, it will be automatically bound by the effect as a {@link 45android.opengl.GLES20#GL_TEXTURE_2D} and with one mipmap level (0), which will have the same 46size as the input.</p> 47 48<p class="note"><strong>Note:</strong> All effects listed in {@link 49android.media.effect.EffectFactory} are guaranteed to be supported. However, some additional effects 50available from external libraries are not supported by all devices, so you must first check if the 51desired effect from the external library is supported by calling {@link 52android.media.effect.EffectFactory#isEffectSupported isEffectSupported()}.</p> 53</BODY> 54</HTML> 55