从比屏幕高控制绘制位图 [英] Draw a bitmap from a control taller than the screen

查看:174
本文介绍了从比屏幕高控制绘制位图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有保存C#控制位图文件相当多的问题。有问题的控制是一种绘图表面上,用户可以写文字,画画和油漆盒。控制是调整大小,拖动。发生什么是,当控制是非常大,是不完全可见的屏幕上,在控制的不可见的部分被保存在位图上半牵伸。用于生成位图code是相当简单:

I am having quite a few problems saving a C# control to a bitmap file. The control in question is a kind of drawing surface on which the user can write text, draw pictures and paint boxes. The control is resizable and draggable. What happen is, when the control is really big and is not totally visible on the screen, the parts of the control not visible are saved half-drawn on the bitmap. The code used to generate the bitmap is quite simple:

Bitmap bitmap = new Bitmap(myControl.Width, myControl.Height);
myControl.DrawToBitmap(bitmap);

我曾尝试以下方法来尝试有一个完全手绘的位图,没有任何成功:

I have tried the following methods to try to have a fully painted bitmap, without any success:

myControl.Invalidate(myControl.ClientRectangle, true);
myControl.Refresh();
myControl.Update();
Application.DoEvents();

我不能缩放控制下来,使其完全可见的,因为分辨率和图像质量是该项目非常重要。其实,我实际上是想将图像缩放到提高它的质量。有没有办法,我不知道从控制生成图像的?

I cannot scale the control down to make it fully visible since resolution and image quality are very important for that project. In fact, I am actually trying to scale the image up to increase it's quality. Are there ways I am not aware of generating an image from a control ?

坦克你。

推荐答案

DrawToBitmap 有一些限制,不总是按预期工作。而是尝试与当地的 GDI +工作

DrawToBitmap has limitations and dont always work as expected. Try instead work with native GDI+

下面是<一个href=\"http://stackoverflow.com/questions/2434156/webbrowser-drawtobitmap-or-other-methods/2434231#2434231\">example

这篇关于从比屏幕高控制绘制位图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