This commit is contained in:
2025-01-24 19:20:57 +08:00
parent 7bd0c2b82a
commit 11e4d7a9f2
3 changed files with 8 additions and 25 deletions

View File

@@ -196,23 +196,6 @@ class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
'dark' => ThemeMode.dark, 'dark' => ThemeMode.dark,
_ => ThemeMode.system _ => ThemeMode.system
}, },
locale: () {
var lang = appdata.settings['language'];
if (lang == 'system') {
return null;
}
return switch (lang) {
'zh-CN' => const Locale('zh', 'CN'),
'zh-TW' => const Locale('zh', 'TW'),
'en-US' => const Locale('en'),
_ => null
};
}(),
supportedLocales: const [
Locale('en'),
Locale('zh', 'CN'),
Locale('zh', 'TW'),
],
builder: (context, widget) { builder: (context, widget) {
ErrorWidget.builder = (details) { ErrorWidget.builder = (details) {
Log.error("Unhandled Exception", Log.error("Unhandled Exception",

View File

@@ -39,12 +39,12 @@ class Image {
return image; return image;
} }
int getPixelAtIndex(int index) { Color getPixelAtIndex(int index) {
if (index < 0 || index >= _data.length) { if (index < 0 || index >= _data.length) {
throw ArgumentError( throw ArgumentError(
'Invalid argument: index must be in the range of [0, ${_data.length}).'); 'Invalid argument: index must be in the range of [0, ${_data.length}).');
} }
return _data[index]; return Color.fromValue(_data[index]);
} }
Image copyRange(int x, int y, int width, int height) { Image copyRange(int x, int y, int width, int height) {
@@ -184,11 +184,11 @@ class Color {
Color.fromValue(this.value); Color.fromValue(this.value);
int get r => (value >> 16) & 0xFF; int get r => value & 0xFF;
int get g => (value >> 8) & 0xFF; int get g => (value >> 8) & 0xFF;
int get b => value & 0xFF; int get b => (value >> 16) & 0xFF;
int get a => (value >> 24) & 0xFF; int get a => (value >> 24) & 0xFF;
} }

View File

@@ -394,10 +394,10 @@ class PdfGenerator {
var height = image.height; var height = image.height;
data = Uint8List(width * height * 3); data = Uint8List(width * height * 3);
for (var i = 0; i < width * height; i++) { for (var i = 0; i < width * height; i++) {
var pixel = image.getPixelAtIndex(i); // RGBA var pixel = image.getPixelAtIndex(i);
data[i * 3] = pixel & 0xFF; // R data[i * 3] = pixel.r;
data[i * 3 + 1] = (pixel >> 8) & 0xFF; // G data[i * 3 + 1] = pixel.g;
data[i * 3 + 2] = (pixel >> 16) & 0xFF; // B data[i * 3 + 2] = pixel.b;
} }
data = tdeflCompressData(data, true, true, 9); data = tdeflCompressData(data, true, true, 9);
return (width: width, height: height, data: data); return (width: width, height: height, data: data);