mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-25 19:49:50 +01:00
rgba8888
This commit is contained in:
1 parent
92ef7f4020
commit
9236c54b4b
1 file changed
+26
-1
@@ -88,6 +88,7 @@ enum PvrChannelType {
|
||||
|
||||
enum ResolvedBitRatePixelFormat {
|
||||
R4G4B4A4,
|
||||
R8G8B8A8,
|
||||
R5G6B5A0,
|
||||
}
|
||||
|
||||
@@ -137,6 +138,27 @@ export class PvrReadStream extends ReadStream {
|
||||
};
|
||||
}
|
||||
|
||||
case ResolvedBitRatePixelFormat.R8G8B8A8: {
|
||||
const data = Buffer.alloc(pixelCount * 4);
|
||||
|
||||
times(pixelCount, (index) => {
|
||||
const buffer = this.consumeUint8Array(4);
|
||||
const bufferIndex = index * 4;
|
||||
|
||||
data[bufferIndex] = buffer[0]; // R
|
||||
data[bufferIndex + 1] = buffer[1]; // G
|
||||
data[bufferIndex + 2] = buffer[2]; // B
|
||||
data[bufferIndex + 3] = buffer[3]; // A
|
||||
});
|
||||
|
||||
return {
|
||||
data,
|
||||
width: header.width,
|
||||
height: header.height,
|
||||
channels: 4 as const,
|
||||
};
|
||||
}
|
||||
|
||||
case ResolvedBitRatePixelFormat.R5G6B5A0: {
|
||||
const data = Buffer.alloc(pixelCount * 3);
|
||||
|
||||
@@ -208,10 +230,13 @@ export class PvrReadStream extends ReadStream {
|
||||
if (pixelFormat.order === "rgba") {
|
||||
if (isEqual(pixelFormat.bitRates, [4, 4, 4, 4])) {
|
||||
return ResolvedBitRatePixelFormat.R4G4B4A4;
|
||||
} else
|
||||
} else if (isEqual(pixelFormat.bitRates, [8, 8, 8, 8])) {
|
||||
return ResolvedBitRatePixelFormat.R8G8B8A8;
|
||||
} else {
|
||||
throw new TypeError(
|
||||
`Unhandled rgba bit rate ${pixelFormat.bitRates.join(", ")}`,
|
||||
);
|
||||
}
|
||||
} else if (pixelFormat.order === "rgb\0") {
|
||||
if (isEqual(pixelFormat.bitRates, [5, 6, 5, 0])) {
|
||||
return ResolvedBitRatePixelFormat.R5G6B5A0;
|
||||
|
||||
Reference in new issue
Block a user