docs(cursor): explain image decoding and Retina sampling

This commit is contained in:
fufesou
2026-09-12 20:51:58 +08:00
parent bbf86259e9
commit 02e4f02815
2 changed files with 6 additions and 1 deletions

View File

@@ -2995,7 +2995,9 @@ class PredefinedCursor {
() async {
_image?.dispose();
// PNG stores straight alpha; let the codec prepare the pixels for ui.Image.
// Native registration uses this ui.Image. The RGBA bytes from img2 are
// straight alpha, but PixelFormat.rgba8888 requires premultiplied alpha.
// Decode the PNG directly to preserve translucent cursor colors.
final codec = await ui.instantiateImageCodec(pngBytes);
final ui.Image nativeImage;
try {

View File

@@ -638,6 +638,9 @@ fn unsafe_get_cursor_data(hcursor: u64) -> ResultType<CursorData> {
if hcursor != hcursor2 {
bail!("cursor changed");
}
// NSImage.size is in points; using it as bitmap dimensions can crop Retina
// artwork. Render the full image and convert its hotspot to pixels;
// keep the existing 1x sampling path below.
if scale > 1.0 {
return cursor::data(c, hcursor, scale);
}