From d8cbb07ae4b0926102eeaf8422b8fcca306ec72f Mon Sep 17 00:00:00 2001 From: Emerson Cloud Date: Mon, 28 Jan 2019 16:46:12 -0500 Subject: [PATCH 1/5] Fix JpegView renderJpeg --- jpegkit/src/main/cpp/jpegkit/render.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jpegkit/src/main/cpp/jpegkit/render.cpp b/jpegkit/src/main/cpp/jpegkit/render.cpp index 2a470f2..390ca61 100644 --- a/jpegkit/src/main/cpp/jpegkit/render.cpp +++ b/jpegkit/src/main/cpp/jpegkit/render.cpp @@ -6,7 +6,7 @@ #include extern "C" JNIEXPORT void JNICALL -Java_com_jpegkit_JpegView_renderJpeg(JNIEnv *env, jobject obj, jobject surface, jlong allocHandle, jlong jpegSize, jint width, jint height) { +Java_jpegkit_JpegView_renderJpeg(JNIEnv *env, jobject obj, jobject surface, jlong allocHandle, jlong jpegSize, jint width, jint height) { ANativeWindow *window = ANativeWindow_fromSurface(env, surface); ANativeWindow_setBuffersGeometry(window, width, height, WINDOW_FORMAT_RGBA_8888); ANativeWindow_Buffer windowBuffer; From 413ac78b925f497b125d28c4b9c016b026981a42 Mon Sep 17 00:00:00 2001 From: Emerson Cloud Date: Mon, 28 Jan 2019 16:48:06 -0500 Subject: [PATCH 2/5] Un-deprecate Jpeg and related classes --- jpegkit/src/main/java/jpegkit/Jpeg.java | 1 - jpegkit/src/main/java/jpegkit/JpegFile.java | 1 - jpegkit/src/main/java/jpegkit/JpegImageView.java | 1 - jpegkit/src/main/java/jpegkit/JpegKit.java | 1 - 4 files changed, 4 deletions(-) diff --git a/jpegkit/src/main/java/jpegkit/Jpeg.java b/jpegkit/src/main/java/jpegkit/Jpeg.java index 6a0b81c..8673fe6 100644 --- a/jpegkit/src/main/java/jpegkit/Jpeg.java +++ b/jpegkit/src/main/java/jpegkit/Jpeg.java @@ -7,7 +7,6 @@ import java.nio.ByteBuffer; -@Deprecated public class Jpeg implements Parcelable { private static final Object sJniLock = new Object(); diff --git a/jpegkit/src/main/java/jpegkit/JpegFile.java b/jpegkit/src/main/java/jpegkit/JpegFile.java index 03261cc..f00c35c 100644 --- a/jpegkit/src/main/java/jpegkit/JpegFile.java +++ b/jpegkit/src/main/java/jpegkit/JpegFile.java @@ -9,7 +9,6 @@ import java.io.FileOutputStream; import java.io.IOException; -@Deprecated public class JpegFile extends Jpeg { private File mJpegFile; diff --git a/jpegkit/src/main/java/jpegkit/JpegImageView.java b/jpegkit/src/main/java/jpegkit/JpegImageView.java index 5124532..5867817 100644 --- a/jpegkit/src/main/java/jpegkit/JpegImageView.java +++ b/jpegkit/src/main/java/jpegkit/JpegImageView.java @@ -8,7 +8,6 @@ import android.util.AttributeSet; import android.widget.ImageView; -@Deprecated public class JpegImageView extends ImageView { private Jpeg mJpeg; diff --git a/jpegkit/src/main/java/jpegkit/JpegKit.java b/jpegkit/src/main/java/jpegkit/JpegKit.java index 391315f..8fcdec7 100644 --- a/jpegkit/src/main/java/jpegkit/JpegKit.java +++ b/jpegkit/src/main/java/jpegkit/JpegKit.java @@ -9,7 +9,6 @@ import java.io.FileOutputStream; import java.io.IOException; -@Deprecated public final class JpegKit { private static void writeFile(Jpeg jpeg, File file) throws IOException { From 9e758aed648ea057a0d417700d13cd45fbdeae46 Mon Sep 17 00:00:00 2001 From: Emerson Cloud Date: Tue, 29 Jan 2019 09:17:29 -0500 Subject: [PATCH 3/5] Update README --- README.md | 62 ++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 48 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 2acb4fb..530567b 100644 --- a/README.md +++ b/README.md @@ -27,49 +27,73 @@ JpegKit bridges the libjpeg-turbo C++ library into android and wraps it with an This is all done without decoding the JPEG to RGB. All operations on the JPEG are done in C++ space and does not touch the Java memory, allowing you to work with extremely large JPEGs without the risk of an `OutOfMemoryException`. +## The State Of The Union +We've been working on a major update to the JpegKit project that we will dub `v0.3.0`. This release separates concerns away from the single Jpeg class to several classes, each handling different functions of JpegKit. + +In a previous release we deprecated the Jpeg class with the intention of having the new functionality ready for the spotlight. + +However we discovered some bugs and issues after the initial release. Until `v0.3.0` is finalized, we've un-deprecated that Jpeg class and its other supporting classes. Below is the intended Setup and Usage for `v0.2.2`. + ## Setup Add __JpegKit__ to the dependencies block in your `app` level `build.gradle`: ```groovy -compile 'com.camerakit:jpegkit:0.2.1' +compile 'com.camerakit:jpegkit:0.2.2' ``` ## Usage -JpegKit currently expects a JPEG parameter in the form of a `byte[]`. In the future you'll be able to just pass a file. +The core of JpegKit is the Jpeg class. When creating an object of type `Jpeg`, the constructor expects a `byte[]`. In the future you'll be able to pass just a file. -First, create a `JpegTransformer`: +### Constructor +First, create a `Jpeg`: ```java -byte[] jpeg = ...; -JpegTransformer jpegTransformer = new JpegTransformer(jpeg); +byte[] jpegBytes = ...; +Jpeg mJpeg = new Jpeg(jpegBytes); ``` +One can then transform this Jpeg object with the transformations listed in the **Transformations** section below. + + +### Jpeg result After you perform your transformations, you can get a new JPEG `byte[]` back: ```java -byte[] newJpeg = jpegTransformer.getJpeg(); +byte[] newJpegBytes = mJpeg.getJpeg(); ``` The `getJpeg()` call can only be used once. At this point our C++ libjpeg-turbo wrapper encodes the new JPEG and also disposes of the original and clears any other memory it used. Transformations are performed in C++ right when you make the method call, as opposed to doing all after you finish with `getJpeg()`. The transformations will be applied in the order you make the method calls. -### MetaData +## JpegImageView + +`JpegImageView` is a view to display JpegKit's `Jpeg` objects. + +Create a `JpegImageView` in **xml** as follows. -You can currently retrieve a JPEGs width and height. This only decodes the JPEGs header information and is very fast. +```xml + +``` + +Access and set the JPEG from your Activity as follows. ```java -int width = jpegTransformer.getWidth(); -int height = jpegTransformer.getHeight(); +JpegImageView jpegView = findViewById(R.id.jpegView) +jpegView.setJpeg(mJpeg); ``` +## Transformations ### Rotate Acceptable parameters are `90`, `180`, or `270`. ```java -jpegTransformer.rotate(90); +mJpeg.rotate(int rotation); ``` ### Flip Horizontal or Vertical @@ -77,13 +101,13 @@ jpegTransformer.rotate(90); Flip horizontal: ```java -jpegTransformer.flipHorizontal(); +mJpeg.flipHorizontal(); ``` Flip horizontal: ```java -jpegTransformer.flipVertical(); +mJpeg.flipVertical(); ``` ### Crop @@ -92,9 +116,19 @@ Crop extends an `android.graphics.Rect`. ```java Rect cropRect = new Rect(left, top, right, bottom); -jpegTransformer.crop(cropRect); +mJpeg.crop(cropRect); ``` + +## MetaData + +You can retrieve a JPEGs width, height and size. This only decodes the JPEGs header information and is very fast. + +```java +int width = mJpeg.getWidth(); +int height = mJpeg.getHeight(); +long size = mJpeg.getJpegSize(); +``` --- ## License From 3986dba9062110da813d1bbc2268a02028e05f7c Mon Sep 17 00:00:00 2001 From: Emerson Cloud Date: Tue, 29 Jan 2019 09:50:06 -0500 Subject: [PATCH 4/5] Add import statements to README --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 530567b..073bd68 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,10 @@ The core of JpegKit is the Jpeg class. When creating an object of type `Jpeg`, t First, create a `Jpeg`: ```java +import jpegkit.Jpeg; + +//... + byte[] jpegBytes = ...; Jpeg mJpeg = new Jpeg(jpegBytes); ``` @@ -83,6 +87,10 @@ Create a `JpegImageView` in **xml** as follows. Access and set the JPEG from your Activity as follows. ```java +import jpegkit.JpegImageView; + +//... + JpegImageView jpegView = findViewById(R.id.jpegView) jpegView.setJpeg(mJpeg); ``` From dd4745c28f389c2498b276a445e4e55cc3754dbf Mon Sep 17 00:00:00 2001 From: Emerson Cloud Date: Tue, 29 Jan 2019 09:50:33 -0500 Subject: [PATCH 5/5] Increment version --- app/build.gradle | 2 +- jpegkit/build.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 452c001..ee6a069 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -11,7 +11,7 @@ android { minSdkVersion 15 targetSdkVersion 28 versionCode 1 - versionName '0.2.1' + versionName '0.2.2' externalNativeBuild { cmake { cppFlags '' diff --git a/jpegkit/build.gradle b/jpegkit/build.gradle index 962b937..3072657 100644 --- a/jpegkit/build.gradle +++ b/jpegkit/build.gradle @@ -111,7 +111,7 @@ task deployRelease { } group = 'com.camerakit' -version = '0.2.1' +version = '0.2.2' install { repositories.mavenInstaller {