如何使用vb.net在一个图片框中显示多个图像 [英] how to display multiple images in one picture box using vb.net

查看:416
本文介绍了如何使用vb.net在一个图片框中显示多个图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我正在使用VB.Net,VS2008和Win7。

我想在一个图片框中添加多个图片使用VB.Net并在printpreviewcontrol上显示以进行打印。

如何在打印预览控件中显示多个图像。



帮助将非常有用。

任何链接或者想法我给我。



mukesh: - )

Hi All,

I am using VB.Net, VS2008 and Win7.
I want to add multiple images in one picturebox using VB.Net and display on printpreviewcontrol for print.
How can display multiple image in print preview control.

Help will be very apprecited.
Any link or idea my give me.

mukesh :-)

推荐答案

你不能显示多个图像在一个PictureBox中 - 它只有一个Image属性。

要做这样的事情,你必须创建一个足够大的Bitmap对象来保存你的多个图像,然后使用它们绘制它们,来自Bitmap的Graphics对象:

You can't show multiple images in a single PictureBox - it only has a single Image property.
To do something like this, you would have to create a large enough Bitmap object to hold your multiple images, and then draw them in, using a Graphics object from the Bitmap:
Using g As Graphics = Graphics.FromImage(myBigBitmap)
	For Each i As Image In myListOfImagesToAdd
		g.DrawImage(i, pointToDrawit)
		pointToDrawIt = MoveForNextImage(pointToDrawIt, i)
	Next
End Using



大概这也将解决你的打印预览问题,虽然我强烈建议您使用PrintDocument而不是尝试打印屏幕图像......


Presumably this will also solve your print preview problem, although I would strongly suggest you use a PrintDocument rather than try to print screen images...


你不能。除了为不知道如何自己显示一个图像的人显示一个图像之外,图片框对于任何东西都是无用的。每张照片一个盒子,你可以通过将你所有的照片绘制成一个大的照片并显示,或通过拥有许多盒子,或通过处理你的绘画事件和绘制自己的照片来解决这个问题。
You can't. A picture box is useless for anything except showing one image for people who don't know how to show one themselves. One box per picture, you can get around this by drawing all your pictures in to one big one and showing that, or by having many boxes, or by handing your paint event and drawing your own pics.


哦(叹气)......我发现了另一起企图滥用 PictureBox 的案例。让我解释一下。此控件专为不想处理任何图形的人设计。简单而简单的东西。没有任何动态,动画,组合,操纵。纯静态图像,有时可能被替换,但不经常。



由于对图形的深深混淆,许多人试图做更多,这是可能的,但只是愚蠢。这个控件对它没有帮助,只会带来麻烦。



那么,该怎么做?更简单的方法:

如何从旧图纸中清除面板 [ ^ ]。



如果你的图片是静态的,它甚至更简单比起那个来说。做无效,没有双缓冲。但是你可以移动图像,动画,保存到文件或从文件加载等等。



-SA
Oh (sigh)… I discovered yet another case of an attempt to misuse of PictureBox. Let me explain that. This control is designed for somebody who does not want to deal with any graphics at all. Something simple and simpler. Nothing dynamic, animated, combined, manipulated. Pure static image, maybe sometimes replaced, but not often.

By the reason of deep confusion about graphics, many try to do a lot more, which is possible but just silly. This control does not help it, only presents a hassle.

So, what do to? Something way more simple:
How do I clear a panel from old drawing[^].

If you picture is static, it's even simpler than that. Do invalidation, no double buffering. But you can do moving images, animation, saving to file or loading from files and a lot more.

—SA


这篇关于如何使用vb.net在一个图片框中显示多个图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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