WPF:System.Windows.Int32Rect ---> 系统.Windows.Int32Point?
你知道System.Drawing.Rectangle是如何被System.Windows.Int32Rect取代的吗? (就非浮点形状而言......)
对于整数点或大小是否有类似的新对象? 如果没有,我将只使用 System.Drawing - 但这似乎是两个平台的小混合,对我来说不应该混合。
无论如何,你对此有何看法?
You know how System.Drawing.Rectangle was replaced by System.Windows.Int32Rect? (As far as non-floating-point shapes are concerned ...)
Is there a similar new object for an integer point or size? If not, I'll just use System.Drawing - but that kinda seems like a minor mix of two platforms that ought not to me mixed.
Anyway, what do you think about this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
WPF 中的绘图基元将所有测量/位置值存储在双精度中 - 正如您所指出的,显然除了 Int32Rect 之外的所有测量/位置值。 此设计背后的原因是 WPF 不直接从像素到显示绑定 - 它使用“设备独立像素”(DIP),可以根据渲染它的任何设备进行缩放。 这使 WPF 能够非常轻松地缩放和转换其显示的所有内容。
至于 System.Windows.Int32Rect,我看到它在 API 中唯一使用的地方是用于捕获和裁剪像素。 这是有道理的 - 在进行屏幕捕获时,您希望准确获取设备上当前显示的像素。
The drawing primitives in WPF store all measurements/locations values in doubles - apparently all except Int32Rect, as you pointed out. The reasoning behind this design is due to how WPF is not bound directly from pixel-to-display - it uses "device independent pixels" (DIPs) which can be scaled for whatever device on which it is being rendered. This gives WPF the ability to scale and translate everything that it is displaying very easily.
As for System.Windows.Int32Rect, the only place I see it being used inside the API is for capturing and cropping pixels. This makes sense - when doing a screen capture, you're wanting to get exactly the pixels that are currently displayed on the device.