mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-01-19 08:23:01 +08:00
move ImagePainter, and fix mobile drawImage quality
This commit is contained in:
parent
1f5d68ef22
commit
2a0c9699e8
@ -21,6 +21,7 @@ import '../../mobile/widgets/dialog.dart';
|
|||||||
import '../../models/model.dart';
|
import '../../models/model.dart';
|
||||||
import '../../models/platform_model.dart';
|
import '../../models/platform_model.dart';
|
||||||
import '../../common/shared_state.dart';
|
import '../../common/shared_state.dart';
|
||||||
|
import '../../utils/image.dart';
|
||||||
import '../widgets/remote_menubar.dart';
|
import '../widgets/remote_menubar.dart';
|
||||||
import '../widgets/kb_layout_type_chooser.dart';
|
import '../widgets/kb_layout_type_chooser.dart';
|
||||||
|
|
||||||
@ -685,40 +686,3 @@ class CursorPaint extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ImagePainter extends CustomPainter {
|
|
||||||
ImagePainter({
|
|
||||||
required this.image,
|
|
||||||
required this.x,
|
|
||||||
required this.y,
|
|
||||||
required this.scale,
|
|
||||||
});
|
|
||||||
|
|
||||||
ui.Image? image;
|
|
||||||
double x;
|
|
||||||
double y;
|
|
||||||
double scale;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void paint(Canvas canvas, Size size) {
|
|
||||||
if (image == null) return;
|
|
||||||
if (x.isNaN || y.isNaN) return;
|
|
||||||
canvas.scale(scale, scale);
|
|
||||||
// https://github.com/flutter/flutter/issues/76187#issuecomment-784628161
|
|
||||||
// https://api.flutter-io.cn/flutter/dart-ui/FilterQuality.html
|
|
||||||
var paint = Paint();
|
|
||||||
if ((scale - 1.0).abs() > 0.001) {
|
|
||||||
paint.filterQuality = FilterQuality.medium;
|
|
||||||
if (scale > 10.00000) {
|
|
||||||
paint.filterQuality = FilterQuality.high;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
canvas.drawImage(
|
|
||||||
image!, Offset(x.toInt().toDouble(), y.toInt().toDouble()), paint);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool shouldRepaint(CustomPainter oldDelegate) {
|
|
||||||
return oldDelegate != this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -17,6 +17,7 @@ import '../../common/widgets/remote_input.dart';
|
|||||||
import '../../models/input_model.dart';
|
import '../../models/input_model.dart';
|
||||||
import '../../models/model.dart';
|
import '../../models/model.dart';
|
||||||
import '../../models/platform_model.dart';
|
import '../../models/platform_model.dart';
|
||||||
|
import '../../utils/image.dart';
|
||||||
import '../widgets/dialog.dart';
|
import '../widgets/dialog.dart';
|
||||||
import '../widgets/gestures.dart';
|
import '../widgets/gestures.dart';
|
||||||
|
|
||||||
@ -898,32 +899,6 @@ class CursorPaint extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ImagePainter extends CustomPainter {
|
|
||||||
ImagePainter({
|
|
||||||
required this.image,
|
|
||||||
required this.x,
|
|
||||||
required this.y,
|
|
||||||
required this.scale,
|
|
||||||
});
|
|
||||||
|
|
||||||
ui.Image? image;
|
|
||||||
double x;
|
|
||||||
double y;
|
|
||||||
double scale;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void paint(Canvas canvas, Size size) {
|
|
||||||
if (image == null) return;
|
|
||||||
canvas.scale(scale, scale);
|
|
||||||
canvas.drawImage(image!, Offset(x, y), Paint());
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool shouldRepaint(CustomPainter oldDelegate) {
|
|
||||||
return oldDelegate != this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void showOptions(
|
void showOptions(
|
||||||
BuildContext context, String id, OverlayDialogManager dialogManager) async {
|
BuildContext context, String id, OverlayDialogManager dialogManager) async {
|
||||||
String quality =
|
String quality =
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
import 'dart:ui' as ui;
|
import 'dart:ui' as ui;
|
||||||
|
|
||||||
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
Future<ui.Image> decodeImageFromPixels(
|
Future<ui.Image> decodeImageFromPixels(
|
||||||
Uint8List pixels,
|
Uint8List pixels,
|
||||||
int width,
|
int width,
|
||||||
@ -47,3 +49,40 @@ Future<ui.Image> decodeImageFromPixels(
|
|||||||
descriptor.dispose();
|
descriptor.dispose();
|
||||||
return frameInfo.image;
|
return frameInfo.image;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ImagePainter extends CustomPainter {
|
||||||
|
ImagePainter({
|
||||||
|
required this.image,
|
||||||
|
required this.x,
|
||||||
|
required this.y,
|
||||||
|
required this.scale,
|
||||||
|
});
|
||||||
|
|
||||||
|
ui.Image? image;
|
||||||
|
double x;
|
||||||
|
double y;
|
||||||
|
double scale;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void paint(Canvas canvas, Size size) {
|
||||||
|
if (image == null) return;
|
||||||
|
if (x.isNaN || y.isNaN) return;
|
||||||
|
canvas.scale(scale, scale);
|
||||||
|
// https://github.com/flutter/flutter/issues/76187#issuecomment-784628161
|
||||||
|
// https://api.flutter-io.cn/flutter/dart-ui/FilterQuality.html
|
||||||
|
var paint = Paint();
|
||||||
|
if ((scale - 1.0).abs() > 0.001) {
|
||||||
|
paint.filterQuality = FilterQuality.medium;
|
||||||
|
if (scale > 10.00000) {
|
||||||
|
paint.filterQuality = FilterQuality.high;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
canvas.drawImage(
|
||||||
|
image!, Offset(x.toInt().toDouble(), y.toInt().toDouble()), paint);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool shouldRepaint(CustomPainter oldDelegate) {
|
||||||
|
return oldDelegate != this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user