Skip to content

Commit

Permalink
v0.0.13: fix image generation error when using "Bitmap.Config.RGB_565"
Browse files Browse the repository at this point in the history
  • Loading branch information
succlz123 committed Jun 16, 2019
1 parent f159544 commit b527b5c
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 32 deletions.
30 changes: 17 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ implementation 'com.bilibili:burst-linker:latest-version'

#### Build Environment

Android Studio 3.2.1
Android Studio 3.4.1

NDK r18
NDK r20

#### Basic usage

Expand Down Expand Up @@ -50,12 +50,12 @@ try {

#### Enable RenderScript Support

> This is an untested experimental feature
> This is an untested feature.
1. Git branch `/feature/render-script`
2. Gradle sync, It will generate the required ScriptC_*.cpp
3. Uncomment the line 64 of the /lib/CMakeLists.txt
4. Run
1. Choose the Git branch "/feature/render-script".
2. Sync Project with Gradle Files, It will generate the required file named "ScriptC_*.cpp".
3. Uncomment the line 64 of the "/lib/CMakeLists.txt".
4. Try this function.

### Linux & Mac

Expand All @@ -71,7 +71,7 @@ try {

3. Run
- `./BurstLinker 1000 1.jpg 2.jpg 3.jpg`
- See out.gif
- See the "out.gif"

### Windows

Expand All @@ -81,13 +81,13 @@ try {
- `cd /BurstLinker`
- `mkdir cmake-build-debug; cd cmake-build-debug`
- `cmake ..`
- Open BurstLinker.sln
- Open the "BurstLinker.sln"
- Solution Explorer -> BurstLinker -> Build

3. Run
- `cd Debug`
- `BurstLinker.exe 1000 1.jpg 2.jpg 3.jpg`
- See out.gif
- See the "out.gif"

## Samples

Expand Down Expand Up @@ -137,17 +137,21 @@ try {

![octree-floyd-steinberg](screenshot/octree-floyd-steinberg.gif)

### Encoding with transparent image
### Encodes images with transparent channels

- Original

![bilibili](screenshot/bilibili.png)

- Octree + No + Default (ARGB.a != 0)
- Octree + No + Default

Display all Alpha channels greater than 0. (ARGB.a != 0)

![bilibili-octree](screenshot/bilibili-octree-default.gif)

- Octree + No + Ignore translucency (ARGB.a == 255)
- Octree + No + Ignored translucency

Display only the Alpha channels equal to 255. (ARGB.a == 255)

![bilibili-octree](screenshot/bilibili-octree-ignore.gif)

Expand Down
4 changes: 2 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.novoda:bintray-release:0.8.1'
classpath 'com.android.tools.build:gradle:3.4.1'
classpath 'com.novoda:bintray-release:0.9.1'
}
}

Expand Down
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
1 change: 0 additions & 1 deletion android/lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ android {

externalNativeBuild {
cmake {
// abiFilters 'armeabi-v7a', 'x86'
// arguments "-DANDROID_ARM_NEON=TRUE"
// arguments "-DANDROID_ABI=armeabi-v7a with NEON"
arguments "-DANDROID_STL=c++_static"
Expand Down
2 changes: 1 addition & 1 deletion android/lib/src/main/cpp/BurstLinker.cpp

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions android/sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
testImplementation 'junit:junit:4.12'

implementation 'com.android.support:appcompat-v7:28.0.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* Created by succlz123 on 2017/9/7.
*/
public class MainActivity extends AppCompatActivity {
private static final String TAG = "gif";
private static final String TAG = "JAVA_BURSTLINKER";

private ImageView mDisplayImg;
private TextView mTimeTv;
Expand Down Expand Up @@ -57,7 +57,7 @@ private void encodeGIF() {
final Context context = MainActivity.this;

final Bitmap bitmap = loadBitmap(R.drawable.tcr);
int size = 0;
int count = 0;
int width = bitmap.getWidth();
int height = bitmap.getHeight();
final int delayMs = 1000;
Expand All @@ -67,12 +67,13 @@ private void encodeGIF() {
try {
burstLinker.init(width, height, mFilePath, 0, CPU_COUNT);
burstLinker.debugLog(true);
// select one to test
if (true) {
List<Bitmap> bitmaps = new ArrayList<>();
bitmaps.add(bitmap);
bitmaps.add(bitmap);
bitmaps.add(bitmap);
size = bitmaps.size();
count = bitmaps.size();
burstLinker.connect(bitmaps, BurstLinker.OCTREE_QUANTIZER,
BurstLinker.NO_DITHER, 0, 0, delayMs);
} else {
Expand All @@ -83,7 +84,7 @@ private void encodeGIF() {
for (int color : colors) {
p.setColor(color);
canvas.drawRect(0, 0, width, height, p);
size++;
count++;
burstLinker.connect(colorBitmap, BurstLinker.OCTREE_QUANTIZER,
BurstLinker.NO_DITHER, 0, 0, delayMs);
}
Expand All @@ -105,7 +106,8 @@ private void encodeGIF() {
file.delete();
}
} else {
mText = "width " + width + " height " + height + " size " + size + " time " + diff + "ms";
mText =
"width: " + width + " height: " + height + " count: " + count + " time: " + diff + "ms";
runOnUiThread(() -> Glide.with(context).load(mFilePath).into(mDisplayImg));
}
runOnUiThread(() -> {
Expand Down
2 changes: 1 addition & 1 deletion src/Logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#include <android/log.h>

#define LOG_TAG "BURSTLINKER"
#define LOG_TAG "JNI_BURSTLINKER"

#define LOGV(...) __android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG,__VA_ARGS__)
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG , LOG_TAG,__VA_ARGS__)
Expand Down
10 changes: 5 additions & 5 deletions src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ int main(int argc, char *argv[]) {
return 0;
}
if (processWidth != width || processHeight != height) {
std::cout << "Image is not the same width or height " << processFileName << std::endl;
std::cout << "The height and width of the front and back images do not match " << processFileName << std::endl;
stbi_image_free(processImage);
return 0;
}
Expand All @@ -133,10 +133,10 @@ int main(int argc, char *argv[]) {
g = processImage[index++];
b = processImage[index++];
} else if (n == 4) {
r = data[index++];
g = data[index++];
b = data[index++];
a = data[index++];
r = processImage[index++];
g = processImage[index++];
b = processImage[index++];
a = processImage[index++];
} else {
std::cout << "Unsupported images" << std::endl;
return 0;
Expand Down

0 comments on commit b527b5c

Please sign in to comment.