下面列出了怎么用android.media.effect.EffectContext的API类实例代码及写法,或者点击链接到github查看源代码。
@Override
public void onDrawFrame(GL10 gl) {
if (!mInitialized) {
//Only need to do this once
mEffectContext = EffectContext.createWithCurrentGlContext();
mTexRenderer.init();
loadTextures();
mInitialized = true;
}
if (mCurrentEffect != R.id.none) {
//if an effect is chosen initialize it and apply it to the texture
initEffect();
applyEffect();
}
renderResult();
}
@Override
public void onDrawFrame(GL10 gl) {
if (!mInitialized) {
//Only need to do this once
mEffectContext = EffectContext.createWithCurrentGlContext();
mTexRenderer.init();
loadTextures();
mInitialized = true;
}
if (mCurrentEffect != R.id.none) {
//if an effect is chosen initialize it and apply it to the texture
initEffect();
applyEffect();
}
renderResult();
}
@Override
public void onDrawFrame(GL10 gl) {
if (!mInitialized) {
// Only need to do this once
mEffectContext = EffectContext.createWithCurrentGlContext();
mTexRenderer.init();
loadTextures();
mInitialized = true;
}
if (mCurrentEffect != R.id.none) {
// if an effect is chosen initialize it and apply it to the texture
initEffect();
applyEffect();
}
renderResult();
if (saveFrame) {
saveBitmap(takeScreenshot(gl));
}
}
@Override
public void onDrawFrame(GL10 gl) {
if (!mInitialized) {
//Only need to do this once
mEffectContext = EffectContext.createWithCurrentGlContext();
mTexRenderer.init();
loadTextures();
mInitialized = true;
}
if (mCurrentEffect != R.id.none) {
//if an effect is chosen initialize it and apply it to the texture
initEffect();
applyEffect();
}
renderResult();
}
@Override
public void onDrawFrame(GL10 gl) {
if (!mInitialized) {
//Only need to do this once
mEffectContext = EffectContext.createWithCurrentGlContext();
mTexRenderer.init();
loadTextures();
mInitialized = true;
}
if (mCurrentEffect != NONE || mCustomEffect != null) {
//if an effect is chosen initialize it and apply it to the texture
initEffect();
applyEffect();
}
renderResult();
if (isSaveImage) {
final Bitmap mFilterBitmap = BitmapUtil.createBitmapFromGLSurface(this, gl);
Log.e(TAG, "onDrawFrame: " + mFilterBitmap);
isSaveImage = false;
if (mOnSaveBitmap != null) {
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
mOnSaveBitmap.onBitmapReady(mFilterBitmap);
}
});
}
}
}
/**
* コンストラクタ
* GLコンテキスト内で生成すること
* @param effect_context
*/
public MediaEffect(final EffectContext effect_context, final String effectName) {
mEffectContext = effect_context;
final EffectFactory factory = effect_context.getFactory();
if (TextUtils.isEmpty(effectName)) {
mEffect = null;
} else {
mEffect = factory.createEffect(effectName);
}
}
/**
* コンストラクタ
* GLコンテキスト内で生成すること
*
* @param effect_context
* @param flip_vertical
* @param flip_horizontal
*/
public MediaEffectFlip(final EffectContext effect_context,
final boolean flip_vertical, final boolean flip_horizontal) {
super(effect_context, EffectFactory.EFFECT_FLIP);
setParameter(flip_vertical, flip_horizontal);
}
/**
* コンストラクタ
* GLコンテキスト内で生成すること
*
* @param effect_context
* @param x The origin's x-value. between 0 and width of the image.
* @param y The origin's y-value. between 0 and height of the image.
* @param width The width of the cropped image.
* between 1 and the width of the image minus xorigin.
* @param height The height of the cropped image.
* between 1 and the height of the image minus yorigin.
*/
public MediaEffectCrop(final EffectContext effect_context,
final int x, final int y, final int width, final int height) {
super(effect_context, EffectFactory.EFFECT_CROP);
setParameter(x, y, width, height);
}
/**
* コンストラクタ
* GLコンテキスト内で生成すること
*
* @param effect_context
* @param first_color The first color tone.
* representing an ARGB color with 8 bits per channel.
* May be created using Color class.
* @param second_color The second color tone. Integer,
* representing an ARGB color with 8 bits per channel.
* May be created using Color class.
*/
public MediaEffectDuoTone(final EffectContext effect_context,
final int first_color, final int second_color) {
super(effect_context, EffectFactory.EFFECT_DUOTONE);
setParameter(first_color, second_color);
}
/**
* コンストラクタ
* GLコンテキスト内で生成すること
*
* @param effect_context
* @param bitmap The overlay bitmap.
*/
public MediaEffectBitmapOverlay(final EffectContext effect_context,
final Bitmap bitmap) {
super(effect_context, EffectFactory.EFFECT_BITMAPOVERLAY);
setParameter(bitmap);
}
/**
* コンストラクタ
* GLコンテキスト内で生成すること
*
* @param effect_context
*/
public MediaEffectDocumentary(final EffectContext effect_context) {
super(effect_context, EffectFactory.EFFECT_DOCUMENTARY);
}
/**
* コンストラクタ
* GLコンテキスト内で生成すること
*
* @param effect_context
*/
public MediaEffectCrossProcess(final EffectContext effect_context) {
super(effect_context, EffectFactory.EFFECT_CROSSPROCESS);
}
/**
* コンストラクタ
* GLコンテキスト内で生成すること
*
* @param effect_context
* @param scale The scale of color saturation.
* between -1 and 1. 0 means no change,
* while -1 indicates full desaturation, i.e. grayscale.
*/
public MediaEffectSaturate(final EffectContext effect_context, final float scale) {
super(effect_context, EffectFactory.EFFECT_SATURATE);
setParameter(scale);
}
/**
* コンストラクタ
* GLコンテキスト内で生成すること
*
* @param effect_context
* @param scale The scale of vignetting. between 0 and 1. 0 means no change.
*/
public MediaEffectVignette(final EffectContext effect_context, final float scale) {
super(effect_context, EffectFactory.EFFECT_SHARPEN);
setParameter(scale);
}
/**
* コンストラクタ
* GLコンテキスト内で生成すること
*
* @param effect_context
* @param angle The angle of rotation. between -45 and +45.
*/
public MediaEffectStraighten(final EffectContext effect_context, final float angle) {
super(effect_context, EffectFactory.EFFECT_STRAIGHTEN);
setParameter(angle);
}
/**
* コンストラクタ
* GLコンテキスト内で生成すること
*
* @param effect_context
*/
public MediaEffectFlipVertical(final EffectContext effect_context) {
super(effect_context, true, false);
}
/**
* コンストラクタ
* GLコンテキスト内で生成すること
*
* @param effect_context
* @param contrast The contrast multiplier. Float. 1.0 means no change; larger values will increase contrast.
*/
public MediaEffectContrast(final EffectContext effect_context, final float contrast) {
super(effect_context, EffectFactory.EFFECT_CONTRAST);
setParameter(contrast);
}
/**
* コンストラクタ
* GLコンテキスト内で生成すること
*
* @param effect_context
* @param tint The color of the tint.
* representing an ARGB color with 8 bits per channel.
* May be created using Color class.
*/
public MediaEffectTint(final EffectContext effect_context, final int tint) {
super(effect_context, EffectFactory.EFFECT_TINT);
setParameter(tint);
}
/**
* コンストラクタ
* GLコンテキスト内で生成すること
*
* @param effect_context
* @param scale The value of color temperature. between 0 and 1,
* with 0 indicating cool, and 1 indicating warm.
* A value of of 0.5 indicates no change.
*/
public MediaEffectTemperature(final EffectContext effect_context, final float scale) {
super(effect_context, EffectFactory.EFFECT_TEMPERATURE);
setParameter(scale);
}
/**
* コンストラクタ
* GLコンテキスト内で生成すること
*
* @param effect_context
* @param strength The strength of the grain effect. between 0 and 1. Zero means no change.
*/
public MediaEffectGrain(final EffectContext effect_context, final float strength) {
super(effect_context, EffectFactory.EFFECT_GRAIN);
setParameter(strength);
}
/**
* コンストラクタ
* GLコンテキスト内で生成すること
*
* @param effect_context
* @param scale The scale of the distortion. between 0 and 1. Zero means no distortion.
*/
public MediaEffectFishEye(final EffectContext effect_context, final float scale) {
super(effect_context, EffectFactory.EFFECT_FISHEYE);
setParameter(scale);
}
/**
* コンストラクタ
* GLコンテキスト内で生成すること
*
* @param effect_context
*/
public MediaEffectFlipHorizontal(final EffectContext effect_context) {
super(effect_context, false, true);
}
/**
* コンストラクタ
* GLコンテキスト内で生成すること
*
* @param effect_context
*/
public MediaEffectGrayScale(final EffectContext effect_context) {
super(effect_context, EffectFactory.EFFECT_GRAYSCALE);
}
/**
* コンストラクタ
* GLコンテキスト内で生成すること
*
* @param effect_context
*/
public MediaEffectLomoish(final EffectContext effect_context) {
super(effect_context, EffectFactory.EFFECT_LOMOISH);
}
/**
* コンストラクタ
* GLコンテキスト内で生成すること
*
* @param effect_context
* @param centers Multiple center points (x, y) of the red eye regions.
* An array of floats, where (f[2*i], f[2*i+1])
* specifies the center of the i'th eye.
* Coordinate values are expected to be normalized between 0 and 1.
*/
public MediaEffectRedEye(final EffectContext effect_context, final float[] centers) {
super(effect_context, EffectFactory.EFFECT_REDEYE);
setParameter(centers);
}
/**
* コンストラクタ
* GLコンテキスト内で生成すること
*
* @param effect_context
*/
public MediaEffectBlackWhite(final EffectContext effect_context) {
this(effect_context, 0.0f, 1.0f);
}
/**
* コンストラクタ
* GLコンテキスト内で生成すること
*
* @param effect_context
* @param black The value of the minimal pixel. 0-1
* @param white The value of the maximal pixel. 0-1
*/
public MediaEffectBlackWhite(final EffectContext effect_context, final float black, final float white) {
super(effect_context, EffectFactory.EFFECT_BLACKWHITE);
setParameter(black, white);
}
/**
* コンストラクタ
* GLコンテキスト内で生成すること
*
* @param effect_context
* @param angle The angle of rotation in degrees.
* This will be rounded to the nearest multiple of 90.
*/
public MediaEffectRotate(final EffectContext effect_context, final int angle) {
super(effect_context, EffectFactory.EFFECT_ROTATE);
setParameter(angle);
}
/**
* コンストラクタ
* GLコンテキスト内で生成すること
*
* @param effect_context
* @param strength between 0 and 1. between 0 and 1. Zero means no change.
*/
public MediaEffectFillLight(final EffectContext effect_context, final float strength) {
super(effect_context, EffectFactory.EFFECT_FILLLIGHT);
setParameter(strength);
}
/**
* コンストラクタ
* GLコンテキスト内で生成すること
*
* @param effect_context
*/
public MediaEffectSepia(final EffectContext effect_context) {
super(effect_context, EffectFactory.EFFECT_SEPIA);
}