From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Remove elements from picture control

I'd like to selectively remove some elements i previously drew on a 2D picture control (with functions such as "Draw line", "Draw rect"...). The rest of the picture, including what was "behind" them, should stay untouched.

Actually, i already managed to do it by "hacking": the picture data is incremental, so i can Flatten to String and carefully remove part of the data, if i memorized the length of data before and after drawing the element i want to remove. But perhaps you know better ways...

0 Kudos
Message 1 of 4
(2,953 Views)

Hello,

 

I'm new to drawing on pictures but what I do is draw various lines over a picture in response to user actions. Lines are added or taken away. 

 

I maintain an array of all the line segments I wish to draw, and I add to or remove from that array.It is independent of the picture.

 

Then when I need to change the picture with lines, I simply reload the original picture and draw all the lines again from the array with all the current lines I want.

 

This works well, however I wonder whether it wastes time reloading my original "background" picture each time. Quite a large bmp.

 

Hopefully someone else with more experience may suggest a more efficient way.

===============================================================

Take a look at DATEx, FOTEx, HELEx & SIGEx add-in trainer boards for NI ELVIS 1,2 & 2+ and DXIQ, ESSB for NI ELVIS III and myDSP for myDAQ to learn Wireless Telecoms, Signals & Systems, Fiber Optics and Green Energy principles (www.emona-tims.com)
0 Kudos
Message 2 of 4
(2,940 Views)

same thought with you ,i'm draw cycle ,and want edit (delete the wrong location cycle), think can use a array to store all cycle data, and reload.

i think it's a good way current.

sushu;
Certified LabVIEW Developer (CLD);
0 Kudos
Message 3 of 4
(2,582 Views)

Keeping track of your image elements, then removing the one you want and redrawing is probably the better approach.  But if you want to dive into the wonderful world of 2D picture control editing, then checkout this fabulous post by Norm.  In that thread a user was asking if there was a way to move all the object in a 2D picture at once instead of flattening the image, moving, and then redrawing.  What Norm shows in his videos, and the source, is that it is easier to pull out the individual image elements, change the data defining their location, and then update it with new position data. 

 

In the core of Norms code is a while loop that iterates over all image objects and performs some work on them.  He then builds a string of each element which contains the op-code (what kind of object is it) the length of the data, and the data itself.  Each of these strings is then concatenated into a single image.  What you can do is do the same thing, pulling out individual elements, but then ignoring the ones you want removed.

0 Kudos
Message 4 of 4
(2,566 Views)