Skip to content

Commit 9e758ae

Browse files
committed
Update README
1 parent 413ac78 commit 9e758ae

File tree

1 file changed

+48
-14
lines changed

1 file changed

+48
-14
lines changed

README.md

Lines changed: 48 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,63 +27,87 @@ 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+
byte[] jpegBytes = ...;
53+
Jpeg mJpeg = new Jpeg(jpegBytes);
4654
```
4755

56+
One can then transform this Jpeg object with the transformations listed in the **Transformations** section below.
57+
58+
59+
### Jpeg result
4860
After you perform your transformations, you can get a new JPEG `byte[]` back:
4961

5062
```java
51-
byte[] newJpeg = jpegTransformer.getJpeg();
63+
byte[] newJpegBytes = mJpeg.getJpeg();
5264
```
5365

5466
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.
5567

5668
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.
5769

58-
### MetaData
70+
## JpegImageView
71+
72+
`JpegImageView` is a view to display JpegKit's `Jpeg` objects.
73+
74+
Create a `JpegImageView` in **xml** as follows.
5975

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

6285
```java
63-
int width = jpegTransformer.getWidth();
64-
int height = jpegTransformer.getHeight();
86+
JpegImageView jpegView = findViewById(R.id.jpegView)
87+
jpegView.setJpeg(mJpeg);
6588
```
6689

90+
## Transformations
6791
### Rotate
6892

6993
Acceptable parameters are `90`, `180`, or `270`.
7094

7195
```java
72-
jpegTransformer.rotate(90);
96+
mJpeg.rotate(int rotation);
7397
```
7498

7599
### Flip Horizontal or Vertical
76100

77101
Flip horizontal:
78102

79103
```java
80-
jpegTransformer.flipHorizontal();
104+
mJpeg.flipHorizontal();
81105
```
82106

83107
Flip horizontal:
84108

85109
```java
86-
jpegTransformer.flipVertical();
110+
mJpeg.flipVertical();
87111
```
88112

89113
### Crop
@@ -92,9 +116,19 @@ Crop extends an `android.graphics.Rect`.
92116

93117
```java
94118
Rect cropRect = new Rect(left, top, right, bottom);
95-
jpegTransformer.crop(cropRect);
119+
mJpeg.crop(cropRect);
96120
```
97121

122+
123+
## MetaData
124+
125+
You can retrieve a JPEGs width, height and size. This only decodes the JPEGs header information and is very fast.
126+
127+
```java
128+
int width = mJpeg.getWidth();
129+
int height = mJpeg.getHeight();
130+
long size = mJpeg.getJpegSize();
131+
```
98132
---
99133

100134
## License

0 commit comments

Comments
 (0)