在图片框上绘制图像 [英] draw an image on a picturebox

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

问题描述

嗨 我想在另一个图像上绘制一个图像(它在一个图片框中)我该怎么做?
并且如果我移动图像,它将保持不变.
请帮帮我!
请给我一个代码

解决方案

您可以:
1)在PictureBox.Image属性中包含的图像上绘制新图像,并使Invalidate Picture框无效-这将在应用程序期间永久存在,尽管它不会影响原始图像,并且在更改时不会更改您重新加载应用程序.
2)不使用PictureBox,而是使用Panel,并在Paint事件中绘制两个图像-这是一个临时更改,使您可以将新图像移到旧图像的顶部.

您想做什么?

我有一个可缩放和可滚动的图片.用户选择它的一个点,然后我想在该点上画一个狭窄的地方,即使用户滚动图像,我也想在那个点上找到一个狭窄的地方."

通过窄",我假设您是指矩形?如果是这样,请使用以下命令:

using (Graphics g = Graphics.FromImage(myPictureBox.Image))
    {
    g.DrawRectangle(Pens.White, rect);
    }
myPictureBox.Invalidate();


hi I want to draw an image on another image(It is in a picturebox)how can i do that?
& it will be constant if I move the image.
pls help me!
pls give me a code

解决方案

You can either:
1) Draw the new image on the image contained in the PictureBox.Image property, and Invalidate the Picture box - this will be permanent for the duration of the application, though it won''t affect the original image and it will be unchanged when you reload the application.
2) Not use a PictureBox, but a Panel instead, and draw both images in the Paint event - this will be a temporary change, which will allow you to move the new image around over the top of the old.

Which do you want to do?

"I have a zoomable & scrollable picture. the user selects a point of it then I want to draw a narrow on that point also I want the narrow places on that point even if the user scroll the image."

By "narrow" I assume you mean a rectangle? If so then use this:

using (Graphics g = Graphics.FromImage(myPictureBox.Image))
    {
    g.DrawRectangle(Pens.White, rect);
    }
myPictureBox.Invalidate();


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

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