Android Renderscript Gaussian Blur _android

Source: Internet
Author: User

Look at the code, and see that there are. RS end of the file, not very clear, there are Renderscript class, look at a blind, unintelligible, and then Baidu a bit, receive a lot of goods, this thing in the graphics processing this piece of useful very big.

Today, to say Scriptintrinsicblur, this class does not need to define the RS file, from this intrinsic word can be seen, it is API17 after the built-in classes, specifically for processing images, so that the picture becomes blurred.

public static Bitmap Blurbitmap (Bitmap Bitmap, float radius, contextual context) {//Create Render script contexts Renderscript rs = R 
 
    Enderscript.create (context); 
 
    Allocating memory for bitmaps allocation allocation = Allocation.createfrombitmap (rs, bitmap); 
 
    Type t = Allocation.gettype (); Create memory with the same type, typically creating <span style= "font-family:arial, Helvetica, Sans-serif" in both ways. 
 
    >Allocation</span> Allocation blurredallocation = allocation.createtyped (rs, T); 
    Create a Gaussian rendering script Scriptintrinsicblur Blurscript = scriptintrinsicblur.create (RS, Element.u8_4 (RS)); 
    Set the fuzzy radius (maximum 25.0) Blurscript.setradius (RADIUS); 
    Set input parameters for the script blurscript.setinput (allocation); Call script results are deposited in <span style= "font-family:arial, Helvetica, Sans-serif;" 
 
    >blurredallocation </span> Blurscript.foreach (blurredallocation); 
 
    The script results are stored in the bitmap because the native layer is rendered, the result needs to be copied to the upper Blurredallocation.copyto (bitmap); 
 Destroy everything to free memory Allocation.destroy ();   Blurredallocation.destroy (); 
    Blurscript.destroy (); 
 
    T.destroy (); 
  return bitmap; 

 }

The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

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.