简体   繁体   English

为什么在使用Graphics.ScaleTransform时出现OverflowException?

[英]Why do I get an OverflowException when using Graphics.ScaleTransform?

I have some drawing code for an editor I am working on. 我有一些正在使用的编辑器的绘图代码。 It draws a few lines and an image buffer. 它画了几条线和一个图像缓冲区。 After adding a zoom features and calling ScaleTransform I get an OverflowException thrown in my paint method. 添加缩放功能并调用ScaleTransform我在paint方法中抛出了OverflowException

Is something being scaled outside the bounds? 事物是否超出范围? My scaling factor is 2.0 and I have even tried 1.0 and making sure all the window sizes / buffers are large enough. 我的缩放系数是2.0 ,我什至尝试过1.0 ,并确保所有窗口大小/缓冲区都足够大。

The Graphics.Transform property is not reset to the identity matrix. Graphics.Transform属性不会重置为身份矩阵。 You have to do this yourself at the beginning of your paint method: 您必须在绘制方法的开始时自己做:

g.Tranfsorm = new Matrix();
g.ScaleTransform(2.0, 2.0);

Otherwise after a few exponents it will overflow (at 60 frames per second as in my application this would seem instantaneous) 否则,经过几次指数运算后,它将溢出(在我的应用程序中,每秒60帧的速度似乎是瞬时的)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM