每隔这么多像素绘制图像 [英] Draw Image every so many pixels

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

问题描述

Hello社区,(新人在这里qith vb.net 2010问题)



我正在努力解决这个问题。



我想要做的是画一个图片框或图像,然后跳过50个像素然后绘制另一个图像或图片框并重复此过程。我需要在整个窗口窗体中发生这种情况并停止窗体的结束宽度像素。



可能吗?我认为它可能是某种循环或数组甚至两者..但我对这个VB.net编程领域很新,所以我希望得到帮助。



如果它意味着我在这里尝试做的任何东西都是我多年来一直试图用vb6和现在的vb.net完成的事情而且没有运气。



提前致谢!你永远感激我真的不知道!

Hello Community, (New Guy Here qith vb.net 2010 question)

Im struggling to figure this out.

What im trying to do is draw either a picturebox or image then skip 50 pixels then draw another image or picbox and repeat this process. I need this to happen across the entire window form and stop the the end width pixel of the form.

Possible? I figure it might be some sort of loop or array maybe even both.. but im new to this area of VB.net programming so im hoping for help.

If it means anything what i am trying to do here is something ive been trying to accomplish for years using vb6 and now vb.net and no luck.

Thanks in advance! You have my gratitude eternally you really have no idea seriously!

推荐答案

你可以简单地安排 PictureBox的实例循环中,你想要的方式。矩阵将是嵌套的X-Y循环,依此类推。



但是,您可能希望在调整窗口大小时图像流动,保留这些间隙。然后你可以使用类 System.Windows.Forms.FlowLayoutPanel

http://msdn.microsoft.com/en-us/library/system.windows.forms.flowlayoutpanel%28v = vs.110%29.aspx [ ^ ]。



如何保留5像素间隙呢?您需要将每个 PictureBox 放在一个固定大小的面板中,更高,更宽5像素。然后,您可以使用该面板上的属性 Padding 来创建一些间隙,例如,在右侧和底部。 (那么你可能需要制作不同宽度填充的最右边的面板,以避免额外的间隙。)和然后将这些较大的面板实例放入流程面板中,这将自动排列布局。这只是一个尝试的问题,看看你喜欢什么,并唤起进一步的想法。



您还需要知道如何在代码中添加控件。方法如下:

You could simply arrange the instance of PictureBox in a loop, the way you want. A matrix would be a nested X-Y loop, and so on.

However, you may want the images to flow as you resize the window, preserving those gaps. Then you can use the class System.Windows.Forms.FlowLayoutPanel:
http://msdn.microsoft.com/en-us/library/system.windows.forms.flowlayoutpanel%28v=vs.110%29.aspx[^].

How to preserve the 5-pixel gaps then? You need to put each PictureBox in a fixed-size panel 5 pixels taller and wider. And then you can use the property Padding on that panel to create some gaps, say, on right and bottom. (Then you may need to make the rightmost panel of different Width and Padding, to unwanted avoid extra gap.) And then drop those bigger panel instances in a flow panel, which will auto-arrange the layout. It's just a matter of trying, to see what would you prefer and evoke further ideas.

You also need to know how to add a control in code. Here is how:
Dim someChildControl As Control = '...
Dim someOtherChildControl As Control = '...
Dim someParentControl As Control = '...

' set some other properties, size, location, DockStyle, whatever applicable...

someParentControl.Controls.Add(someChildControl);
' or, same thing:
someOtherChildControl.Parent = someParentControl;





我还有另外一个普遍的想法。使用设计器创建您想要查看的内容的原型,构建/运行项目。然后,查看自动生成的代码,了解它是如何在代码中实现的。理解之后,请在您自己的代码中使用该技术。



-SA


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

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