Gpuimage is the next open source GPU-based image processing library in iOS, offering a wide range of image processing filters and supports real-time filters for cameras and cameras. Gpuimage for Android is its implementation under Android, also open source, hosted on GitHub.
Version: android-gpuimage-1.1.1
OpenGL ES 2.0 is not supported on Android emulator so it will be error-genymotion test, or real machine running.
Reference caused By:java.lang.IllegalStateException:OpenGL ES 2.0 is not supported on the this phone.
(1) using a custom ImageView
XML code
<jp.co.cyberagent.android.gpuimage.gpuimageview android:id= "@+id/gpuimage" android:layout_width= " Wrap_content " android:layout_height=" 0DP " android:layout_gravity=" center " android:layout_weight=" 1 "/>
Java code
Mimageview.setfilter (New Gpuimagesepiafilter ()); Sepiamimageview.setfilter (New Gpuimagegrayscalefilter ()); Graymimageview.setfilter (New Gpuimagesharpenfilter ()); Sharpmimageview.setfilter (New Gpuimagesobeledgedetection ()); Edge
Original
After Sepia:
After Gray:
After Sharp:
After Edge:
(2) Working with files in assets
Java code
Read image Assetmanager as = Getassets (); InputStream is = null; Bitmap Bitmap = null;try {is = As.open ("dog.jpg"); Bitmap = Bitmapfactory.decodestream (IS); Is.close ();} catch (IOException e) {log.e ("mainactivity", "Error"),}//using gpuimage processing image gpuimage Gpuimage = new Gpuimage (this); Gpuima Ge.setimage (bitmap); Gpuimage.setfilter (new Gpuimagetoonfilter ()); bitmap = Gpuimage.getbitmapwithfilterapplied (); Display the processed image in ImageView ImageView view = new ImageView (this); View.setimagebitmap (bitmap); Setcontentview (view);
(3) using Photoshop's ACV file
Java code
Read image Assetmanager as = Getassets (); InputStream is = null; Bitmap Bitmap = null;try {is = As.open ("dog.jpg"); Bitmap = Bitmapfactory.decodestream (IS); Is.close ();} catch (IOException e) {log.e ("mainactivity", "Error");} Read Photoshop's ACV file gpuimagetonecurvefilter filter = new Gpuimagetonecurvefilter (); try {is = As.open ("TONE_CURVE.ACV") ; Filter.setfromcurvefileinputstream (IS); Is.close ();} catch (IOException e) {log.e ("mainactivity", "Error");} Use Gpuimage to process images gpuimage gpuimage = new gpuimage (self); gpuimage.setimage (bitmap); Gpuimage.setfilter (filter); bitmap = Gpuimage.getbitmapwithfilterapplied ();//Display the processed image in ImageView ImageView view = new ImageView (self); View.setimagebitmap (bitmap); Setcontentview (view);
Android image processing gpuimage for Android