Skip to content

Commit

Permalink
Update WebPDecoderJN to 1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinrobot committed Jul 17, 2023
1 parent bc6dbe8 commit fadc45f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ dependencies {
modImplementation "com.twelvemonkeys.imageio:imageio-webp:3.9.4"

// WebP support for animated WebP using official Google's native library
modImplementation "com.github.Vinrobot.WebPDecoderJN:lib:v1.2"
modImplementation "com.github.Vinrobot.WebPDecoderJN:lib:1.3"
}

processResources {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import net.vinrobot.mcemote.client.providers.STVGlobalEmoteProvider;
import net.vinrobot.mcemote.client.providers.STVUserEmoteProvider;
import net.vinrobot.mcemote.client.text.EmotesManager;
import webpdecoderjn.WebPDecoder;
import webpdecoderjn.WebPLoader;

import java.io.IOException;
import java.util.ArrayList;
Expand All @@ -22,7 +22,7 @@ public class MinecraftEmoteModClient implements ClientModInitializer {
public void onInitializeClient() {
// This entrypoint is suitable for setting up client-specific logic, such as rendering.
try {
WebPDecoder.init();
WebPLoader.init();
} catch (IOException e) {
MinecraftEmoteMod.LOGGER.error("Failed to initialize WebPDecoder", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import net.vinrobot.mcemote.api.seventv.EmoteHost;
import net.vinrobot.mcemote.client.helpers.NativeImageHelper;
import webpdecoderjn.WebPDecoder;
import webpdecoderjn.WebPImage;
import webpdecoderjn.WebPImageFrame;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
Expand Down Expand Up @@ -57,13 +59,12 @@ public Frame[] loadFrames() throws IOException {
final EmoteFile file = getFile();
final String url = "https:" + host.url() + "/" + file.name();
if (data.animated()) {
final byte[] bytes = WebPDecoder.getBytesFromURL(new URL(url));
final WebPDecoder.WebPImage image = WebPDecoder.decode(bytes);
final WebPImage image = WebPDecoder.decode(new URL(url));

final int frameCount = image.frames.size();
final Frame[] frames = new Frame[frameCount];
for (int i = 0; i < frameCount; ++i) {
final WebPDecoder.WebPImageFrame frame = image.frames.get(i);
final WebPImageFrame frame = image.frames.get(i);
final NativeImage nativeImage = NativeImageHelper.fromBufferedImage(frame.img);
frames[i] = new Frame(nativeImage, Duration.ofMillis(frame.delay));
}
Expand Down

0 comments on commit fadc45f

Please sign in to comment.