回 帖 发 新 帖 刷新版面

主题:PictureBox控件的一个小问题

由于默认坐标系的原点在左上角,想通过变换变成习惯的状态,即原点在左下角。在.net里面,用下面方法实现:
Dim PicDraw As Graphics = PictureBox_Draw.CreateGraphics()
Dim RecPos As Rectangle = New Rectangle(0, 0, 20, 20)
PicDraw.DrawRectangle(Pens.Black, RecPos)
PicDraw.TranslateTransform(0, PictureBox_Draw.Height)
PicDraw.ScaleTransform(1, -1)
PicDraw.DrawRectangle(Pens.Black, RecPos)

首先是将坐标的原点移到左下角,坐标是(0,PictureBox_Draw.Height)。然后将y坐标系镜像,使其向上为正。
为了验证效果,前后画了两个矩形。结果如下:
可以发现,改变坐标系后,有一部分图形没显示出来。不知道是什么情况,查了一些资料,说是控件的边界处有一部分是不能绘图的,不知如何确定这一部分的大小?

求各位大神不吝赐教!

回复列表 (共7个回复)

沙发

如果是定义坐标系6.0中可以直接用Picture1.Scale (x0,y0)-(x1,y1)

板凳

从计算机图形学角度讲,这是一个边界像素的取舍问题。一般规定:左、下边界无效,右、上边界有效。具体到你这里表现到了下边界。
但是——
更重要的是,我们使用图形框决不能用满!第一大问题就是不美观。例如我们看书,没有页边距会有什么感觉?
建议,有效长度=有效的最大值-有效的最小值,
图片框设置最小值=有效最小值-有效长度/6
图片框设置最大值=有效最大值+有效长度/6
即,左右(上下同理)留出各1/8的边距。

3 楼

另,本版是vb6.0讨论板,vb.net请到.net版讨论。

4 楼


怎么没显示图片呢!

















signature--------------------------------------------------------------------------------
Our [url=http://www.jeremyscottwingsoutlet.org/]jeremy scott wings[/url] Products are favored by our clients for high quality[url=http://www.jeremyscottwingsoutlet.org/jeremy-scott-wings-c-1.html]adidas jeremy scott wings[/url],[url=http://www.jeremyscottwingsoutlet.org/jeremy-scott-wings-20-c-2.html]jeremy scott wings 2.0[/url],[url=http://www.jeremyscottwingsoutlet.org/jeremy-scott-teddy-bear-c-8.html]jeremy scott teddy bear[/url],[url=http://www.jeremyscottwingsoutlet.org/adidas-obyo-jeremy-scott-c-3.html]Adidas ObyO Jeremy Scott[/url]

5 楼


定义左上,及右下的坐标即可。

6 楼

不能回复图片吗?

7 楼

Russian President Dmitry Medvedev on Sunday [url=http://www.soccercleatsonlines.com/adidas-soccer-cleats-adidas-adipower-predator-trx-fg-c-1_29.html]adidas Adipower predator[/url] ordered an investigation into the allegations of electoral fraud during last weeks parliamentary vote. The announcement came a day after tens of thousands of people rallied in Moscow and other cities to demand the December 4 polls [url=http://www.cheaptimberlandswholesale.com/]cheap timberlands[/url] won by Prime Minister Vladimir Putins ruling United Russia party be annulled and rerun. In a post on the social media site Facebook, Mr. Medvedev said that although he does not agree with any slogans or speeches made at the rallies, he has given [url=http://www.soccercleatcheap.com/]cheap soccer cleats[/url] instructions to check all information from polling station regarding compliance with the election laws. Within minutes of his statement, Mr. Medvedev had received over 1,000 comments on his Facebook site, most of them angry and some [url=http://www.timberlandoutletonline.com/]timberland outlet online[/url] disrespectful. The Occupy London protest site reached its 60th day Monday, running longer than its counterpart in New York did before it was dismantled. It now occupies three sites across the City of London - a cathedral courtyard, a square [url=http://www.soccercleatsonlines.com/adidas-soccer-cleats-adidas-f50-adizero-micoach-fg-c-1_9.html]adidas adizero f50[/url] and a building. One of the sites even has an art gallery. But with growth has come rivalry between the two, with criticism that some American protesters who have decamped to London from New York are too reliant on their creature [url=http://www.cheaptimberlandswholesale.com/mens-timberland-roll-top-boots-c-3.html]timberland boots on sale[/url] comforts. The U.S. economy has recently showed signs of improvement with the unemployment rate dropping from nine percent to 8.6 percent but it remains far above a normal traditional rate of four or five percent. The jobless rate [url=http://www.soccercleatcheap.com/nike-mercurial-glide-iii-ag-green-black-p-289.html]nike mercurial green[/url] is seen as a major factor in whether Mr. Obama can win re-election to another four-year term next November. The president once again called on Congress to approve his nominee, Richard Cordray, to head a new consumer [url=http://www.timberlandoutletonline.com/mens-timberland-roll-top-boots-wheat-p-50.html]timberland roll top boots[/url] protection agency. U.S. President Barack Obama is pressing Republicans in Congress to approve his nominee Richard Cordray to head the first ever consumer guardian agency. During his weekly address Saturday, Obama urged lawmakers to give [url=http://www.soccercleatsonlines.com/nike-soccer-cleats-nike-mercurial-vapor-viii-fg-c-41_64.html]nike mercurial vapor fg[/url] Americans the protection they need from being taken advantage of by mortgage lenders, payday lenders and debt collectors. The president says many people on Wall Street have made a lot money taking advantage of consumers. He is appealing [url=http://www.cheaptimberlandswholesale.com/]timberland for sale[/url] to legislators to give Americans an advocate he says will protect them from unscrupulous practices. Protesters came out across the worlds largest country to demand clean elections and to say what, only one week ago, [url=http://www.soccercleatcheap.com/nike-soccer-cleats-nike-mercurial-victory-iv-ag-c-41_73.html]nike mercurial victory iv[/url] was unsayable. Russia Without Putin was the favorite chant of thousands of demonstrators who marched within earshot of the Kremlin in the largest pro-democracy demonstration since Vladimir Putin came to power in 2000. From Vladivostok on the Pacific [url=http://www.timberlandoutletonline.com/mens-timberland-6-inch-premium-boots-olive-green-p-112.html]timberland boots for men[/url] Coast to Kaliningrad on the Baltic.CF

我来回复

您尚未登录,请登录后再回复。点此登录或注册