Skip to the content.

PTools 高分辨率图片加载指南

目标

PTools 5.64.6 将图片加载的“布局点尺寸”和“解码像素尺寸”明确分开:调用方提供 UIKit 点尺寸,Core 根据实际窗口屏幕比例转换为像素后交给 PhotoKit、ImageIO、Kingfisher 或视频缩略图服务。

PTools 5.64.6 separa el tamaño de diseño en puntos del tamaño de decodificación en píxeles. La escala se obtiene del UIWindowScene activo cuando la vista ya está instalada en una ventana.

PTools 5.64.6 separates UIKit layout points from decode pixels. The Core loader resolves the active window screen scale at the UI boundary and keeps the 4096-pixel safety budget for large assets.

推荐调用

imageView.loadImage(contentData: source,
                   emptyImage: UIImage(named: "image-placeholder"))

UIImageView 和 UIButton 会立即清理旧图并设置 emptyImage。如果首次调用时控件尚未完成布局,Core 会等待一次主线程布局机会,再使用实际图片区域请求目标尺寸;Cell 复用时旧任务仍可通过 cancelImageLoad() 取消。

UIImageView y UIButton muestran el placeholder antes de la carga. Las solicitudes antiguas siguen protegidas por UUID/generation para que una celda reutilizada no reciba una imagen obsoleta.

尺寸规则

来源兼容

PTImageSource.image/data/asset/color/url/named/videoURL/avAsset 和旧的 Any 入口继续可用。视频 URL 默认获取第 10 帧;GIF、iCloud、取消、进度回调和旧 completion 行为不变。

PTRichText 的远程图片仍应通过 PTLoadImageFunction.makeTextAttachmentCoordinator() 或现有媒体 loader 进入同一条 Core 管线,下载期间使用占位图。

验收清单