Package 

Object RenderScriptToolkit

  • All Implemented Interfaces:

    
    public class RenderScriptToolkit
    
                        

    A collection of high-performance graphic utility functions like blur and blend.

    This toolkit provides ten image manipulation functions: blend, blur, color matrix, convolve, histogram, histogramDot, lut, lut3d, resize, and YUV to RGB. These functions execute multithreaded on the CPU.

    Most of the functions have two variants: one that manipulates Bitmaps, the other ByteArrays. For ByteArrays, you need to specify the width and height of the data to be processed, as well as the number of bytes per pixel. For most use cases, this will be 4.

    The Toolkit creates a thread pool that's used for processing the functions. The threads live for the duration of the application. They can be destroyed by calling the method shutdown().

    This library is thread safe. You can call methods from different poolThreads. The functions will execute sequentially.

    A native C++ version of this Toolkit is available. Check the RenderScriptToolkit.h file in the cpp directory.

    This toolkit can be used as a replacement for most RenderScript Intrinsic functions. Compared to RenderScript, it's simpler to use and more than twice as fast on the CPU. However RenderScript Intrinsics allow more flexibility for the type of allocation supported. In particular, this toolkit does not support allocations of floats.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final Bitmap blur(Bitmap inputBitmap, @IntRange(from = 0, to = 25) Integer radius, Range2d restriction) Blurs an image.
      final Bitmap blur(Bitmap inputBitmap, @IntRange(from = 0, to = 25) Integer radius) Blurs an image.
      final Bitmap blur(Bitmap inputBitmap) Blurs an image.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • blur

         final Bitmap blur(Bitmap inputBitmap, @IntRange(from = 0, to = 25) Integer radius, Range2d restriction)

        Blurs an image.

        Performs a Gaussian blur of a Bitmap and returns result as a Bitmap. A variant of this method is available to blur ByteArrays.

        The radius determines which pixels are used to compute each blurred pixels. This Toolkit accepts values between 1 and 25. Larger values create a more blurred effect but also take longer to compute. When the radius extends past the edge, the edge pixel will be used as replacement for the pixel that's out off boundary.

        This method supports input Bitmap of config ARGB_8888 and ALPHA_8. Bitmaps with a stride different than width * vectorSize are not currently supported. The returned Bitmap has the same config.

        An optional range parameter can be set to restrict the operation to a rectangular subset of each buffer. If provided, the range must be wholly contained with the dimensions described by sizeX and sizeY. NOTE: The output Bitmap will still be full size, with the section that's not blurred all set to 0. This is to stay compatible with RenderScript.

        Parameters:
        inputBitmap - The buffer of the image to be blurred.
      • blur

         final Bitmap blur(Bitmap inputBitmap, @IntRange(from = 0, to = 25) Integer radius)

        Blurs an image.

        Performs a Gaussian blur of a Bitmap and returns result as a Bitmap. A variant of this method is available to blur ByteArrays.

        The radius determines which pixels are used to compute each blurred pixels. This Toolkit accepts values between 1 and 25. Larger values create a more blurred effect but also take longer to compute. When the radius extends past the edge, the edge pixel will be used as replacement for the pixel that's out off boundary.

        This method supports input Bitmap of config ARGB_8888 and ALPHA_8. Bitmaps with a stride different than width * vectorSize are not currently supported. The returned Bitmap has the same config.

        An optional range parameter can be set to restrict the operation to a rectangular subset of each buffer. If provided, the range must be wholly contained with the dimensions described by sizeX and sizeY. NOTE: The output Bitmap will still be full size, with the section that's not blurred all set to 0. This is to stay compatible with RenderScript.

        Parameters:
        inputBitmap - The buffer of the image to be blurred.
      • blur

         final Bitmap blur(Bitmap inputBitmap)

        Blurs an image.

        Performs a Gaussian blur of a Bitmap and returns result as a Bitmap. A variant of this method is available to blur ByteArrays.

        The radius determines which pixels are used to compute each blurred pixels. This Toolkit accepts values between 1 and 25. Larger values create a more blurred effect but also take longer to compute. When the radius extends past the edge, the edge pixel will be used as replacement for the pixel that's out off boundary.

        This method supports input Bitmap of config ARGB_8888 and ALPHA_8. Bitmaps with a stride different than width * vectorSize are not currently supported. The returned Bitmap has the same config.

        An optional range parameter can be set to restrict the operation to a rectangular subset of each buffer. If provided, the range must be wholly contained with the dimensions described by sizeX and sizeY. NOTE: The output Bitmap will still be full size, with the section that's not blurred all set to 0. This is to stay compatible with RenderScript.

        Parameters:
        inputBitmap - The buffer of the image to be blurred.