Images not drawn by software rendering #1542
Labels
Bug
Product bug (most likely)
.NET Framework
tell-mode
Issues and PR's that require notice to .NET Core Shiproom
Milestone
(Port of fix in the .NETFx servicing pipeline)
Software rendering fails to draw images (or only partially draws them) when the image position and scaling are too large.
Software rendering does image-processing using integer arithmetic, representing points as "16.16" fixed-point numbers (16 bits of integer, 16 bits of fraction). Thus it cannot deal with quantities whose magnitude exceeds 2^15=32768. The translation components of the device-to-texture mapping can exceed this limit if the position and scaling of the image are large enough. For example, the mapping for a 10x10 Image element, sourced to a 500x500 bitmap and positioned 700 pixels from the edge of the enclosing window, has scaling factor 500/10 = 50 and a desired translation of -50*700 = -35000 -- too big.
In this case the renderer uses the closest available number, -32768, causing it to sample the source bitmap too far to the right. This produces a result equivalent to painting the image at the maximum "working" offset then clipping by the actual position of the Image. In other words, as the Image moves to the right, the picture stops moving when the maximum offset is reached, and instead gets clipped on its left side until it eventually disappears altogether.
Fix:
Use an adjusted mapping, relative to an "origin" point. When mapping from device to texture, subtract the origin (in regular "int" coords), then apply the adjusted 16.16 mapping. The adjusted mapping's translation components depend on the distance from the origin, rather than from the window-edge, so choosing an origin point that's close to the Image position will avoid the overflow.
The text was updated successfully, but these errors were encountered: