本文整理汇总了Java中jp.co.cyberagent.android.gpuimage.GPUImageFilter类的典型用法代码示例。如果您正苦于以下问题:Java GPUImageFilter类的具体用法?Java GPUImageFilter怎么用?Java GPUImageFilter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GPUImageFilter类属于jp.co.cyberagent.android.gpuimage包,在下文中一共展示了GPUImageFilter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getView
import jp.co.cyberagent.android.gpuimage.GPUImageFilter; //导入依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {
EffectHolder holder = null;
if (convertView == null) {
LayoutInflater layoutInflater = LayoutInflater.from(mContext);
convertView = layoutInflater.inflate(R.layout.item_bottom_filter, null);
holder = new EffectHolder();
holder.filteredImg = (GPUImageView) convertView.findViewById(R.id.small_filter);
holder.filterName = (TextView) convertView.findViewById(R.id.filter_name);
convertView.setTag(holder);
} else {
holder = (EffectHolder) convertView.getTag();
}
final FilterEffect effect = (FilterEffect) getItem(position);
holder.filteredImg.setImage(background);
holder.filterName.setText(effect.getTitle());
//if (!effect.isOri() && effect.getType() != null) {
GPUImageFilter filter = GPUImageFilterTools.createFilterForType(mContext, effect.getType());
holder.filteredImg.setFilter(filter);
return convertView;
}
示例2: FilterAdjuster
import jp.co.cyberagent.android.gpuimage.GPUImageFilter; //导入依赖的package包/类
public FilterAdjuster(final GPUImageFilter filter) {
if (filter instanceof GPUImageSharpenFilter) {
adjuster = new SharpnessAdjuster().filter(filter);
} else if (filter instanceof GPUImageSepiaFilter) {
adjuster = new SepiaAdjuster().filter(filter);
} else if (filter instanceof GPUImageContrastFilter) {
adjuster = new ContrastAdjuster().filter(filter);
} else if (filter instanceof GPUImageGammaFilter) {
adjuster = new GammaAdjuster().filter(filter);
} else if (filter instanceof GPUImageBrightnessFilter) {
adjuster = new BrightnessAdjuster().filter(filter);
} else if (filter instanceof GPUImageSobelEdgeDetection) {
adjuster = new SobelAdjuster().filter(filter);
} else if (filter instanceof GPUImageEmbossFilter) {
adjuster = new EmbossAdjuster().filter(filter);
} else if (filter instanceof GPUImage3x3TextureSamplingFilter) {
adjuster = new GPU3x3TextureAdjuster().filter(filter);
} else if (filter instanceof GPUImageHueFilter) {
adjuster = new HueAdjuster().filter(filter);
} else if (filter instanceof GPUImagePosterizeFilter) {
adjuster = new PosterizeAdjuster().filter(filter);
} else if (filter instanceof GPUImagePixelationFilter) {
adjuster = new PixelationAdjuster().filter(filter);
} else if (filter instanceof GPUImageSaturationFilter) {
adjuster = new SaturationAdjuster().filter(filter);
} else if (filter instanceof GPUImageExposureFilter) {
adjuster = new ExposureAdjuster().filter(filter);
} else if (filter instanceof GPUImageHighlightShadowFilter) {
adjuster = new HighlightShadowAdjuster().filter(filter);
} else if (filter instanceof GPUImageMonochromeFilter) {
adjuster = new MonochromeAdjuster().filter(filter);
} else if (filter instanceof GPUImageOpacityFilter) {
adjuster = new OpacityAdjuster().filter(filter);
} else if (filter instanceof GPUImageRGBFilter) {
adjuster = new RGBAdjuster().filter(filter);
} else if (filter instanceof GPUImageWhiteBalanceFilter) {
adjuster = new WhiteBalanceAdjuster().filter(filter);
} else if (filter instanceof GPUImageVignetteFilter) {
adjuster = new VignetteAdjuster().filter(filter);
} else if (filter instanceof GPUImageDissolveBlendFilter) {
adjuster = new DissolveBlendAdjuster().filter(filter);
} else if (filter instanceof GPUImageGaussianBlurFilter) {
adjuster = new GaussianBlurAdjuster().filter(filter);
} else if (filter instanceof GPUImageCrosshatchFilter) {
adjuster = new CrosshatchBlurAdjuster().filter(filter);
} else if (filter instanceof GPUImageBulgeDistortionFilter) {
adjuster = new BulgeDistortionAdjuster().filter(filter);
} else if (filter instanceof GPUImageGlassSphereFilter) {
adjuster = new GlassSphereAdjuster().filter(filter);
} else if (filter instanceof GPUImageHazeFilter) {
adjuster = new HazeAdjuster().filter(filter);
} else if (filter instanceof GPUImageSphereRefractionFilter) {
adjuster = new SphereRefractionAdjuster().filter(filter);
} else if (filter instanceof GPUImageSwirlFilter) {
adjuster = new SwirlAdjuster().filter(filter);
} else if (filter instanceof GPUImageColorBalanceFilter) {
adjuster = new ColorBalanceAdjuster().filter(filter);
} else if (filter instanceof GPUImageLevelsFilter) {
adjuster = new LevelsMinMidAdjuster().filter(filter);
} else if (filter instanceof GPUImageBilateralFilter) {
adjuster = new BilateralAdjuster().filter(filter);
} else if (filter instanceof GPUImageTransformFilter) {
adjuster = new RotateAdjuster().filter(filter);
}
else {
adjuster = null;
}
}
示例3: initFilterToolBar
import jp.co.cyberagent.android.gpuimage.GPUImageFilter; //导入依赖的package包/类
private void initFilterToolBar() {
final List<FilterEffect> filters = EffectService.getInst().getLocalFilters();
final FilterAdapter adapter = new FilterAdapter(PhotoProcessActivity.this, filters, smallImageBackgroud);
bottomToolBar.setAdapter(adapter);
bottomToolBar.setOnItemClickListener(new it.sephiroth.android.library.widget.AdapterView.OnItemClickListener() {
@Override
public void onItemClick(it.sephiroth.android.library.widget.AdapterView<?> arg0, View arg1, int arg2, long arg3) {
labelSelector.hide();
if (adapter.getSelectFilter() != arg2) {
adapter.setSelectFilter(arg2);
GPUImageFilter filter = GPUImageFilterTools.createFilterForType(
PhotoProcessActivity.this, filters.get(arg2).getType());
mGPUImageView.setFilter(filter);
GPUImageFilterTools.FilterAdjuster mFilterAdjuster = new GPUImageFilterTools.FilterAdjuster(filter);
//可调节颜色的滤镜
if (mFilterAdjuster.canAdjust()) {
//mFilterAdjuster.adjust(100); 给可调节的滤镜选一个合适的值
}
}
}
});
}
示例4: onClick
import jp.co.cyberagent.android.gpuimage.GPUImageFilter; //导入依赖的package包/类
@Override
public void onClick(final View v) {
switch (v.getId()) {
case R.id.button_choose_filter:
GPUImageFilterTools.showDialog(this, new OnGpuImageFilterChosenListener() {
@Override
public void onGpuImageFilterChosenListener(final GPUImageFilter filter) {
switchFilterTo(filter);
mGPUImageView.requestRender();
}
});
break;
case R.id.button_save:
saveImage();
break;
default:
break;
}
}
示例5: getBitmapForMultipleFilters
import jp.co.cyberagent.android.gpuimage.GPUImageFilter; //导入依赖的package包/类
/**
* Gets the images for multiple filters on a image. This can be used to
* quickly get thumbnail images for filters. <br>
* Whenever a new Bitmap is ready, the listener will be called with the
* bitmap. The order of the calls to the listener will be the same as the
* filter order.
*
* @param bitmap the bitmap on which the filters will be applied
* @param filters the filters which will be applied on the bitmap
* @param listener the listener on which the results will be notified
*/
public static void getBitmapForMultipleFilters(final Bitmap bitmap,
final List<GPUImageFilter> filters, final ResponseListener<Bitmap> listener) {
if (filters.isEmpty()) {
return;
}
GPUImageRenderer renderer = new GPUImageRenderer(filters.get(0));
renderer.setImageBitmap(bitmap, false);
PixelBuffer buffer = new PixelBuffer(bitmap.getWidth(), bitmap.getHeight());
buffer.setRenderer(renderer);
for (GPUImageFilter filter : filters) {
renderer.setFilter(filter);
listener.response(buffer.getBitmap());
filter.destroy();
}
renderer.deleteImage();
buffer.destroy();
}
示例6: setFilter
import jp.co.cyberagent.android.gpuimage.GPUImageFilter; //导入依赖的package包/类
public void setFilter(final GPUImageFilter filter) {
runOnDraw(new Runnable() {
@Override
public void run() {
final GPUImageFilter oldFilter = mFilter;
mFilter = filter;
if (oldFilter != null) {
oldFilter.destroy();
}
mFilter.init();
GLES20.glUseProgram(mFilter.getProgram());
mFilter.onOutputSizeChanged(mOutputWidth, mOutputHeight);
}
});
}
示例7: filterPhoto
import jp.co.cyberagent.android.gpuimage.GPUImageFilter; //导入依赖的package包/类
public static Bitmap filterPhoto(Context context, Bitmap bitmap, String key) {
if (bitmap == null) {
return null;
}
// 实现图片过滤处理
GPUImageFilter filter = null;
if (!TextUtils.isEmpty(key)) {
try {
filter = FILTERS.get(key).newInstance();
} catch (Exception e) {
}
}
if (filter != null) {
GPUImage gpuImage = new GPUImage(context);
gpuImage.setFilter(filter);
bitmap = gpuImage.getBitmapWithFilterApplied(bitmap);
gpuImage.deleteImage();
}
return bitmap;
}
示例8: initSurface
import jp.co.cyberagent.android.gpuimage.GPUImageFilter; //导入依赖的package包/类
@Override
public void initSurface(Context context) {
List<GPUImageFilter> filters = new ArrayList<>();
for (Processor processor : mProcessors) {
filters.addAll(processor.getFilters());
}
filters.add(new GPUImageFilter());
GLFilterGroup filterGroup = new GLFilterGroup(filters);
filterGroup.setImageDumpedListener(this);
mGLRender = new GLRender(filterGroup, mDefaultFilterEnabled, this, mProfiler);
if (GLUtil.isSupportOpenGLES2(context)) {
mGLSurfaceView.setEGLContextClientVersion(2);
}
mGLSurfaceView.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
mGLSurfaceView.getHolder().setFormat(PixelFormat.RGBA_8888);
mGLSurfaceView.setRenderer(mGLRender);
mGLSurfaceView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
mGLSurfaceView.requestRender();
}
示例9: GLRender
import jp.co.cyberagent.android.gpuimage.GPUImageFilter; //导入依赖的package包/类
public GLRender(final GLFilterGroup filter, boolean enableFilter,
VideoSizeChangedListener videoSizeChangedListener, Profiler profiler) {
mVideoSizeChangedListener = videoSizeChangedListener;
mProfiler = profiler;
mIdleFilterGroup = new GLFilterGroup(Collections.singletonList(new GPUImageFilter()));
mDesiredFilter = filter;
mEnableFilter = enableFilter;
mFilter = enableFilter ? mDesiredFilter : mIdleFilterGroup;
mRunOnDraw = new LinkedList<>();
mRunOnDrawEnd = new LinkedList<>();
mGLCubeBuffer = ByteBuffer.allocateDirect(CUBE.length * 4)
.order(ByteOrder.nativeOrder())
.asFloatBuffer();
mGLCubeBuffer.put(CUBE).position(0);
mGLTextureBuffer = ByteBuffer.allocateDirect(TEXTURE_NO_ROTATION.length * 4)
.order(ByteOrder.nativeOrder())
.asFloatBuffer();
setRotation(Rotation.NORMAL, false, false);
}
示例10: GLFilterGroup
import jp.co.cyberagent.android.gpuimage.GPUImageFilter; //导入依赖的package包/类
/**
* Instantiates a new GPUImageFilterGroup with the given filters.
*
* @param filters the filters which represent this filter
*/
public GLFilterGroup(List<GPUImageFilter> filters) {
mFilters = filters;
if (mFilters == null) {
mFilters = new ArrayList<>();
} else {
updateMergedFilters();
}
mGLCubeBuffer = ByteBuffer.allocateDirect(GLRender.CUBE.length * 4)
.order(ByteOrder.nativeOrder())
.asFloatBuffer();
mGLCubeBuffer.put(GLRender.CUBE).position(0);
mGLTextureBuffer = ByteBuffer.allocateDirect(TEXTURE_NO_ROTATION.length * 4)
.order(ByteOrder.nativeOrder())
.asFloatBuffer();
mGLTextureBuffer.put(TEXTURE_NO_ROTATION).position(0);
float[] flipTexture = TextureRotationUtil.getRotation(Rotation.NORMAL, false, true);
mGLTextureFlipBuffer = ByteBuffer.allocateDirect(flipTexture.length * 4)
.order(ByteOrder.nativeOrder())
.asFloatBuffer();
mGLTextureFlipBuffer.put(flipTexture).position(0);
}
示例11: updateMergedFilters
import jp.co.cyberagent.android.gpuimage.GPUImageFilter; //导入依赖的package包/类
public void updateMergedFilters() {
if (mFilters == null) {
return;
}
if (mMergedFilters == null) {
mMergedFilters = new ArrayList<>();
} else {
mMergedFilters.clear();
}
List<GPUImageFilter> filters;
for (GPUImageFilter filter : mFilters) {
if (filter instanceof GLFilterGroup) {
((GLFilterGroup) filter).updateMergedFilters();
filters = ((GLFilterGroup) filter).getMergedFilters();
if (filters == null || filters.isEmpty()) continue;
mMergedFilters.addAll(filters);
continue;
}
mMergedFilters.add(filter);
}
}
示例12: getFilterFactories
import jp.co.cyberagent.android.gpuimage.GPUImageFilter; //导入依赖的package包/类
private static Map<String, Func<GPUImageFilter>> getFilterFactories() {
if (sFilterFactories != null) {
return sFilterFactories;
}
sFilterFactories = new HashMap<>();
sFilterFactories.put(CROP_FILTER_ID, new Func<GPUImageFilter>() {
@Override
public GPUImageFilter func() {
return new GPUImageCropFilter();
}
});
sFilterFactories.put(HUE_FILTER_ID, new Func<GPUImageFilter>() {
@Override
public GPUImageFilter func() {
return new GPUImageHueFilter();
}
});
return sFilterFactories;
}
示例13: initFilter
import jp.co.cyberagent.android.gpuimage.GPUImageFilter; //导入依赖的package包/类
@Override
protected GPUImageFilter initFilter(Context context) {
PointF[] redControlPoints = new PointF[] { new PointF(0.0f, 0.078f),
new PointF(0.341f, 0.475f), new PointF(0.835f, 0.882f),
new PointF(1.0f, 0.949f) };
PointF[] greenControlPoints = new PointF[] { new PointF(0.0f, 0.0f),
new PointF(0.243f, 0.282f), new PointF(0.580f, 0.698f),
new PointF(0.831f, 0.882f), new PointF(1.0f, 1.0f) };
PointF[] blueControlPoints = new PointF[] { new PointF(0.0f, 0.067f),
new PointF(0.490f, 0.565f), new PointF(0.761f, 0.773f),
new PointF(1.0f, 0.910f) };
return new FilterBuilder.Builder().toneCurve(redControlPoints,
greenControlPoints, blueControlPoints).build();
}
示例14: initFilter
import jp.co.cyberagent.android.gpuimage.GPUImageFilter; //导入依赖的package包/类
@Override
protected GPUImageFilter initFilter(Context context) {
List<GPUImageFilter> filterList = new ArrayList<GPUImageFilter>();
GPUImageOverlayBlendFilter blendFilter = new GPUImageOverlayBlendFilter();
blendFilter.setBitmap(BitmapFactory.decodeResource(
context.getResources(), R.drawable.filter_serenity_vignette2));
filterList.add(blendFilter);
GPUImageLookupFilter lookup = new GPUImageLookupFilter();
lookup.setBitmap(BitmapFactory.decodeResource(context.getResources(),
R.drawable.lookup_serenity));
filterList.add(lookup);
return new GPUImageFilterGroup(filterList);
}
示例15: initFilter
import jp.co.cyberagent.android.gpuimage.GPUImageFilter; //导入依赖的package包/类
@Override
protected GPUImageFilter initFilter(Context context) {
List<GPUImageFilter> filterList = new ArrayList<GPUImageFilter>();
GPUImageLookupFilter lookup = new GPUImageLookupFilter();
lookup.setBitmap(BitmapFactory.decodeResource(context.getResources(),
R.drawable.lookup_luminance));
filterList.add(lookup);
GPUImageSoftLightBlendFilter blendFilter = new GPUImageSoftLightBlendFilter();
blendFilter.setBitmap(BitmapFactory.decodeResource(
context.getResources(), R.drawable.filter_luminance_vignette));
filterList.add(blendFilter);
return new GPUImageFilterGroup(filterList);
}