For one, we have already switched to RGBA some time ago, so the name was technically incorrect already. But the main reason is that we'll want to use them for depth maps as well (and potentially maybe even for HDR images if that's possible with canvas?).
41 lines
1.2 KiB
Java
41 lines
1.2 KiB
Java
package com.replaymod.render.frame;
|
|
|
|
import com.replaymod.render.rendering.Frame;
|
|
import de.johni0702.minecraft.gui.utils.lwjgl.ReadableDimension;
|
|
import org.apache.commons.lang3.Validate;
|
|
|
|
import java.nio.ByteBuffer;
|
|
|
|
public class BitmapFrame implements Frame {
|
|
private final int frameId;
|
|
private final ReadableDimension size;
|
|
private final int bytesPerPixel;
|
|
private final ByteBuffer byteBuffer;
|
|
|
|
public BitmapFrame(int frameId, ReadableDimension size, int bytesPerPixel, ByteBuffer byteBuffer) {
|
|
Validate.isTrue(size.getWidth() * size.getHeight() * bytesPerPixel == byteBuffer.remaining(),
|
|
"Buffer size is %d (cap: %d) but should be %d",
|
|
byteBuffer.remaining(), byteBuffer.capacity(), size.getWidth() * size.getHeight() * bytesPerPixel);
|
|
this.frameId = frameId;
|
|
this.size = size;
|
|
this.bytesPerPixel = bytesPerPixel;
|
|
this.byteBuffer = byteBuffer;
|
|
}
|
|
|
|
public int getFrameId() {
|
|
return this.frameId;
|
|
}
|
|
|
|
public ReadableDimension getSize() {
|
|
return this.size;
|
|
}
|
|
|
|
public int getBytesPerPixel() {
|
|
return bytesPerPixel;
|
|
}
|
|
|
|
public ByteBuffer getByteBuffer() {
|
|
return this.byteBuffer;
|
|
}
|
|
}
|