B4A Library RSImageProcessing Library

Hello everybody,

I'm back again with a new library.
With this library you can do a lot of image processing and it is easy to use:


  • Properties:
    • All As
    Methods:
    • applyConfig (config As Double()())
    • computeConvolution3x3 (src As Bitmap, matrix As ConvolutionMatrix) As Bitmap
      This works fluently on my app.
      Sharpens my image.
      Works slower!
      Uses getpixel
      src:
      matrix:
      Return type: @return:
  • RSImageBlend
    Methods:
    • AddBlend (source As Bitmap, layer As Bitmap) As Bitmap
      Blends 2 bitmaps to one and adds addition blend.
    • AverageBlend (source As Bitmap, layer As Bitmap) As Bitmap
      Blends 2 bitmaps to one and adds average blend.
    • Blend (bottomImage As Bitmap, topImage As Bitmap, left As Float, top As Float) As Bitmap
      Blends 2 bitmaps together with help of a canvas. - Blending
      Draws them both to a canvas and saves them as a bitmap.
    • ColorBurnBlend (source As Bitmap, layer As Bitmap) As Bitmap
      Blends 2 bitmaps to one and adds substraction blend.
    • ColorDodgeBlend (source As Bitmap, layer As Bitmap) As Bitmap
      Blends 2 bitmaps to one and adds the color dodge blend mode to it.
    • DarkenBlend (source As Bitmap, layer As Bitmap) As Bitmap
      Blends 2 bitmaps to one and adds darken blend.
    • DifferenceBlend (source As Bitmap, layer As Bitmap) As Bitmap
      Blends 2 bitmaps to one and adds substraction blend.
    • ExclusionBlend (source As Bitmap, layer As Bitmap) As Bitmap
      Blends 2 bitmaps to one and adds substraction blend.
    • GlowBlend (source As Bitmap, layer As Bitmap) As Bitmap
      Blends 2 bitmaps to one and adds substraction blend.
    • HardMixBlend (source As Bitmap, layer As Bitmap) As Bitmap
      Blends 2 bitmaps to one and adds substraction blend.
    • HardlightBlend (source As Bitmap, layer As Bitmap) As Bitmap
      Blends 2 bitmaps to one and adds substraction blend.
    • LightenBlend (source As Bitmap, layer As Bitmap) As Bitmap
      Blends 2 bitmaps to one and adds lighten blend.
    • LinearBurnBlend (source As Bitmap, layer As Bitmap) As Bitmap
      Blends 2 bitmaps to one and adds substraction blend.
    • LinearDodgeBlend (source As Bitmap, layer As Bitmap) As Bitmap
      Blends 2 bitmaps to one and adds addition blend.
    • LinearLightBlend (source As Bitmap, layer As Bitmap) As Bitmap
      Blends 2 bitmaps to one and adds substraction blend.
    • MultiplyBlend (source As Bitmap, layer As Bitmap) As Bitmap
      Blends 2 bitmaps to one and adds darken blend.
    • NegationBlend (source As Bitmap, layer As Bitmap) As Bitmap
      Blends 2 bitmaps to one and adds substraction blend.
    • OverlayBlend (source As Bitmap, layer As Bitmap) As Bitmap
      Blends 2 bitmaps to one and adds substraction blend.
    • PhoenixBlend (source As Bitmap, layer As Bitmap) As Bitmap
      Blends 2 bitmaps to one and adds substraction blend.
    • PinLightBlend (source As Bitmap, layer As Bitmap) As Bitmap
      Blends 2 bitmaps to one and adds substraction blend.
    • ReflectBlend (source As Bitmap, layer As Bitmap) As Bitmap
      Blends 2 bitmaps to one and adds substraction blend.
    • ScreenBlend (source As Bitmap, layer As Bitmap) As Bitmap
      Blends 2 bitmaps to one and adds substraction blend.
    • SoftlightBlend (source As Bitmap, layer As Bitmap) As Bitmap
      Blends 2 bitmaps to one and adds substraction blend.
    • SubstractBlend (source As Bitmap, layer As Bitmap) As Bitmap
      Blends 2 bitmaps to one and adds substraction blend.
    • VividLightBlend (source As Bitmap, layer As Bitmap) As Bitmap
      Blends 2 bitmaps to one and adds substraction blend.
  • RSImageEffects
    Methods:
    • Blur (src As Bitmap, Factor As Int, Offset As Int) As Bitmap
      Does a Gaussian Blur to the image. - Filter
      It uses the concepts of Convolution Filtering to apply in image processing.
    • Brightness (src As Bitmap, value As Int) As Bitmap
      The concept of brightness is rather simple, increasing/decreasing value of each R, G, B channel together.
      + By increasing: image results brighter.
      + By decreasing: image results darker.

      Effects
    • ColorBoost (src As Bitmap, type As Int, percent As Float) As Bitmap
      Color boost technique is basically based on color filtering, which is to increase the
      intensity of a single color channel.

      Effect
    • Contrast (src As Bitmap, value As Double) As Bitmap
      Contrast is the difference in luminance and/or colour that makes an object (or its representation in an image or display) distinguishable.
      In visual perception of the real world, contrast is determined by the difference in the colour and
      brightness of the object and other objects within the same field of view.

      Effects
    • Emboss (src As Bitmap) As Bitmap
      Embosses your bitmap to make it look sketchy like.

      Filter
    • Engrave (src As Bitmap) As Bitmap
      Engraves your bitmap.

      Filter
    • Flip (src As Bitmap) As Bitmap
      Flips a bitmap vertically.

      Effect
    • GammaCorrection (src As Bitmap, red As Double, green As Double, blue As Double) As Bitmap
      Gamma correction or gamma encoding is one among the common image processing method
      Gamma correction, gamma nonlinearity, gamma encoding, or often simply gamma,
      is the name of a nonlinear operation used to code and decode luminance or tristimulus values in video or
      still image systems.

      Effect
    • GreyScale (src As Bitmap) As Bitmap
      Greyscales a bitmap
      The intensity is calculated by common formula: 30% of Red + 59% of Green + 11 % of Blue

      Effects
    • Highlight (src As Bitmap) As Bitmap
      Highlights a bitmap.

      Effects
    • Invert (src As Bitmap) As Bitmap
      Inverts a bitmap.
      Every image pixel holds information of four channels: Alpha, Red, Green, Blue.
      However, Alpha doesn�t reflect the image color as display. So the value is kept, and take inversion for other three
      channels by formula: 0xFF � CurrentValue.
    • Mirror (src As Bitmap) As Bitmap
      Flips a bitmap horizontally.

      Effect
    • Noise (source As Bitmap) As Bitmap
      Gives a noise or flea effect to the bitmap

      Effect
    • Paintify (src As Bitmap, bitOffset As Int, Factor As Int, Offset As Int) As Bitmap
      Makes a paint like effect on a picture.
      128 (or 64/32)
      8
      1

      Effect
    • Paintify2 (src As Bitmap, bitOffset As Int, Factor As Int, Offset As Int) As Bitmap
      Makes a paint like effect on a picture.
      128 (or 64/32)
      8
      1

      Effect
    • Posterize (src As Bitmap, bitOffset As Int) As Bitmap
      Decreasing color depth involves converting to standard values.
      For example: if I want to offset 32, then each image color channel will apply the range: 0, 31, 63 �

      Effects
    • Reflection (originalImage As Bitmap, ReflectionGap As Int) As Bitmap
      Makes a mirror/reflection like
      ReflectionGap: gap space between original and reflected

      Effect
    • ReplaceColor (src As Bitmap, fromColor As Int, targetColor As Int) As Bitmap
      Replaces pixels from one color to the other.

      Effect
    • Rotate (src As Bitmap, degree As Float) As Bitmap
      Rotates a bitmaps

      Effects
    • RoundCorner (src As Bitmap, round As Float) As Bitmap
      Create a bitmap with round corners.
      Effect
    • SepiaToning (src As Bitmap, depth As Int, red As Double, green As Double, blue As Double) As Bitmap
      Sepia-toning effect is used very commonly in photography.
      It is the process of changing the intensity on every pixel color of a gray-scale image, or so-called black-and-white.

      Effects
    • Sharpen (src As Bitmap, weight As Double) As Bitmap
      Sharpening effect make uses of Convolution Matrix
      The applied matrix is:
      [ 0 | -2 | 0 ]
      [ -2 | 11 | -2 ]
      [ 0 | -2 | 0 ]

      Filter
      Weight : 3
    • Sharpen2 (src As Bitmap, weight As Double) As Bitmap
      Sharpening effect make uses of Convolution Matrix
      The applied matrix is:
      [ 0 | -2 | 0 ]
      [ -2 | 11 | -2 ]
      [ 0 | -2 | 0 ]

      Filter
      Weight : 3
    • Sketchify (src As Bitmap, Factor As Int, Offset As Int) As Bitmap
      Sketchify a photo.
      src:
      Factor: 16
      Offset: 0
      Return type: @return:Effect
    • Smooth (src As Bitmap, value As Double) As Bitmap
      Smoothens a bitmap.
      The factor is 13 and offset 1.

      Filter
    • Snow (source As Bitmap) As Bitmap
      Adds a snow-like effect to the bitmap.
      Opposite of Black Filter
      Sets all pixels having R,G,B values to the max (0xFF) when they�re greater than threshold,
      then we have the Snow Effect.

      Effect
    • TintColor (src As Bitmap, degree As Int) As Bitmap
      Gives a nice tint color to a bitmap.
      degree: Use the constants for the degree.

      Effect
    • Watermark (src As Bitmap, watermark As String, x As Float, y As Float, color As Int, alpha As Int, size As Int, underline As Boolean) As Bitmap
      Gives your image a watermark, choose the location of the text, etc, etc
      Effect
  • RSImageFilters
    Methods:
    • BlackFilter (source As Bitmap) As Bitmap
      Base on randomizing image pixels, another filter is created, named �Black Filter�, or enhance the noise of darkness.
      The algorithm is to generate a threshold number (0-255), if all R,G,B values of a pixel are less than the threshold,
      then set the pixel to black.

      Filter
    • ColorFilter (src As Bitmap, red As Double, green As Double, blue As Double) As Bitmap
      Filter the color on the bitmap, in which to display image by only one channel or
      combine the increase on every channel.

      Filter
    • EdgeEnhancement (src As Bitmap, Factor As Int, Offset As Int) As Bitmap
      Edge Enhancement
    • EdgeEnhancement2 (src As Bitmap, Factor As Int, Offset As Int) As Bitmap
      Edge Enhancement
    • EdgeEnhancement3 (src As Bitmap, Factor As Int, Offset As Int) As Bitmap
      Edge Enhancement
    • FindEdge (src As Bitmap, Factor As Int, Offset As Int) As Bitmap
      Find Edge
    • FindEdge2 (src As Bitmap, Factor As Int, Offset As Int) As Bitmap
      Find Edge
    • FindEdge3 (src As Bitmap, Factor As Int, Offset As Int) As Bitmap
      Find Edge
    • GaussianFilter (src As Bitmap, Factor As Int, Offset As Int) As Bitmap
      Gaussian filter.
    • GaussianFilter2 (src As Bitmap, Factor As Int, Offset As Int) As Bitmap
      Gaussian filter.
    • HueFilter (source As Bitmap, level As Int) As Bitmap
      Filters the Hue of a bitmap.
      By converting RGB to HSV, we can adjust pixel color in different way.

      Filter
    • MeanRemoval (src As Bitmap) As Bitmap
      Mean Removal Effect makes uses of Convolution Matrix.
      The applied matrix is:
      [ -1 | -1 | -1 ]
      [ -1 | 9 | -1 ]
      [ -1 | -1 | -1 ]

      Filter
    • SaturationFilter (source As Bitmap, level As Int) As Bitmap
      Filters the saturation of a bitmap.
      By converting RGB to HSV, we can adjust pixel color in different way.

      Filter
    • ShadingFilter (source As Bitmap, shadingColor As Int) As Bitmap
      Shading Filter is a technique that use AND operator for the current pixel color and a desired-shading color.

      Filter
    • Wedding (src As Bitmap, Factor As Int, Offset As Int) As Bitmap
      Wedding
      src:
      Factor: 16
      Offset: 0
      Return type: @return:Filter
  • RSImageProcessing
    Methods:
    • Initialize
      Initializes the RSSImageProcessing Library.
      EventName - Events subs prefix.
    • compress (bitmap As Bitmap, format As String, quality As Int, stream As OutputStream)
      Write a compressed version of the bitmap to the specified outputstream.

      format The format of the compressed image
      quality Hint to the compressor, 0-100. 0 meaning compress for small size, 100 meaning compress for max quality. Some formats, like PNG which is lossless, will ignore the quality setting
      stream The outputstream to write the compressed data.
    • createScaledBitmap (src As Bitmap, dstWidth As Int, dstHeight As Int, filter As Boolean) As Bitmap
      Creates a new bitmap, scaled from an existing bitmap.
      src The source bitmap.
      dstWidth The new bitmap's desired width.
      dstHeight The new bitmap's desired height.
      filter true if the source should be filtered.
      Return type: @return:the bitmap
    • eraseColor (bitmap As Bitmap, c As Int)
      Fills the bitmap's pixels with the specified Color.
      bitmap: the source bitmap. (must be mutable!)
      c: colours
    • extractAlpha (bitmap As Bitmap) As Bitmap
      Returns a new bitmap that captures the alpha values of the original.
      bitmap:
    • extractBitmap (source As Bitmap, x As Int, y As Int, width As Int, height As Int) As Bitmap
      Returns an immutable bitmap from the specified subset of the source bitmap.
      The new bitmap may be the same object as source, or a copy may have been made.
      It is initialized with the same density as the original bitmap.
      source:
      x:
      y:
      width:
      height:
      Return type: @return:
    • extractBitmap2 (source As Bitmap, x As Int, y As Int, width As Int, height As Int) As Bitmap
      Returns an immutable bitmap from the specified subset of the source bitmap.
      The new bitmap may be the same object as source, or a copy may have been made.
      It is initialized with the same density as the original bitmap.
      source:
      x:
      y:
      width:
      height:
      Return type: @return:
    • getDestination (src As Bitmap, destination As Double) As Int
      Gets the new destination width or height keeping the aspect ratio of the image.
      src: - bitmap
      destination: -Source width or height
      Return type: @return:
    • getPixel (bitmap As Bitmap, x As Int, y As Int) As Int
      Returns the Color at the specified location.
      Throws an exception if x or y are out of bounds (negative or >= to the width or height respectively).
      bitmap:
      x: The x coordinate (0...width-1) of the pixel to return
      y: The y coordinate (0...height-1) of the pixel to return
      Return type: @return:The argb Color at the specified coordinate
    • hasAlpha (bitmap As Bitmap) As Boolean
      Returns true if the bitmap's config supports per-pixel alpha, and if the pixels may contain non-opaque alpha values.
      For some configs, this is always false (e.g. RGB_565), since they do not support per-pixel alpha.
      However, for configs that do, the bitmap may be flagged to be known that all of its pixels are opaque.
      In this case hasAlpha() will also return false. If a config such as ARGB_8888 is not so flagged, it will return true by default.
      bitmap:
      Return type: @return:
    • isMutable (bitmap As Bitmap) As Boolean
      Returns true if the bitmap is marked as mutable (i.e. can be drawn into)
      bitmap:
      Return type: @return:
    • isRecycled (bitmap As Bitmap) As Boolean
      Returns true if this bitmap has been recycled. If so, then it is an error to try to access its pixels, and the bitmap will not draw.
      bitmap:
      Return type: @return:true if the bitmap has been recycled
    • recycle (bitmap As Bitmap)
      Free the native object associated with this bitmap, and clear the reference to the pixel data.
      This will not free the pixel data synchronously; it simply allows it to be garbage collected if
      there are no other references. The bitmap is marked as "dead", meaning it will throw an exception if
      getPixels() or setPixels() is called, and will draw nothing. This operation cannot be reversed,
      so it should only be called if you are sure there are no further uses for the bitmap.
      This is an advanced call, and normally need not be called, since the normal GC process will free
      up this memory when there are no more references to this bitmap.
      bitmap:
    • rotate (src As Bitmap, degree As Float) As Bitmap
    • rotateBitmap (bitmap As Bitmap, degrees As Float) As Bitmap
      Rotates the bitmap.
      bitmap:
      degrees:
      Return type: @return:
    • scaleBitmap (bitmap As Bitmap, sx As Float, sy As Float) As Bitmap
      Scales the bitmap.
      bitmap:
      degrees:
      Return type: @return:
    • setHorizontalScrollBarEnabled (hsv As HorizontalScrollView, enabled As Boolean)
    • skewBitmap (bitmap As Bitmap, kx As Float, ky As Float) As Bitmap
      Skews the bitmap.
      bitmap:
      kx:
      ky:
      Return type: @return:
    • translateBitmap (bitmap As Bitmap, dx As Float, dy As Float) As Bitmap
      Translate the bitmap.
      bitmap:
      degrees:
      Return type: @return:
    • writeBitmapToFile (src As Bitmap, dir As String, fileName As String, quality As Int)
      Writes a bitmap to a file

