Skip to content

Commit 5ac401f

Browse files
committed
Add JpegFile manual reloading
1 parent ce6ea3e commit 5ac401f

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ private Jpeg() {
1717
}
1818

1919
public Jpeg(@NonNull byte[] jpegBytes) {
20+
mount(jpegBytes);
21+
}
22+
23+
protected void mount(byte[] jpegBytes) {
2024
synchronized (sJniLock) {
2125
mHandle = jniMount(jpegBytes);
2226
}

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class JpegFile extends Jpeg {
1313

1414
private File mJpegFile;
1515

16-
public JpegFile(@NonNull File jpegFile) throws IOException {
16+
public JpegFile(@NonNull final File jpegFile) throws IOException {
1717
super(dumpFile(jpegFile));
1818
mJpegFile = jpegFile;
1919
}
@@ -28,6 +28,12 @@ public void save() throws IOException {
2828
outputStream.close();
2929
}
3030

31+
public void reload() throws Exception {
32+
byte[] jpegBytes = dumpFile(mJpegFile);
33+
release();
34+
mount(jpegBytes);
35+
}
36+
3137
private static byte[] dumpFile(File file) throws IOException {
3238
FileInputStream inputStream = new FileInputStream(file);
3339
byte[] fileBytes = new byte[inputStream.available()];

0 commit comments

Comments
 (0)