Android image processing gpuimage for Android

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.