And tons of other features!

Have fun,
Tomas
 

Attachments

  • RSImageProcessing.zip
    151.9 KB · Views: 2,616
  • RSImageProcessing2.zip
    332 KB · Views: 3,016
  • RSImageProcessingFixed.zip
    331.4 KB · Views: 4,119
Last edited:

jcohedman

Member
Licensed User
Longtime User
Hello everybody,

I'm back again with a new library.
With this library you can do a lot of image processing and it is easy to use:


  • Properties:
    • All As
    Methods:
    • applyConfig (config As Double()())
    • computeConvolution3x3 (src As Bitmap, matrix As ConvolutionMatrix) As Bitmap
      This works fluently on my app.
      Sharpens my image.
      Works slower!
      Uses getpixel
      src:
      matrix:
      Return type: @return:
  • RSImageBlend
    Methods:
    • AddBlend (source As Bitmap, layer As Bitmap) As Bitmap
      Blends 2 bitmaps to one and adds addition blend.
    • AverageBlend (source As Bitmap, layer As Bitmap) As Bitmap
      Blends 2 bitmaps to one and adds average blend.
    • Blend (bottomImage As Bitmap, topImage As Bitmap, left As Float, top As Float) As Bitmap
      Blends 2 bitmaps together with help of a canvas. - Blending
      Draws them both to a canvas and saves them as a bitmap.
    • ColorBurnBlend (source As Bitmap, layer As Bitmap) As Bitmap
      Blends 2 bitmaps to one and adds substraction blend.
    • ColorDodgeBlend (source As Bitmap, layer As Bitmap) As Bitmap
      Blends 2 bitmaps to one and adds the color dodge blend mode to it.
    • DarkenBlend (source As Bitmap, layer As Bitmap) As Bitmap
      Blends 2 bitmaps to one and adds darken blend.
    • DifferenceBlend (source As Bitmap, layer As Bitmap) As Bitmap
      Blends 2 bitmaps to one and adds substraction blend.
    • ExclusionBlend (source As Bitmap, layer As Bitmap) As Bitmap
      Blends 2 bitmaps to one and adds substraction blend.
    • GlowBlend (source As Bitmap, layer As Bitmap) As Bitmap
      Blends 2 bitmaps to one and adds substraction blend.
    • HardMixBlend (source As Bitmap, layer As Bitmap) As Bitmap
      Blends 2 bitmaps to one and adds substraction blend.
    • HardlightBlend (source As Bitmap, layer As Bitmap) As Bitmap
      Blends 2 bitmaps to one and adds substraction blend.
    • LightenBlend (source As Bitmap, layer As Bitmap) As Bitmap
      Blends 2 bitmaps to one and adds lighten blend.
    • LinearBurnBlend (source As Bitmap, layer As Bitmap) As Bitmap
      Blends 2 bitmaps to one and adds substraction blend.
    • LinearDodgeBlend (source As Bitmap, layer As Bitmap) As Bitmap
      Blends 2 bitmaps to one and adds addition blend.
    • LinearLightBlend (source As Bitmap, layer As Bitmap) As Bitmap
      Blends 2 bitmaps to one and adds substraction blend.
    • MultiplyBlend (source As Bitmap, layer As Bitmap) As Bitmap
      Blends 2 bitmaps to one and adds darken blend.
    • NegationBlend (source As Bitmap, layer As Bitmap) As Bitmap
      Blends 2 bitmaps to one and adds substraction blend.
    • OverlayBlend (source As Bitmap, layer As Bitmap) As Bitmap
      Blends 2 bitmaps to one and adds substraction blend.
    • PhoenixBlend (source As Bitmap, layer As Bitmap) As Bitmap
      Blends 2 bitmaps to one and adds substraction blend.
    • PinLightBlend (source As Bitmap, layer As Bitmap) As Bitmap
      Blends 2 bitmaps to one and adds substraction blend.
    • ReflectBlend (source As Bitmap, layer As Bitmap) As Bitmap
      Blends 2 bitmaps to one and adds substraction blend.
    • ScreenBlend (source As Bitmap, layer As Bitmap) As Bitmap
      Blends 2 bitmaps to one and adds substraction blend.
    • SoftlightBlend (source As Bitmap, layer As Bitmap) As Bitmap
      Blends 2 bitmaps to one and adds substraction blend.
    • SubstractBlend (source As Bitmap, layer As Bitmap) As Bitmap
      Blends 2 bitmaps to one and adds substraction blend.
    • VividLightBlend (source As Bitmap, layer As Bitmap) As Bitmap
      Blends 2 bitmaps to one and adds substraction blend.
  • RSImageEffects
    Methods:
    • Blur (src As Bitmap, Factor As Int, Offset As Int) As Bitmap
      Does a Gaussian Blur to the image. - Filter
      It uses the concepts of Convolution Filtering to apply in image processing.
    • Brightness (src As Bitmap, value As Int) As Bitmap
      The concept of brightness is rather simple, increasing/decreasing value of each R, G, B channel together.
      + By increasing: image results brighter.
      + By decreasing: image results darker.

      Effects
    • ColorBoost (src As Bitmap, type As Int, percent As Float) As Bitmap
      Color boost technique is basically based on color filtering, which is to increase the
      intensity of a single color channel.

      Effect
    • Contrast (src As Bitmap, value As Double) As Bitmap
      Contrast is the difference in luminance and/or colour that makes an object (or its representation in an image or display) distinguishable.
      In visual perception of the real world, contrast is determined by the difference in the colour and
      brightness of the object and other objects within the same field of view.

      Effects
    • Emboss (src As Bitmap) As Bitmap
      Embosses your bitmap to make it look sketchy like.

      Filter
    • Engrave (src As Bitmap) As Bitmap
      Engraves your bitmap.

      Filter
    • Flip (src As Bitmap) As Bitmap
      Flips a bitmap vertically.

      Effect
    • GammaCorrection (src As Bitmap, red As Double, green As Double, blue As Double) As Bitmap
      Gamma correction or gamma encoding is one among the common image processing method
      Gamma correction, gamma nonlinearity, gamma encoding, or often simply gamma,
      is the name of a nonlinear operation used to code and decode luminance or tristimulus values in video or
      still image systems.

      Effect
    • GreyScale (src As Bitmap) As Bitmap
      Greyscales a bitmap
      The intensity is calculated by common formula: 30% of Red + 59% of Green + 11 % of Blue

      Effects
    • Highlight (src As Bitmap) As Bitmap
      Highlights a bitmap.

      Effects
    • Invert (src As Bitmap) As Bitmap
      Inverts a bitmap.
      Every image pixel holds information of four channels: Alpha, Red, Green, Blue.
      However, Alpha doesn�t reflect the image color as display. So the value is kept, and take inversion for other three
      channels by formula: 0xFF � CurrentValue.
    • Mirror (src As Bitmap) As Bitmap
      Flips a bitmap horizontally.

      Effect
    • Noise (source As Bitmap) As Bitmap
      Gives a noise or flea effect to the bitmap

      Effect
    • Paintify (src As Bitmap, bitOffset As Int, Factor As Int, Offset As Int) As Bitmap
      Makes a paint like effect on a picture.
      128 (or 64/32)
      8
      1

      Effect
    • Paintify2 (src As Bitmap, bitOffset As Int, Factor As Int, Offset As Int) As Bitmap
      Makes a paint like effect on a picture.
      128 (or 64/32)
      8
      1

      Effect
    • Posterize (src As Bitmap, bitOffset As Int) As Bitmap
      Decreasing color depth involves converting to standard values.
      For example: if I want to offset 32, then each image color channel will apply the range: 0, 31, 63 �

      Effects
    • Reflection (originalImage As Bitmap, ReflectionGap As Int) As Bitmap
      Makes a mirror/reflection like
      ReflectionGap: gap space between original and reflected

      Effect
    • ReplaceColor (src As Bitmap, fromColor As Int, targetColor As Int) As Bitmap
      Replaces pixels from one color to the other.

      Effect
    • Rotate (src As Bitmap, degree As Float) As Bitmap
      Rotates a bitmaps

      Effects
    • RoundCorner (src As Bitmap, round As Float) As Bitmap
      Create a bitmap with round corners.
      Effect
    • SepiaToning (src As Bitmap, depth As Int, red As Double, green As Double, blue As Double) As Bitmap
      Sepia-toning effect is used very commonly in photography.
      It is the process of changing the intensity on every pixel color of a gray-scale image, or so-called black-and-white.

      Effects
    • Sharpen (src As Bitmap, weight As Double) As Bitmap
      Sharpening effect make uses of Convolution Matrix
      The applied matrix is:
      [ 0 | -2 | 0 ]
      [ -2 | 11 | -2 ]
      [ 0 | -2 | 0 ]

      Filter
      Weight : 3
    • Sharpen2 (src As Bitmap, weight As Double) As Bitmap
      Sharpening effect make uses of Convolution Matrix
      The applied matrix is:
      [ 0 | -2 | 0 ]
      [ -2 | 11 | -2 ]
      [ 0 | -2 | 0 ]

      Filter
      Weight : 3
    • Sketchify (src As Bitmap, Factor As Int, Offset As Int) As Bitmap
      Sketchify a photo.
      src:
      Factor: 16
      Offset: 0
      Return type: @return:Effect
    • Smooth (src As Bitmap, value As Double) As Bitmap
      Smoothens a bitmap.
      The factor is 13 and offset 1.

      Filter
    • Snow (source As Bitmap) As Bitmap
      Adds a snow-like effect to the bitmap.
      Opposite of Black Filter
      Sets all pixels having R,G,B values to the max (0xFF) when they�re greater than threshold,
      then we have the Snow Effect.

      Effect
    • TintColor (src As Bitmap, degree As Int) As Bitmap
      Gives a nice tint color to a bitmap.
      degree: Use the constants for the degree.

      Effect
    • Watermark (src As Bitmap, watermark As String, x As Float, y As Float, color As Int, alpha As Int, size As Int, underline As Boolean) As Bitmap
      Gives your image a watermark, choose the location of the text, etc, etc
      Effect
  • RSImageFilters
    Methods:
    • BlackFilter (source As Bitmap) As Bitmap
      Base on randomizing image pixels, another filter is created, named �Black Filter�, or enhance the noise of darkness.
      The algorithm is to generate a threshold number (0-255), if all R,G,B values of a pixel are less than the threshold,
      then set the pixel to black.

      Filter
    • ColorFilter (src As Bitmap, red As Double, green As Double, blue As Double) As Bitmap
      Filter the color on the bitmap, in which to display image by only one channel or
      combine the increase on every channel.

      Filter
    • EdgeEnhancement (src As Bitmap, Factor As Int, Offset As Int) As Bitmap
      Edge Enhancement
    • EdgeEnhancement2 (src As Bitmap, Factor As Int, Offset As Int) As Bitmap
      Edge Enhancement
    • EdgeEnhancement3 (src As Bitmap, Factor As Int, Offset As Int) As Bitmap
      Edge Enhancement
    • FindEdge (src As Bitmap, Factor As Int, Offset As Int) As Bitmap
      Find Edge
    • FindEdge2 (src As Bitmap, Factor As Int, Offset As Int) As Bitmap
      Find Edge
    • FindEdge3 (src As Bitmap, Factor As Int, Offset As Int) As Bitmap
      Find Edge
    • GaussianFilter (src As Bitmap, Factor As Int, Offset As Int) As Bitmap
      Gaussian filter.
    • GaussianFilter2 (src As Bitmap, Factor As Int, Offset As Int) As Bitmap
      Gaussian filter.
    • HueFilter (source As Bitmap, level As Int) As Bitmap
      Filters the Hue of a bitmap.
      By converting RGB to HSV, we can adjust pixel color in different way.

      Filter
    • MeanRemoval (src As Bitmap) As Bitmap
      Mean Removal Effect makes uses of Convolution Matrix.
      The applied matrix is:
      [ -1 | -1 | -1 ]
      [ -1 | 9 | -1 ]
      [ -1 | -1 | -1 ]

      Filter
    • SaturationFilter (source As Bitmap, level As Int) As Bitmap
      Filters the saturation of a bitmap.
      By converting RGB to HSV, we can adjust pixel color in different way.

      Filter
    • ShadingFilter (source As Bitmap, shadingColor As Int) As Bitmap
      Shading Filter is a technique that use AND operator for the current pixel color and a desired-shading color.

      Filter
    • Wedding (src As Bitmap, Factor As Int, Offset As Int) As Bitmap
      Wedding
      src:
      Factor: 16
      Offset: 0
      Return type: @return:Filter
  • RSImageProcessing
    Methods:
    • Initialize
      Initializes the RSSImageProcessing Library.
      EventName - Events subs prefix.
    • compress (bitmap As Bitmap, format As String, quality As Int, stream As OutputStream)
      Write a compressed version of the bitmap to the specified outputstream.

      format The format of the compressed image
      quality Hint to the compressor, 0-100. 0 meaning compress for small size, 100 meaning compress for max quality. Some formats, like PNG which is lossless, will ignore the quality setting
      stream The outputstream to write the compressed data.
    • createScaledBitmap (src As Bitmap, dstWidth As Int, dstHeight As Int, filter As Boolean) As Bitmap
      Creates a new bitmap, scaled from an existing bitmap.
      src The source bitmap.
      dstWidth The new bitmap's desired width.
      dstHeight The new bitmap's desired height.
      filter true if the source should be filtered.
      Return type: @return:the bitmap
    • eraseColor (bitmap As Bitmap, c As Int)
      Fills the bitmap's pixels with the specified Color.
      bitmap: the source bitmap. (must be mutable!)
      c: colours
    • extractAlpha (bitmap As Bitmap) As Bitmap
      Returns a new bitmap that captures the alpha values of the original.
      bitmap:
    • extractBitmap (source As Bitmap, x As Int, y As Int, width As Int, height As Int) As Bitmap
      Returns an immutable bitmap from the specified subset of the source bitmap.
      The new bitmap may be the same object as source, or a copy may have been made.
      It is initialized with the same density as the original bitmap.
      source:
      x:
      y:
      width:
      height:
      Return type: @return:
    • extractBitmap2 (source As Bitmap, x As Int, y As Int, width As Int, height As Int) As Bitmap
      Returns an immutable bitmap from the specified subset of the source bitmap.
      The new bitmap may be the same object as source, or a copy may have been made.
      It is initialized with the same density as the original bitmap.
      source:
      x:
      y:
      width:
      height:
      Return type: @return:
    • getDestination (src As Bitmap, destination As Double) As Int
      Gets the new destination width or height keeping the aspect ratio of the image.
      src: - bitmap
      destination: -Source width or height
      Return type: @return:
    • getPixel (bitmap As Bitmap, x As Int, y As Int) As Int
      Returns the Color at the specified location.
      Throws an exception if x or y are out of bounds (negative or >= to the width or height respectively).
      bitmap:
      x: The x coordinate (0...width-1) of the pixel to return
      y: The y coordinate (0...height-1) of the pixel to return
      Return type: @return:The argb Color at the specified coordinate
    • hasAlpha (bitmap As Bitmap) As Boolean
      Returns true if the bitmap's config supports per-pixel alpha, and if the pixels may contain non-opaque alpha values.
      For some configs, this is always false (e.g. RGB_565), since they do not support per-pixel alpha.
      However, for configs that do, the bitmap may be flagged to be known that all of its pixels are opaque.
      In this case hasAlpha() will also return false. If a config such as ARGB_8888 is not so flagged, it will return true by default.
      bitmap:
      Return type: @return:
    • isMutable (bitmap As Bitmap) As Boolean
      Returns true if the bitmap is marked as mutable (i.e. can be drawn into)
      bitmap:
      Return type: @return:
    • isRecycled (bitmap As Bitmap) As Boolean
      Returns true if this bitmap has been recycled. If so, then it is an error to try to access its pixels, and the bitmap will not draw.
      bitmap:
      Return type: @return:true if the bitmap has been recycled
    • recycle (bitmap As Bitmap)
      Free the native object associated with this bitmap, and clear the reference to the pixel data.
      This will not free the pixel data synchronously; it simply allows it to be garbage collected if
      there are no other references. The bitmap is marked as "dead", meaning it will throw an exception if
      getPixels() or setPixels() is called, and will draw nothing. This operation cannot be reversed,
      so it should only be called if you are sure there are no further uses for the bitmap.
      This is an advanced call, and normally need not be called, since the normal GC process will free
      up this memory when there are no more references to this bitmap.
      bitmap:
    • rotate (src As Bitmap, degree As Float) As Bitmap
    • rotateBitmap (bitmap As Bitmap, degrees As Float) As Bitmap
      Rotates the bitmap.
      bitmap:
      degrees:
      Return type: @return:
    • scaleBitmap (bitmap As Bitmap, sx As Float, sy As Float) As Bitmap
      Scales the bitmap.
      bitmap:
      degrees:
      Return type: @return:
    • setHorizontalScrollBarEnabled (hsv As HorizontalScrollView, enabled As Boolean)
    • skewBitmap (bitmap As Bitmap, kx As Float, ky As Float) As Bitmap
      Skews the bitmap.
      bitmap:
      kx:
      ky:
      Return type: @return:
    • translateBitmap (bitmap As Bitmap, dx As Float, dy As Float) As Bitmap
      Translate the bitmap.
      bitmap:
      degrees:
      Return type: @return:
    • writeBitmapToFile (src As Bitmap, dir As String, fileName As String, quality As Int)
      Writes a bitmap to a file

