Build Android (FCM) / build-android-fcm (push) Canceled after 0s
Build Android / build-android (push) Canceled after 0s
Build iOS / build-ios (push) Canceled after 0s
Build Linux / build-linux (push) Canceled after 0s
Build macOS / build-macos (push) Canceled after 0s
Build Windows / build-windows (push) Canceled after 0s
Release (main) / android (oneme) (push) Canceled after 0s
Release (main) / android (qlyra) (push) Canceled after 0s
Release (main) / windows (push) Canceled after 0s
Release (main) / linux (push) Canceled after 0s
Release (main) / macos (push) Canceled after 0s
Release (main) / ios (push) Canceled after 0s
Release (main) / release (push) Canceled after 0s
35 lines
907 B
Dart
35 lines
907 B
Dart
import 'dart:io';
|
|
import 'dart:ui' as ui;
|
|
|
|
import 'package:path/path.dart' as p;
|
|
import 'package:path_provider/path_provider.dart';
|
|
|
|
import '../utils/image_utils.dart';
|
|
|
|
Future<File?> rasterPictureToJpegFile(
|
|
ui.Picture picture,
|
|
int width,
|
|
int height, {
|
|
required String prefix,
|
|
void Function()? onPictureDisposed,
|
|
}) async {
|
|
final rendered = await picture.toImage(width, height);
|
|
picture.dispose();
|
|
onPictureDisposed?.call();
|
|
final bd = await rendered.toByteData(format: ui.ImageByteFormat.rawRgba);
|
|
rendered.dispose();
|
|
if (bd == null) return null;
|
|
|
|
final jpeg = await encodeRgbaToJpeg(bd.buffer.asUint8List(), width, height);
|
|
if (jpeg == null) return null;
|
|
final dir = await getTemporaryDirectory();
|
|
final out = File(
|
|
p.join(
|
|
dir.path,
|
|
'qlyra_${prefix}_${DateTime.now().microsecondsSinceEpoch}.jpg',
|
|
),
|
|
);
|
|
await out.writeAsBytes(jpeg);
|
|
return out;
|
|
}
|