ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Selection intersection

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
spetric Posted - Mar 04 2015 : 14:03:21
Hi,

I have two questions regarding Selections.

1. Is there some option to create selections intersection?
Something like: Sel3 = Sel1 & Sel2 (such option would be helpful).

2. For checking if point is inside selection, what method is faster?
a) PaintView->SelectionMask->GetPixel(x, y) == 0
b) PaintView->IsPointInsideSelection(x, y)

TIA,
Siniša
5   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Mar 08 2015 : 20:36:45
Hi

Yes, that would do it, but why not simply create the mask for the invisible selection using an in-memory bitmap rather than involving your TImageEnVect?

Another way would be simply to have a non-visible TImageEnVect for your second selection and simply call ImageEnVect1.IsPointInsideSelection() AND ImageEnVect2.IsPointInsideSelection(). That would be faster unless you are making a huge number of calls to IsPointInsideSelection.

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
spetric Posted - Mar 06 2015 : 01:55:29
Hi Nigel,

Yes, selections are merged, which means it's an union of two selections (Sel1 union Sel2), so the method IsPointInsideSelection will return true if point is inside Sel1 OR Sel2.

I'm trying to make an intersection of selections: Sel1 is visible and created by user, the other one, Sel2, is created programmatically and is not visible.
As there is no method to create intersection, I'm trying to achieve some kind of intersection of Sel1 and Sel2 and check if point is inside Sel1 AND Sel2.

So, I'm just thinking loudly, how to perform such task (mask depth = 8):

1. Copy user's SelMask of Sel1 into some external 8-bit bitmap (Mask1).
2. Save Sel1.
3. Programmatically create invisible selection Sel2 and save it's mask as external 8-bit bitmap (Mask2).
4. Restore Sel1.
5. Perform AND operation between bitmaps (masks): Mask1 = Mask1 AND Mask2.

Now, bitmap Mask1 contains intersection of selections and calling Mask1->GetPixel(x,y) will fulfill intersection query...I hope so.

Any other idea? It would be nice to reduce those steps.
xequte Posted - Mar 05 2015 : 22:17:08
Sorry Siniša

I may be misunderstanding your request. What are the sources of your two selections? If they are in the same TImageEnView then they will automatically merge, so IsPointInsideSelection will return the correct result regardless of which selection.


Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
spetric Posted - Mar 05 2015 : 08:30:27
Thanks Nigel,

Until intersection implementation, there is a workaround:

bool selIntersect = true;
PaintView->LoadSelectionFromStream(sel1); 
selIntersect &= PaintView->IsPointInsideSelection(x, y);
PaintView->LoadSelectionFromStream(sel2); 
selIntersect &= PaintView->IsPointInsideSelection(x, y);


However, this seams a costly operation. Maybe it's better to
export (copy) selection masks and then perform AND operation between those two
masks. Resultant mask will be intersection and
SelectionMask->GetPixel(x, y) == 0 will give desired result.

xequte Posted - Mar 04 2015 : 21:16:27
Hi Siniša

1. No, but it is a good idea for a coming release

2. They are the same as PaintView->IsPointInsideSelection calls:

PaintView->SelectionMask->GetPixel(x, y) == 0

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com