Browse Source

0.2.1

master
asie 1 year ago
parent
commit
3b56f1d36f

+ 1
- 1
build.gradle View File

@@ -17,7 +17,7 @@ apply plugin: 'net.minecraftforge.gradle.forge'
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'net.minecrell.licenser'
version = "0.2.0"
version = "0.2.1"
group = "pl.asie.splashanimation" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "SplashAnimation"

+ 3
- 0
docs/changelog/0.2.1.txt View File

@@ -0,0 +1,3 @@
Bugs fixed:

* Loading all images twice, nullifying the point of threaded frame loading.

+ 32
- 17
src/main/java/pl/asie/splashanimation/SplashAnimationRenderer.java View File

@@ -45,8 +45,13 @@ public class SplashAnimationRenderer {
private int lastImage = 0;
private boolean run = true;

public ImageProvider(Collection<File> files) {
public ImageProvider(Collection<File> files, BufferedImage... initialImages) {
fileList.addAll(files);
imageList.addAll(Arrays.asList(initialImages));
lastImage = imageList.size();
for (int i = 0; i < lastImage; i++) {
fileList.remove();
}
// ~1 second
bufferSize = Math.max(5, (int) Math.ceil(1 / frameDelay));
}
@@ -173,26 +178,32 @@ public class SplashAnimationRenderer {
}

List<File> imageFiles = new ArrayList<>();
{
BufferedImage image = null;

for (Map.Entry<Integer, File> entry : files.entrySet()) {
imageFiles.add(entry.getValue());

if (width < 0 || height < 0) {
try {
image = ImageIO.read(entry.getValue());
width = image.getWidth();
height = image.getHeight();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}

for (Map.Entry<Integer, File> entry : files.entrySet()) {
imageFiles.add(entry.getValue());
try {
BufferedImage image = ImageIO.read(entry.getValue());
width = image.getWidth();
height = image.getHeight();
} catch (Exception e) {
throw new RuntimeException(e);
if (imageFiles.isEmpty() || image == null || width < 0 || height < 0) {
System.err.println("Found no images!");
stage = 2;
return;
}
}

if (imageFiles.isEmpty() || width < 0 || height < 0) {
System.err.println("Found no images!");
stage = 2;
return;
frameCount = imageFiles.size();
provider = new ImageProvider(imageFiles, image);
}

frameCount = imageFiles.size();
provider = new ImageProvider(imageFiles);
providerThread = new Thread(provider);
providerThread.start();

@@ -231,6 +242,10 @@ public class SplashAnimationRenderer {
if (i != uploadedFrame) {
BufferedImage img = provider.getImage(i);

if (img.getWidth() > animTexWidth || img.getHeight() > animTexHeight) {
throw new RuntimeException("Splash frames not the same size!");
}

int[] t = img.getRGB(0, 0, img.getWidth(), img.getHeight(), null, 0, img.getWidth());
IntBuffer buf = BufferUtils.createIntBuffer(t.length);
buf.put(t);

Loading…
Cancel
Save