use of android.filterfw.core.MutableFrameFormat in project android_frameworks_base by ParanoidAndroid.
the class FixedRotationFilter method process.
@Override
public void process(FilterContext context) {
Frame input = pullInput("image");
if (mRotation == 0) {
pushOutput("image", input);
return;
}
FrameFormat inputFormat = input.getFormat();
// Create program if not created already
if (mProgram == null) {
mProgram = ShaderProgram.createIdentity(context);
}
MutableFrameFormat outputFormat = inputFormat.mutableCopy();
int width = inputFormat.getWidth();
int height = inputFormat.getHeight();
Point p1 = new Point(0.0f, 0.0f);
Point p2 = new Point(1.0f, 0.0f);
Point p3 = new Point(0.0f, 1.0f);
Point p4 = new Point(1.0f, 1.0f);
Quad sourceRegion;
switch(((int) Math.round(mRotation / 90f)) % 4) {
case 1:
sourceRegion = new Quad(p3, p1, p4, p2);
outputFormat.setDimensions(height, width);
break;
case 2:
sourceRegion = new Quad(p4, p3, p2, p1);
break;
case 3:
sourceRegion = new Quad(p2, p4, p1, p3);
outputFormat.setDimensions(height, width);
break;
case 0:
default:
sourceRegion = new Quad(p1, p2, p3, p4);
break;
}
// Create output frame
Frame output = context.getFrameManager().newFrame(outputFormat);
// Set the source region
mProgram.setSourceRegion(sourceRegion);
// Process
mProgram.process(input, output);
// Push output
pushOutput("image", output);
// Release pushed frame
output.release();
}
use of android.filterfw.core.MutableFrameFormat in project android_frameworks_base by ParanoidAndroid.
the class ImageFormat method create.
public static MutableFrameFormat create(int width, int height, int colorspace, int bytesPerSample, int target) {
MutableFrameFormat result = new MutableFrameFormat(FrameFormat.TYPE_BYTE, target);
result.setDimensions(width, height);
result.setBytesPerSample(bytesPerSample);
result.setMetaValue(COLORSPACE_KEY, colorspace);
if (target == FrameFormat.TARGET_SIMPLE) {
result.setObjectClass(Bitmap.class);
}
return result;
}
use of android.filterfw.core.MutableFrameFormat in project platform_frameworks_base by android.
the class RetargetFilter method getOutputFormat.
@Override
public FrameFormat getOutputFormat(String portName, FrameFormat inputFormat) {
MutableFrameFormat retargeted = inputFormat.mutableCopy();
retargeted.setTarget(mTarget);
return retargeted;
}
use of android.filterfw.core.MutableFrameFormat in project platform_frameworks_base by android.
the class ObjectFormat method fromClass.
public static MutableFrameFormat fromClass(Class clazz, int count, int target) {
// Create frame format
MutableFrameFormat result = new MutableFrameFormat(FrameFormat.TYPE_OBJECT, target);
result.setObjectClass(getBoxedClass(clazz));
if (count != FrameFormat.SIZE_UNSPECIFIED) {
result.setDimensions(count);
}
result.setBytesPerSample(bytesPerSampleForClass(clazz, target));
return result;
}
use of android.filterfw.core.MutableFrameFormat in project platform_frameworks_base by android.
the class FrameFormat method mutableCopy.
public MutableFrameFormat mutableCopy() {
MutableFrameFormat result = new MutableFrameFormat();
result.setBaseType(getBaseType());
result.setTarget(getTarget());
result.setBytesPerSample(getBytesPerSample());
result.setDimensions(getDimensions());
result.setObjectClass(getObjectClass());
result.mMetaData = mMetaData == null ? null : (KeyValueMap) mMetaData.clone();
return result;
}
Aggregations