为什么没有在屏幕上绘制图像? [英] Why is the image not being Drawn on the screen?

查看:59
本文介绍了为什么没有在屏幕上绘制图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用代码在屏幕上绘制图像。但我无法弄清楚为什么它没有在屏幕上绘制。我使用以下代码,



I was using a code, to draw the image on the screen. But I am not able to figure out why it is not being drawn on the screen. I am using the following code,

Bitmap bmp = new Bitmap("10630606_727195303982470_1655175415434850365_o.jpg");
Graphics gr = Graphics.FromImage(bmp);
gr.DrawImage(bmp, 60, 30);





..如果我在代码末尾添加一个新行,如





..if I add a new line at the end of the code, as

bmp.Save("<location>");





..然后我仍然可以找到在该位置创建的文件。这意味着代码正在运行查找并且图像已加载。但图形不会在屏幕上绘制。我有一个900x700大小的WPF应用程序,但在该应用程序的屏幕上找不到图像或任何东西。



任何帮助将不胜感激。



..then I can still find out the file created at that location. Which means that the code was working find and the image was loaded. But the graphics aren't drawn on the screen. I am having a WPF application of 900x700 size but the image or any thing is not found anywhere on the screen in that application.

Any help will be appreciated.

推荐答案

请参阅我对该问题的评论。我没看到你的代码;搞砸事情的方法太多了。您没有显示任何代码,您尝试在屏幕上绘制任何内容;并且在你显示的位图上画画几乎无关紧要。



然而,首先检查看起来类似的问题以及我过去的答案:

什么样的俏皮方法是Paint? (DataGridViewImageCell.Paint(...)) [ ^ ],

在面板上捕获绘图 [ ^ ],

mdi子表单之间的绘制线 [ ^ ],

如何加快我的vb.net应用程序? [ ^ ],

用C#.net鼠标滚轮缩放图像 [ ^ ]。



很有可能,您可以从这些答案中获得线索。



-SA
Please see my comments to the question. I did not see your code; there can be too many ways to screw up things. You did not show any code where you tried to draw anything on screen; and drawing on a bitmap you show is pretty much irrelevant.

However, first check the problems which looked similar and my past answers:
What kind of playful method is Paint? (DataGridViewImageCell.Paint(...))[^],
capture the drawing on a panel[^],
Drawing Lines between mdi child forms[^],
How to speed up my vb.net application?[^],
Zoom image in C# .net mouse wheel[^].

Chances are, you can get a clue from those answers.

—SA


这篇关于为什么没有在屏幕上绘制图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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