And tons of other features!

Have fun,
Tomas
Error description: Unknown member: colordodgeblend
Occurred on line: 57
btmpBlend = IO.ColorDodgeBlend(btmpBlur, btmpGrayScale)
Word: colordodgeblend

what I'm doing wrong?
I downloaded RSImageProcessingFixed, but any change...
can You help me?
Thank You!
 

jmon

Well-Known Member
Licensed User
Longtime User
The Accelerated Surface library provides an AlterColors function which is very fast to replace the Alpha channel.
Thanks, I would never have guessed that this library would do something like that from its name!

[Edit]
Seems that it is only possible to modify the alpha value as int, but is there a way to swap the alpha with another image in grey scale?
What I need to do is this: draw a red square, then apply an image of a car in grey scale as the alpha of this red square, so that I get a red car.

Thanks for your help
 
Last edited:

chrjak

Active Member
Licensed User
Longtime User
nice-but i dont know what zip i should take... :)
 

RonC.

Member
Licensed User
Longtime User
My values are changing in the Seekbar, but RSIImageFilters doesn't seem to be working in Seekbar1_ValueChanged. Any other suggestions on the code would be great too. ;)


B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Private Timer1 As Timer
End Sub

Sub Globals
    Dim test As Bitmap
    Dim RSIIP As RSImageProcessing
    Dim RSIFilter As RSImageFilters

    Private ImageView1 As ImageView
    Private Label1 As Label
    Private Panel1 As Panel
    Private SeekBar1 As SeekBar
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")

    Init
    RSIIP.Initialize

    Activity.AddView(Panel1,0,0,100%x,100%y)
    Panel1.AddView(Label1,5%x,20dip,90%x,20dip)
    Panel1.AddView(SeekBar1,5%x,60dip,90%x,32dip)
    Panel1.AddView(ImageView1,(Activity.Width/2)-50dip,Activity.Height-100dip,100dip,100dip)

    test.Initialize(File.DirAssets, "d30.jpg")
    ImageView1.Bitmap = test
    Timer1.Enabled = True
