encodePvr method
Implementation
Uint8List encodePvr(Image bitmap, {int format = PVR_AUTO}) {
final output = OutputBuffer();
late dynamic pvrtc;
if (format == PVR_AUTO) {
if (bitmap.channels == Channels.rgb) {
pvrtc = encodeRgb4Bpp(bitmap);
format = PVR_RGB_4BPP;
} else {
pvrtc = encodeRgba4Bpp(bitmap);
format = PVR_RGBA_4BPP;
}
} else if (format == PVR_RGB_2BPP) {
//pvrtc = encodeRgb2Bpp(bitmap);
pvrtc = encodeRgb4Bpp(bitmap);
} else if (format == PVR_RGBA_2BPP) {
//pvrtc = encodeRgba2Bpp(bitmap);
pvrtc = encodeRgba4Bpp(bitmap);
} else if (format == PVR_RGB_4BPP) {
pvrtc = encodeRgb4Bpp(bitmap);
} else if (format == PVR_RGBA_4BPP) {
pvrtc = encodeRgba4Bpp(bitmap);
}
const version = 55727696;
const flags = 0;
final pixelFormat = format;
const channelOrder = 0;
const colorSpace = 0;
const channelType = 0;
final height = bitmap.height;
final width = bitmap.width;
const depth = 1;
const numSurfaces = 1;
const numFaces = 1;
const mipmapCount = 1;
const metaDataSize = 0;
output.writeUint32(version);
output.writeUint32(flags);
output.writeUint32(pixelFormat);
output.writeUint32(channelOrder);
output.writeUint32(colorSpace);
output.writeUint32(channelType);
output.writeUint32(height);
output.writeUint32(width);
output.writeUint32(depth);
output.writeUint32(numSurfaces);
output.writeUint32(numFaces);
output.writeUint32(mipmapCount);
output.writeUint32(metaDataSize);
output.writeBytes(pvrtc as List<int>);
return output.getBytes() as Uint8List;
}