fix cursor image && hotx,hoty, debug win

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou 2022-11-15 22:35:10 +08:00
parent 89a1c8b506
commit 44b89f574b

View File

@ -696,6 +696,8 @@ class CursorData {
final img2.Image? image; final img2.Image? image;
double scale; double scale;
Uint8List? data; Uint8List? data;
final double hotxOrigin;
final double hotyOrigin;
double hotx; double hotx;
double hoty; double hoty;
final int width; final int width;
@ -707,11 +709,12 @@ class CursorData {
required this.image, required this.image,
required this.scale, required this.scale,
required this.data, required this.data,
required this.hotx, required this.hotxOrigin,
required this.hoty, required this.hotyOrigin,
required this.width, required this.width,
required this.height, required this.height,
}); }) : hotx = hotxOrigin * scale,
hoty = hotxOrigin * scale;
int _doubleToInt(double v) => (v * 10e6).round().toInt(); int _doubleToInt(double v) => (v * 10e6).round().toInt();
@ -731,16 +734,14 @@ class CursorData {
image!, image!,
width: (width * scale).toInt(), width: (width * scale).toInt(),
height: (height * scale).toInt(), height: (height * scale).toInt(),
interpolation: img2.Interpolation.cubic,
) )
.getBytes(format: img2.Format.bgra); .getBytes(format: img2.Format.bgra);
} }
} }
this.scale = scale; this.scale = scale;
if (hotx > 0 && hoty > 0) { hotx = hotxOrigin * scale;
// default cursor data hoty = hotyOrigin * scale;
hotx = (width * scale) / 2;
hoty = (height * scale) / 2;
}
return scale; return scale;
} }
@ -811,8 +812,6 @@ class CursorModel with ChangeNotifier {
if (_defaultCache == null) { if (_defaultCache == null) {
Uint8List data; Uint8List data;
double scale = 1.0; double scale = 1.0;
double hotx = (defaultCursorImage!.width * scale) / 2;
double hoty = (defaultCursorImage!.height * scale) / 2;
if (Platform.isWindows) { if (Platform.isWindows) {
data = defaultCursorImage!.getBytes(format: img2.Format.bgra); data = defaultCursorImage!.getBytes(format: img2.Format.bgra);
} else { } else {
@ -825,8 +824,8 @@ class CursorModel with ChangeNotifier {
image: defaultCursorImage?.clone(), image: defaultCursorImage?.clone(),
scale: scale, scale: scale,
data: data, data: data,
hotx: hotx, hotxOrigin: defaultCursorImage!.width / 2,
hoty: hoty, hotyOrigin: defaultCursorImage!.height / 2,
width: defaultCursorImage!.width, width: defaultCursorImage!.width,
height: defaultCursorImage!.height, height: defaultCursorImage!.height,
); );
@ -996,10 +995,8 @@ class CursorModel with ChangeNotifier {
image: Platform.isWindows ? img2.Image.fromBytes(w, h, data) : null, image: Platform.isWindows ? img2.Image.fromBytes(w, h, data) : null,
scale: 1.0, scale: 1.0,
data: data, data: data,
hotx: 0, hotxOrigin: _hotx,
hoty: 0, hotyOrigin: _hoty,
// hotx: _hotx,
// hoty: _hoty,
width: w, width: w,
height: h, height: h,
); );