Merge pull request #2255 from fufesou/fix_win_cursor_color

fix win cursor color
This commit is contained in:
RustDesk 2022-11-21 19:41:16 +08:00 committed by GitHub
commit 1bddc26b5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -975,7 +975,7 @@ class CursorModel with ChangeNotifier {
final image = await img.decodeImageFromPixels(
rgba, width, height, ui.PixelFormat.rgba8888);
_image = image;
if (await _updateCache(image, id, width, height)) {
if (await _updateCache(rgba, image, id, width, height)) {
_images[id] = Tuple3(image, _hotx, _hoty);
} else {
_hotx = 0;
@ -989,22 +989,25 @@ class CursorModel with ChangeNotifier {
}
}
Future<bool> _updateCache(ui.Image image, int id, int w, int h) async {
ui.ImageByteFormat imgFormat = ui.ImageByteFormat.png;
Future<bool> _updateCache(
Uint8List rgba, ui.Image image, int id, int w, int h) async {
Uint8List? data;
img2.Image? imgOrigin;
if (Platform.isWindows) {
imgFormat = ui.ImageByteFormat.rawRgba;
}
ByteData? imgBytes = await image.toByteData(format: imgFormat);
imgOrigin = img2.Image.fromBytes(w, h, rgba, format: img2.Format.rgba);
data = imgOrigin.getBytes(format: img2.Format.bgra);
} else {
ByteData? imgBytes =
await image.toByteData(format: ui.ImageByteFormat.png);
if (imgBytes == null) {
return false;
}
Uint8List? data = imgBytes.buffer.asUint8List();
data = imgBytes.buffer.asUint8List();
}
_cache = CursorData(
peerId: this.id,
id: id,
image: Platform.isWindows ? img2.Image.fromBytes(w, h, data) : null,
image: imgOrigin,
scale: 1.0,
data: data,
hotxOrigin: _hotx,