android - Apply multiple effect on bitmap without saving it -
my requirement load multiple effect on bitmap. following apply-effects-on-image-using-effects it. got success applying effect requirements give brightness effect separately. means user can able give brightness effect after applying other effect without saving file.
i know after saving file , render file again makes possible. need without saving image file.
right now, if apply brightness on applied effect applied effect gone , brightness shows effect. because of below code:
meffect = effectfactory.createeffect(effectfactory.effect_brightness);
here, meffect initialize give new effect on texture. without not able load effect.
so, question is, how load multiple effect on same texture without saving it.
create 3 textures, instead of 2:
private int[] mtextures = new int[3]; private void loadtextures() { // generate textures gles20.glgentextures(3, mtextures, 0); ...
after that, can apply sequentially 2 effects 1 after another, that:
private void applyeffect() { if (mneedsecondeffect) { meffect.apply(mtextures[0], mimagewidth, mimageheight, mtextures[2]); msecondeffect.apply(mtextures[2], mimagewidth, mimageheight, mtextures[1]); } else { meffect.apply(mtextures[0], mimagewidth, mimageheight, mtextures[1]); } }
using 2 textures effects can apply cascade of amount of effects, changing source , destination textures.
edit multiple effects try this:
let's imagine have array of effects cascade
effect meffectarray[] = ...; // effect objects applied int meffectcount = ... ; // number of effects used right output
then applyeffect() method this:
private void applyeffect() { if (meffectcount > 0) { // if there effect meffectarray[0].apply(mtextures[0], mimagewidth, mimageheight, mtextures[1]); // apply first effect (int = 1; < meffectcount; i++) { // if more 1 effect int sourcetexture = mtextures[1]; int destinationtexture = mtextures[2]; meffectarray[i].apply(sourcetexture, mimagewidth, mimageheight, destinationtexture); mtextures[1] = destinationtexture; // changing textures array, 1 texture output, mtextures[2] = sourcetexture; // 2 sparse texture } } }
Comments
Post a Comment