Author |
Topic |
|
andyhill
Australia
133 Posts |
Posted - Dec 31 2022 : 18:14:07
|
I have the following code that loads a Rectangle on Layer1 over Layer0 Background - all good.
What I want to achieve is still use Layer1 as the mask BUT I want the area of Layer0 outside of the mask to be slightly transparent instead of opaque (remember user can drag rectangle over background image) ?
Please advise how using the code below - thanks in advance.
ImageEnView1.LayersAdd(ielkShape);
ImageEnView1.SetLayersGripStyle(clBlack, clLime, bsSolid, DefaultGripSize, iegsCircle);
TIEShapeLayer(ImageEnView1.CurrentLayer).Shape:= iesRoundRect;
ImageEnView1.CurrentLayer.PosX:= x1;
ImageEnView1.CurrentLayer.PosY:= y1;
ImageEnView1.CurrentLayer.Width:= x2;
ImageEnView1.CurrentLayer.Height:= y2;
ImageEnView1.CurrentLayer.FillColor:= clNone;
ImageEnView1.CurrentLayer.AlphaEdgeFeathering:= 50;
ImageEnView1.CurrentLayer.IsMask:= True;
ImageEnView1.MouseInteractLayers:= [mlEditLayerPoints, mlMoveLayers, mlResizeLayers];
ImageEnView1.Update();
ImageEnView1.VisibleBitmapRect:= ImageEnView1.Layers[1].LayerRect;
ImageEnView1.Update();
Andy |
|
andyhill
Australia
133 Posts |
Posted - Dec 31 2022 : 21:16:20
|
See post "Semi-transparent Layers with non-transparent border" I want the opposite.
I want the BackGround (layer0) Semi-Transparent with the ForeGround (Layer1) Fully Transparent showing it's VisibleBitmapRect Mask View of the BackGround (Layer0) - in essence a cookie cutter hole of a fully transparent window view of layer0 underneath the rectangle while the rest of layer0 outside of the rectangle is still semi-transparent. The user can still drag rectangle with view adjusting accordingly.
Why can we not post a small example image ?
Andy |
|
|
xequte
38615 Posts |
Posted - Jan 03 2023 : 20:03:09
|
Hi Andy
What happens when you try to post an example image?
Not quite the same, but have you considered DrawOuter:
http://www.imageen.com/help/TIELayer.DrawOuter.html
Otherwise you need a mask of the same size as the background image that is 50% opaque for the background and 0% opaque for the cut-out.
Nigel Xequte Software www.imageen.com
|
|
|
andyhill
Australia
133 Posts |
Posted - Jan 03 2023 : 20:44:40
|
I do not see on forum where I can post image in topic ?
Andy |
|
|
andyhill
Australia
133 Posts |
Posted - Jan 03 2023 : 20:51:00
|
The ImageEnView1.CurrentLayer.DrawOuter:= True; may just be what I need.
How do I auto position the rectangle in the view (I forgot - sorry).
Andy |
|
|
xequte
38615 Posts |
|
andyhill
Australia
133 Posts |
Posted - Jan 04 2023 : 00:38:50
|
Thanks Nigel, growing old is a tough gig.
Now that I have changed the logic away from Masks to using DrawOuter, can I change the grey percentage used ?
Andy |
|
|
xequte
38615 Posts |
Posted - Jan 04 2023 : 19:28:32
|
Hi Andy
I'm sorry, that cannot be customized at this time.
Nigel Xequte Software www.imageen.com
|
|
|
andyhill
Australia
133 Posts |
Posted - Jan 05 2023 : 14:17:15
|
Nigel, I was talking about quick reply (no image option) so therefore I have to use the full reply option in order to access images - no big deal.
I look forward to a future update where one can adjust the gray percentage in "DrawOuter" - thanks for your hard work.
Andy |
|
|
xequte
38615 Posts |
Posted - Jan 05 2023 : 16:13:22
|
Hi Andy
You can use the OnDrawLayer event to customizes the gray, e.g.
// Draw layers outside of the specified index as gray
procedure DrawLayerOuterEx(ABitmap: TIEBitmap; Layer: TIELayer; GrayValue: Integer);
var
i, j: integer;
rgb: PRGB;
bwidth, bheight: integer;
cab: TRect;
begin
Layer.CalcClientAreaBox( False );
bwidth := ABitmap.Width;
bheight := ABitmap.Height;
for i := 0 to bheight - 1 do
begin
rgb := ABitmap.Scanline[i];
for j := 0 to bwidth - 1 do
begin
cab := Layer.IE_ClientAreaBoxEx;
if ((j < cab.Left) or (j > cab.Right) or (i < cab.Top) or (i > cab.Bottom)) and
((((i and 1) = 0) and ((j and 1) = 0)) or (((i and 1) = 1) and ((j and 1) = 1))) then
with rgb^ do
begin
r := GrayValue;
g := GrayValue;
b := GrayValue;
end;
inc(rgb);
end;
end;
end;
procedure Tfmain.ImageEnView1DrawLayer(Sender: TObject; Dest: TIEBitmap; LayerIndex: Integer);
begin
if LayerIndex = ImageEnView1.LayersCurrent then
DrawLayerOuterEx( dest, ImageEnView1.Layers[LayerIndex], 99 );
end;
Nigel Xequte Software www.imageen.com
|
|
|
andyhill
Australia
133 Posts |
Posted - Jan 05 2023 : 20:29:01
|
My version 11.4.0 does not have "DrawLayerOuterEx" so will have to wait for an update.
Also, with the custom gray code above can we also change the transparency % as well ?
I await for the IEVision update as well.
Andy |
|
|
xequte
38615 Posts |
Posted - Jan 05 2023 : 21:13:48
|
Hi Andy
DrawLayerOuterEx() is shown in the code above. You can specify any value for Gray.
Nigel Xequte Software www.imageen.com
|
|
|
andyhill
Australia
133 Posts |
Posted - Jan 09 2023 : 12:38:15
|
Thanks Nigel - This now works :)
Any news on the IEVision fix ?
Andy |
|
|
xequte
38615 Posts |
Posted - Jan 10 2023 : 15:37:49
|
Hi Andy
Actually, there is an issue with the Pattern Matching demo that caused that. The correct code should be:
// Find templates
procedure TMainForm.btnMatchClick(Sender: TObject);
var
i: integer;
image, templ, map: TIEVisionImage;
rect: TIEVisionRect;
rank: double;
begin
ImageEnView1.Proc.Undo();
// for each image in TImageEnMView (template images)
for i := 0 to ImageEnMView1.ImageCount - 1 do
begin
// get image where to search in
image := ImageEnView1.IEBitmap.GetIEVisionImage();
// get the template image to search
templ := ImageEnMView1.GetTIEBitmap(i).GetIEVisionImage();
// perform template searching
rect := image.matchTemplate(templ, TIEVisionTemplateMatchMethod(cmbMethod.ItemIndex), @rank);
// fill the resulting map (must be done before ImageEnView.IEBitmap changes, otherwise "images" is invalid)
map := image.matchTemplateAsMap(templ, TIEVisionTemplateMatchMethod(cmbMethod.ItemIndex));
// draw a red box around the found rectangle
with ImageEnView1.IEBitmap.Canvas do
begin
Pen.Color := clRed;
Pen.Width := 5;
Brush.Style := bsClear;
Rectangle(IEVisionRectToTRect(rect));
Font.Height := 36;
Font.Color := clRed;
Brush.Style := bsSolid;
Brush.Color := clWhite;
TextOut(rect.x + 4, rect.y + 4, ImageEnMView1.ImageBottomText[i] + ' ' + FloatToStr(trunc(rank)) + '%');
end;
ImageEnView1.Update();
{
// Or use layers
if i = 0 then
ImageEnView1.LayersClear( False );
ImageEnView1.LayersAdd( ielkText, IEVisionRectToTRect( rect ));
with TIETextLayer( ImageEnView1.CurrentLayer ) do
begin
BorderColor := clRed;
BorderWidth := 5;
FillColor := clWhite;
Opacity := 0.66;
Font.Height := 24;
Font.Color := clRed;
WordWrap := False;
Alignment := iejCenter;
Text := ImageEnMView1.ImageBottomText[i] + ' ' + FloatToStr(trunc(rank)) + '%';
TextOverflow := ieoShrink;
end;
}
// draw the resulting map
ImageEnView2.IEBitmap.AssignIEVisionImage(map);
ImageEnView2.Update();
ImageEnMView1.ReleaseBitmap(i);
end;
end;
Nigel Xequte Software www.imageen.com
|
|
|
andyhill
Australia
133 Posts |
Posted - Jan 11 2023 : 13:49:35
|
Yes the demo was faulty but my issue was not with the demo, it was with IEVision stitching that causes A/V's and you said Fabrizio was fixing it late last year:-
pano:= IEVisionLib.createStitcher().stitch(images, status);
I am very keen to move forward with the IEVision fix.
Andy |
|
|
xequte
38615 Posts |
Posted - Jan 11 2023 : 17:00:09
|
Oh, I see. That issue is still pending. Those kinds of images require the newer version of OpenCV (bearing in mind that stitching is designed to merge multiple photos into a single panorama). We've mostly completed the updating to that, but need to test the remaining issues.
Nigel Xequte Software www.imageen.com
|
|
|
andyhill
Australia
133 Posts |
Posted - Jan 11 2023 : 20:55:06
|
Can we have both Vertical Stitching (one on top of each other [top/down1/down2 etc.]) and Horizontal Stitching (panorama [left/right/right etc.]).
Andy |
|
|
xequte
38615 Posts |
Posted - Jan 12 2023 : 14:03:36
|
Hi Andy
OpenCV does not support that. But you can rotate the images before processing and then rotate the result back.
Nigel Xequte Software www.imageen.com
|
|
|
andyhill
Australia
133 Posts |
Posted - Jan 12 2023 : 14:45:24
|
Good thinking - ready for update ...
Andy |
|
|
xequte
38615 Posts |
Posted - Jan 13 2023 : 23:09:36
|
Actually, you can email me for an update that supports joining two bitmaps and strips any overlapping content.
Nigel Xequte Software www.imageen.com
|
|
|
|
Topic |
|