Skip to content

Commit

Permalink
1.0.2 fix memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeffrey Liu committed Jun 5, 2021
1 parent ca96e4c commit 86460a7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Using FSD
##### Dependencies
```groovy
dependencies {
compile 'com.github.jeffreyliu8:Native-Floyd-Steinberg-Dithering:1.0.1'
compile 'com.github.jeffreyliu8:Native-Floyd-Steinberg-Dithering:1.0.2'
}
```

Expand Down
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ dependencies {
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.3.0'

// implementation project(":floydsteinbergdithering")
implementation 'com.github.jeffreyliu8:Native-Floyd-Steinberg-Dithering:1.0.1'
implementation 'com.github.jeffreyliu8:Native-Floyd-Steinberg-Dithering:1.0.2'
}
9 changes: 8 additions & 1 deletion floydsteinbergdithering/src/main/cpp/fsdither.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ static void floydSteinberg(AndroidBitmapInfo *info, void *pixels) {
// set the new pixel back in
line[x] = newpixel;

int err = oldpixel - newpixel;
int err = (int)(oldpixel - newpixel);

if (x + 1 < w)
d[y][x + 1] = d[y][x + 1] + (int) (err * (7. / 16));
Expand All @@ -77,6 +77,13 @@ static void floydSteinberg(AndroidBitmapInfo *info, void *pixels) {

pixels = (char *) pixels + info->stride;
}

//Free each sub-array
for (int i = 0; i < info->height; ++i) {
delete[] d[i];
}
//Free the array of pointers
delete[] d;
}

static void global_mono(AndroidBitmapInfo *info, void *pixels) {
Expand Down

0 comments on commit 86460a7

Please sign in to comment.