add flipY argument to pixelBufferToPng
This commit is contained in:
@@ -64,7 +64,11 @@ Future<Uint8List> pixelBufferToBmp(Uint8List pixelBuffer, int width, int height,
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<Uint8List> pixelBufferToPng(Uint8List pixelBuffer, int width, int height,
|
Future<Uint8List> pixelBufferToPng(Uint8List pixelBuffer, int width, int height,
|
||||||
{bool hasAlpha = true, bool isFloat = false, bool linearToSrgb = false, bool invertAces = false}) async {
|
{bool hasAlpha = true,
|
||||||
|
bool isFloat = false,
|
||||||
|
bool linearToSrgb = false,
|
||||||
|
bool invertAces = false,
|
||||||
|
bool flipY = false}) async {
|
||||||
final image = img.Image(width: width, height: height);
|
final image = img.Image(width: width, height: height);
|
||||||
|
|
||||||
Float32List? floatData;
|
Float32List? floatData;
|
||||||
@@ -75,7 +79,12 @@ Future<Uint8List> pixelBufferToPng(Uint8List pixelBuffer, int width, int height,
|
|||||||
|
|
||||||
for (int y = 0; y < height; y++) {
|
for (int y = 0; y < height; y++) {
|
||||||
for (int x = 0; x < width; x++) {
|
for (int x = 0; x < width; x++) {
|
||||||
final int pixelIndex = (y * width + x) * (hasAlpha ? 4 : 3);
|
late int pixelIndex;
|
||||||
|
if (flipY) {
|
||||||
|
pixelIndex = ((height - 1 - y) * width + x) * (hasAlpha ? 4 : 3);
|
||||||
|
} else {
|
||||||
|
pixelIndex = (y * width + x) * (hasAlpha ? 4 : 3);
|
||||||
|
}
|
||||||
|
|
||||||
double r, g, b, a;
|
double r, g, b, a;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user