Skip to content

Commit 01a782f

Browse files
authored
Merge pull request #8 from CameraKit/v0.2.2
v0.2.2
2 parents 7c03ec2 + dd4745c commit 01a782f

File tree

8 files changed

+59
-21
lines changed

8 files changed

+59
-21
lines changed

README.md

Lines changed: 56 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,63 +27,95 @@ JpegKit bridges the libjpeg-turbo C++ library into android and wraps it with an
2727

2828
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`.
2929

30+
## The State Of The Union
31+
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.
32+
33+
In a previous release we deprecated the Jpeg class with the intention of having the new functionality ready for the spotlight.
34+
35+
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`.
36+
3037
## Setup
3138
Add __JpegKit__ to the dependencies block in your `app` level `build.gradle`:
3239

3340
```groovy
34-
compile 'com.camerakit:jpegkit:0.2.1'
41+
compile 'com.camerakit:jpegkit:0.2.2'
3542
```
3643

3744
## Usage
3845

39-
JpegKit currently expects a JPEG parameter in the form of a `byte[]`. In the future you'll be able to just pass a file.
46+
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.
4047

41-
First, create a `JpegTransformer`:
48+
### Constructor
49+
First, create a `Jpeg`:
4250

4351
```java
44-
byte[] jpeg = ...;
45-
JpegTransformer jpegTransformer = new JpegTransformer(jpeg);
52+
import jpegkit.Jpeg;
53+
54+
//...
55+
56+
byte[] jpegBytes = ...;
57+
Jpeg mJpeg = new Jpeg(jpegBytes);
4658
```
4759

60+
One can then transform this Jpeg object with the transformations listed in the **Transformations** section below.
61+
62+
63+
### Jpeg result
4864
After you perform your transformations, you can get a new JPEG `byte[]` back:
4965

5066
```java
51-
byte[] newJpeg = jpegTransformer.getJpeg();
67+
byte[] newJpegBytes = mJpeg.getJpeg();
5268
```
5369

5470
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.
5571

5672
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.
5773

58-
### MetaData
74+
## JpegImageView
75+
76+
`JpegImageView` is a view to display JpegKit's `Jpeg` objects.
77+
78+
Create a `JpegImageView` in **xml** as follows.
5979

60-
You can currently retrieve a JPEGs width and height. This only decodes the JPEGs header information and is very fast.
80+
```xml
81+
<jpegkit.JpegImageView
82+
android:id="@+id/jpegView"
83+
android:layout_width="200dp"
84+
android:layout_height="200dp" />
85+
```
86+
87+
Access and set the JPEG from your Activity as follows.
6188

6289
```java
63-
int width = jpegTransformer.getWidth();
64-
int height = jpegTransformer.getHeight();
90+
import jpegkit.JpegImageView;
91+
92+
//...
93+
94+
JpegImageView jpegView = findViewById(R.id.jpegView)
95+
jpegView.setJpeg(mJpeg);
6596
```
6697

98+
## Transformations
6799
### Rotate
68100

69101
Acceptable parameters are `90`, `180`, or `270`.
70102

71103
```java
72-
jpegTransformer.rotate(90);
104+
mJpeg.rotate(int rotation);
73105
```
74106

75107
### Flip Horizontal or Vertical
76108

77109
Flip horizontal:
78110

79111
```java
80-
jpegTransformer.flipHorizontal();
112+
mJpeg.flipHorizontal();
81113
```
82114

83115
Flip horizontal:
84116

85117
```java
86-
jpegTransformer.flipVertical();
118+
mJpeg.flipVertical();
87119
```
88120

89121
### Crop
@@ -92,9 +124,19 @@ Crop extends an `android.graphics.Rect`.
92124

93125
```java
94126
Rect cropRect = new Rect(left, top, right, bottom);
95-
jpegTransformer.crop(cropRect);
127+
mJpeg.crop(cropRect);
96128
```
97129

130+
131+
## MetaData
132+
133+
You can retrieve a JPEGs width, height and size. This only decodes the JPEGs header information and is very fast.
134+
135+
```java
136+
int width = mJpeg.getWidth();
137+
int height = mJpeg.getHeight();
138+
long size = mJpeg.getJpegSize();
139+
```
98140
---
99141

100142
## License

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ android {
1111
minSdkVersion 15
1212
targetSdkVersion 28
1313
versionCode 1
14-
versionName '0.2.1'
14+
versionName '0.2.2'
1515
externalNativeBuild {
1616
cmake {
1717
cppFlags ''

jpegkit/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ task deployRelease {
111111
}
112112

113113
group = 'com.camerakit'
114-
version = '0.2.1'
114+
version = '0.2.2'
115115

116116
install {
117117
repositories.mavenInstaller {

jpegkit/src/main/cpp/jpegkit/render.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <android/native_window_jni.h>
77

88
extern "C" JNIEXPORT void JNICALL
9-
Java_com_jpegkit_JpegView_renderJpeg(JNIEnv *env, jobject obj, jobject surface, jlong allocHandle, jlong jpegSize, jint width, jint height) {
9+
Java_jpegkit_JpegView_renderJpeg(JNIEnv *env, jobject obj, jobject surface, jlong allocHandle, jlong jpegSize, jint width, jint height) {
1010
ANativeWindow *window = ANativeWindow_fromSurface(env, surface);
1111
ANativeWindow_setBuffersGeometry(window, width, height, WINDOW_FORMAT_RGBA_8888);
1212
ANativeWindow_Buffer windowBuffer;

jpegkit/src/main/java/jpegkit/Jpeg.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import java.nio.ByteBuffer;
99

10-
@Deprecated
1110
public class Jpeg implements Parcelable {
1211

1312
private static final Object sJniLock = new Object();

jpegkit/src/main/java/jpegkit/JpegFile.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import java.io.FileOutputStream;
1010
import java.io.IOException;
1111

12-
@Deprecated
1312
public class JpegFile extends Jpeg {
1413

1514
private File mJpegFile;

jpegkit/src/main/java/jpegkit/JpegImageView.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import android.util.AttributeSet;
99
import android.widget.ImageView;
1010

11-
@Deprecated
1211
public class JpegImageView extends ImageView {
1312

1413
private Jpeg mJpeg;

jpegkit/src/main/java/jpegkit/JpegKit.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import java.io.FileOutputStream;
1010
import java.io.IOException;
1111

12-
@Deprecated
1312
public final class JpegKit {
1413

1514
private static void writeFile(Jpeg jpeg, File file) throws IOException {

0 commit comments

Comments
 (0)