需要一种在 Visual C 中显示图像并在图像上绘图的方法++
我发现的当前方法是制作位图并将其绘制到图片框中, 但是当尝试滚动面板时速度非常慢(图片框位于可滚动面板内)。
有没有更好的方法来实现这个功能?
The current way that I found was to make a bitmap and paint it into a picturebox,
but there it is very slow when trying to scroll the panel (the picturebox is inside a scrollable panel).
Is there a better way to achieve this functionality?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
仅在创建图片框时加载位图,然后将其保留在内存中,直到图片框被销毁。每次调用
OnPaint
时加载位图都会破坏性能。如果您收到
WM_PAINT
消息并且没有任何变化,还要确保您没有重新绘制位图。Load the bitmap only when your picture box is created, then leave it in memory until the picture box is destroyed. Loading the bitmap every time
OnPaint
is called will destroy performance.Also make sure you aren't re-painting your bitmap if you receive a
WM_PAINT
message and nothing has changed.图像尺寸 1500x2000 会很慢。将其大小调整为 25% 以显示预览怎么样?如果用户希望查看整个图像,请向他们发出警报,这可能需要一些时间。
That image size, 1500x2000 will be slow. How about resizing it to 25% to show a preview and if a user wishes to see the whole image give them an alert it may take some time.