fix length of IDAT chunk
Before Width: | Height: | Size: 441 KiB After Width: | Height: | Size: 441 KiB |
Before Width: | Height: | Size: 2.3 MiB After Width: | Height: | Size: 2.3 MiB |
BIN
docs/simple.png
Before Width: | Height: | Size: 881 KiB After Width: | Height: | Size: 881 KiB |
BIN
docs/squares.png
Before Width: | Height: | Size: 620 KiB After Width: | Height: | Size: 620 KiB |
@ -1,6 +1,7 @@
|
||||
package eu.jonahbauer.raytracing.render;
|
||||
|
||||
import eu.jonahbauer.raytracing.render.canvas.Canvas;
|
||||
import eu.jonahbauer.raytracing.render.canvas.Image;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.*;
|
||||
@ -10,6 +11,7 @@ import java.nio.file.Path;
|
||||
import java.util.zip.CRC32;
|
||||
import java.util.zip.CheckedOutputStream;
|
||||
import java.util.zip.DeflaterOutputStream;
|
||||
import java.util.zip.InflaterInputStream;
|
||||
|
||||
public enum ImageFormat {
|
||||
PPM {
|
||||
@ -93,7 +95,7 @@ public enum ImageFormat {
|
||||
}
|
||||
|
||||
var bytes = baos.toByteArray();
|
||||
data.writeInt(bytes.length);
|
||||
data.writeInt(bytes.length - 4); // don't include type in length
|
||||
data.write(bytes);
|
||||
data.writeInt((int) crc.getChecksum().getValue());
|
||||
}
|
||||
|