End Sub

Private Sub Init
    Timer1.Initialize("Timer1", 2000) '
    Panel1.Initialize("Panel1")
    SeekBar1.Initialize("SeekBar1")
    SeekBar1.Max = 30000
    SeekBar1.Value = 0
    Label1.Initialize("Label1")
    ImageView1.Initialize("ImageView1")
    Label1.TextColor = Colors.White
End Sub

Sub SeekBar1_ValueChanged (Value As Int, UserChanged As Boolean)
    Label1.Text = Value
    ImageView1.Bitmap = RSIFilter.HueFilter(test,Value)
End Sub

Sub Timer1_Tick
    SeekBar1.Value = SeekBar1.Value
End Sub
 

Gsquared

Member
Licensed User
Longtime User
I was not able to get this library and example to work. It says it is missing the "rssketchpad" library and the example fails to compile. I tried all the zip files provided.
 

Vincent HURET

Member
Licensed User
Longtime User
Hi
When I lounch the application in debug..I have an error : missing RSSKETCHPAD then I found the KETCHPAD and have installed it.
Now, I have a problem saying that
IO.Initialize("IO")
is not recognised..

Mayday...somebody has an idea ?

Vincent
 

Spacewalker

Member
Licensed User
Longtime User
same here:
rssketchpad missing and IO.Initialize("IO") error...
any idea how to get this lib working (B4A V3.82) ?
 

