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
 Displaying mask over image

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 - Aug 19 2014 : 02:06:11
Hi,

I'm struggling with one task.

Initial conditions:

1. Image is loaded and display in ImageEnView (24-bit).
2. An offsreen TIEBitmap grayscale mask is created (8-bit), with the same with and height as original 24-bit image.
3. Some brush stroke is drawn on grayscale mask (in OnMouseMove event).

The problem:

I want to display (in ImageEnView) original image with XOR-ed mask.
How to achieve this, without altering original image content?

I've tried few solutions:

1. In OnMouseMove event, I'm simply XOR-ing mask with original image. This solution is quite cumbersome as original image pixels are altered and when such operation is not needed any more, I need to restore original image (XOR-ing with mask again). Also, keeping track if image is XOR-ed with mask or not is additional problem.

2. Adding some kind of special layer also works, but as layer is 24-bit image, I have additional tasks to perform: permanently copying pixels from mask to this layer and also, I need to keep track of this special layer in order to distinguish it from other layers.

3. I've tried with OnDrawBackBuffer event (which seems most promising solution), but there is another problem: how to determine a position of original image inside BackBuffer?

Any other solution? Maybe another event?

TIA,
Siniša



1   L A T E S T    R E P L I E S    (Newest First)
spetric Posted - Aug 21 2014 : 14:55:24
Done it. I'm not completely satisfied, but it works ok.

First, I've tried with nontransparent 24-bit ObjBitmap object (same size as original image). Filled it with clBlack and set BlendOperation to ielXOR. While drawing across image, mask pixels inside bound rectangle are copied to all 3 channels of ObjBitmap in order to get white color which will be xor-ed with original image.

However, while performing this operation, original image is hidden and ObjBitmap is shown in normal mode. XOR operation/blending is performed after mouse button is released. This is the difference between layer and ObjBitmap approach, as layer blending is performed almost instantly (in onmousemove event).

Anyway, I've changed approach a bit and created ObjBitmap with transparent channel, filled it with white and alphachannel with black. Now, while drawing is performed, alpha channel pixels are replaced by mask pixels (both bitmaps are grayscale).

So, while drawing, I have white strokes over image and when mouse button is released, XOR blending is performed.

Well, not what I initially wanted, but quite satisfying.

Any clue why XOR-ing is not performed in the same manner as with layers?