Refactored some variable names
This commit is contained in:
parent
09a1523d57
commit
f62e850b86
3 changed files with 312 additions and 316 deletions
2
app/src/main/java/com/kabouzeid/gramophone/helper/bitmapblur/BlurProcess.java
Normal file → Executable file
2
app/src/main/java/com/kabouzeid/gramophone/helper/bitmapblur/BlurProcess.java
Normal file → Executable file
|
|
@ -1,7 +1,6 @@
|
|||
package com.kabouzeid.gramophone.helper.bitmapblur;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
interface BlurProcess {
|
||||
/**
|
||||
|
|
@ -12,6 +11,5 @@ interface BlurProcess {
|
|||
* @param radius the radius in pixels to blur the image
|
||||
* @return the blurred version of the image.
|
||||
*/
|
||||
@Nullable
|
||||
Bitmap blur(Bitmap original, float radius);
|
||||
}
|
||||
|
|
|
|||
15
app/src/main/java/com/kabouzeid/gramophone/helper/bitmapblur/JavaBlurProcess.java
Normal file → Executable file
15
app/src/main/java/com/kabouzeid/gramophone/helper/bitmapblur/JavaBlurProcess.java
Normal file → Executable file
|
|
@ -1,19 +1,17 @@
|
|||
package com.kabouzeid.gramophone.helper.bitmapblur;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
/**
|
||||
* Blur using Java code.
|
||||
* <p/>
|
||||
*
|
||||
* This is a compromise between Gaussian Blur and Box blur
|
||||
* It creates much better looking blurs than Box Blur, but is
|
||||
* 7x faster than my Gaussian Blur implementation.
|
||||
* <p/>
|
||||
|
||||
* I called it Stack Blur because this describes best how this
|
||||
* filter works internally: it creates a kind of moving stack
|
||||
* of colors whilst scanning through the image. Thereby it
|
||||
|
|
@ -25,11 +23,12 @@ import java.util.concurrent.Callable;
|
|||
*
|
||||
* @author Enrique López Mañas <eenriquelopez@gmail.com>
|
||||
* http://www.neo-tech.es
|
||||
* <p/>
|
||||
*
|
||||
* Author of the original algorithm: Mario Klingemann <mario.quasimondo.com>
|
||||
* <p/>
|
||||
*
|
||||
* Based heavily on http://vitiy.info/Code/stackblur.cpp
|
||||
* See http://vitiy.info/stackblur-algorithm-multi-threaded-blur-for-cpp/
|
||||
*
|
||||
* @copyright: Enrique López Mañas
|
||||
* @license: Apache License 2.0
|
||||
*/
|
||||
|
|
@ -73,9 +72,8 @@ class JavaBlurProcess implements BlurProcess {
|
|||
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24
|
||||
};
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Bitmap blur(@NonNull Bitmap original, float radius) {
|
||||
public Bitmap blur(Bitmap original, float radius) {
|
||||
int w = original.getWidth();
|
||||
int h = original.getHeight();
|
||||
int[] currentPixels = new int[w * h];
|
||||
|
|
@ -322,7 +320,6 @@ class JavaBlurProcess implements BlurProcess {
|
|||
_round = round;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Void call() throws Exception {
|
||||
blurIteration(_src, _w, _h, _radius, _totalCores, _coreIndex, _round);
|
||||
|
|
|
|||
|
|
@ -43,19 +43,19 @@ public class StackBlurManager {
|
|||
/**
|
||||
* Resized original image
|
||||
*/
|
||||
private final Bitmap _image;
|
||||
private final Bitmap image;
|
||||
|
||||
/**
|
||||
* Most recent result of blurring
|
||||
*/
|
||||
@Nullable
|
||||
private Bitmap _result;
|
||||
private Bitmap result;
|
||||
|
||||
/**
|
||||
* Method of blurring
|
||||
*/
|
||||
@NonNull
|
||||
private final BlurProcess _blurProcess;
|
||||
private final BlurProcess blurProcess;
|
||||
|
||||
/**
|
||||
* Constructor method (basic initialization and construction of the pixel array)
|
||||
|
|
@ -63,19 +63,20 @@ public class StackBlurManager {
|
|||
* @param image The image that will be analysed
|
||||
*/
|
||||
public StackBlurManager(@NonNull Bitmap image) {
|
||||
_image = Util.getResizedBitmap(image, 500, 500, false);
|
||||
_blurProcess = new JavaBlurProcess();
|
||||
// resize Bitmap to prevent OOM and OOB exceptions and increase the performance
|
||||
this.image = Util.getResizedBitmap(image, 500, 500, false);
|
||||
blurProcess = new JavaBlurProcess();
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the image on the given radius. Radius must be at least 1
|
||||
*
|
||||
* @param radius
|
||||
* @param radius the blur radius
|
||||
*/
|
||||
@Nullable
|
||||
public Bitmap process(int radius) {
|
||||
_result = _blurProcess.blur(_image, radius);
|
||||
return _result;
|
||||
result = blurProcess.blur(image, radius);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -85,6 +86,6 @@ public class StackBlurManager {
|
|||
*/
|
||||
@Nullable
|
||||
public Bitmap returnBlurredImage() {
|
||||
return _result;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue