-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unbundled Image encoders to their own classes, kept backward-compatib…
…ility methods
- Loading branch information
Showing
23 changed files
with
393 additions
and
266 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#include <jni.h> | ||
#include "SkData.h" | ||
#include "SkImage.h" | ||
#include "SkJpegEncoder.h" | ||
|
||
extern "C" JNIEXPORT jlong JNICALL Java_io_github_humbleui_skija_EncoderJPEG__1nEncode | ||
(JNIEnv* env, jclass jclass, jlong ctxPtr, jlong imagePtr, jint quality, jint alphaMode, jint downsampleMode) { | ||
GrDirectContext* ctx = reinterpret_cast<GrDirectContext*>(static_cast<uintptr_t>(ctxPtr)); | ||
SkImage* image = reinterpret_cast<SkImage*>(static_cast<uintptr_t>(imagePtr)); | ||
SkJpegEncoder::Options opts {quality, (SkJpegEncoder::Downsample) downsampleMode, (SkJpegEncoder::AlphaOption) alphaMode}; | ||
sk_sp<SkData> data = SkJpegEncoder::Encode(ctx, image, opts); | ||
return reinterpret_cast<jlong>(data.release()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include <jni.h> | ||
#include "SkData.h" | ||
#include "SkImage.h" | ||
#include "SkPngEncoder.h" | ||
|
||
extern "C" JNIEXPORT jlong JNICALL Java_io_github_humbleui_skija_EncoderPNG__1nEncode | ||
(JNIEnv* env, jclass jclass, jlong ctxPtr, jlong imagePtr, jint flagsInt, jint zlibLevel) { | ||
GrDirectContext* ctx = reinterpret_cast<GrDirectContext*>(static_cast<uintptr_t>(ctxPtr)); | ||
SkImage* image = reinterpret_cast<SkImage*>(static_cast<uintptr_t>(imagePtr)); | ||
SkPngEncoder::FilterFlag flags = static_cast<SkPngEncoder::FilterFlag>(flagsInt); | ||
SkPngEncoder::Options opts {flags, zlibLevel}; | ||
sk_sp<SkData> data = SkPngEncoder::Encode(ctx, image, opts); | ||
return reinterpret_cast<jlong>(data.release()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#include <jni.h> | ||
#include "SkData.h" | ||
#include "SkImage.h" | ||
#include "SkWebpEncoder.h" | ||
|
||
extern "C" JNIEXPORT jlong JNICALL Java_io_github_humbleui_skija_EncoderWEBP__1nEncode | ||
(JNIEnv* env, jclass jclass, jlong ctxPtr, jlong imagePtr, jint compressionMode, jfloat quality) { | ||
GrDirectContext* ctx = reinterpret_cast<GrDirectContext*>(static_cast<uintptr_t>(ctxPtr)); | ||
SkImage* image = reinterpret_cast<SkImage*>(static_cast<uintptr_t>(imagePtr)); | ||
SkWebpEncoder::Options opts {(SkWebpEncoder::Compression) compressionMode, quality}; | ||
sk_sp<SkData> data = SkWebpEncoder::Encode(ctx, image, opts); | ||
return reinterpret_cast<jlong>(data.release()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package io.github.humbleui.skija; | ||
|
||
public enum EncodeJPEGAlphaMode { | ||
IGNORE, | ||
BLEND_ON_BLACK | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package io.github.humbleui.skija; | ||
|
||
public enum EncodeJPEGDownsampleMode { | ||
/** | ||
* Reduction by a factor of two in both the horizontal and vertical directions. | ||
*/ | ||
DS_420, | ||
|
||
/** | ||
* Reduction by a factor of two in the horizontal direction. | ||
*/ | ||
DS_422, | ||
|
||
/** | ||
* No downsampling. | ||
*/ | ||
DS_444 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package io.github.humbleui.skija; | ||
|
||
import org.jetbrains.annotations.*; | ||
|
||
public enum EncodePNGFilterFlag { | ||
ZERO (0x00), | ||
NONE (0x08), | ||
SUB (0x10), | ||
UP (0x20), | ||
AVG (0x40), | ||
PAETH (0x80), | ||
ALL (0x08 | 0x10 | 0x20 | 0x40 | 0x80); | ||
|
||
@ApiStatus.Internal public final int _value; | ||
|
||
EncodePNGFilterFlag(int value) { | ||
this._value = value; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package io.github.humbleui.skija; | ||
|
||
import org.jetbrains.annotations.*; | ||
|
||
public enum EncodeWEBPCompressionMode { | ||
LOSSY, | ||
LOSSLESS | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.