如何绘制,选择,重新调整大小和放下绘图形状? [英] How to draw, select, re-size & drop the drawing shapes?

查看:82
本文介绍了如何绘制,选择,重新调整大小和放下绘图形状?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建视频播放器,因为我正在使用GDI +绘制形状。通过使用这个我可以在面板上绘制形状。但我需要选择绘制的形状来动态移动和重新调整大小[使其更加用户友好]。我必须做些什么来实现这个目标!?



谢谢和问候,

J.Surjith Kumar

I am creating the video player in that i am drawing shapes using GDI+. By using this i can draw the shapes over the panel. But i need to select the drawn shapes to move & re-size dynamically [To make it more user friendly]. What i have to do to achieve this!?

Thanks & regards,
J.Surjith Kumar

推荐答案

这有两种常用的方法。



1.检查每个形状的光标坐标,看它是否接近任何形状原始。这种技术的缺点是,你在屏幕上拥有的形状越多,你就越需要优化修剪选择,然后再做数学运算来确定你的光标和形状是否足够接近以便计算为选择。



2.每次抽取到屏幕DC或内存DC时,也使用由形状ID确定的假色来绘制到内存DC或原始。对于此操作禁用抗锯齿,它旨在涂抹像素颜色并破坏ID。使用32位位图,您可以使用DWORD作为ID,为您提供最多2 ^ 32-1个形状基元,可以在屏幕上查看。要查找基元,只需扫描假色位图上的像素,然后选择最接近光标位置的对象。确保在每次绘制之前用0绘制背景。这种技术不需要复杂的数学运算,并且可以执行非常快速的查找。



查找第二个,可以是对光标附近像素的简单扫描。无需扫描整个图像。
There are two common methods for doing this.

1. Check you cursor coordinates against each shape to see if it comes near any primitive. The downside of this technique is that the more shapes you have on the screen, the more need you''ll have for optimizations to prune the selections down, before doing the math to determine if your cursor and shapes are close enough together to count as a selection.

2. With every draw to the screen DC or memory DC, also draw to a memory DC using a false color determined by an ID for the shape or primitive. For this operation disable anti-aliasing, it is designed to smudge the pixel colors and will corrupt the IDs. With a 32 bit bitmap, you can use a DWORD for the ID, giving you up to 2^32-1 shape primitives that can be viewed on the screen. To find the primitive, simply scan the pixels on the false color bitmap and choose the object that is closest to the cursor position. Be sure and paint the background with 0 before every draw. This technique requires no complex math and performs very fast look ups.

The look up for the second one, can be a simple scan of the pixels near the cursor. No need to scan the entire image.


这篇关于如何绘制,选择,重新调整大小和放下绘图形状?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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