Johan Schoeman

Expert
Licensed User
Longtime User

little3399

Active Member
Licensed User
Longtime User
Hi, XverhelstX

I runing the demo project with RSImageProcessingFixed ... and receive a error as flollowing ,,
 

Attachments

  • upload_2015-2-5_13-12-59.png
    upload_2015-2-5_13-12-59.png
    151 KB · Views: 298

G-ShadoW

Active Member
Licensed User
Longtime User
B4X:
Dim a As Bitmap
    a=LoadBitmapSample(File.DirRootExternal, "1.jpg", 100%x, 100%y)
    ii.Watermark(a, "Testing...", 20,10, Colors.Red, 50,100,True)
    io.writeBitmapToFile(a,File.DirRootExternal,"1.jpg",100)

why there is no watermark?
 

MaCaveAVin

Member
Licensed User
Longtime User
Hi,

I just found an issue with colorfilter parameters.

ColorFilter (src As android.graphics.Bitmap, red As Double, green As Double, blue As Double) As android.graphics.Bitmap

ColorFilter(current_bitmap, 0,0,255) : it shows green bitmap
ColorFilter(current_bitmap, 0,255,0) : it shows red bitmap
ColorFilter(current_bitmap, 255,0,0) : it shows nothing

Looks like something is shifted ...
 
Top