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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 ColorChange Two Separate Areas on a Base Image Using Two Different Selects
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

andyhill

Australia
133 Posts

Posted - Aug 28 2022 :  15:30:58  Show Profile  Reply
Layer Zero: Base Image
Layer One: FreeHandPolyline (Closed)
Layer Two: FreeHandPolyline (closed)

ImageEnView1.SelectionBase:= iesbBitmap;
ImageEnView1.SelectionMaskDepth:= 8; // see feathering

Walk Layers and locate the two FreeHandPolyline Layers (l1 and l2 are their LayerID's) and record the Polyline points, then make Select (SelectArrayX) from Polyline and CastColorChange.

    if ( (l1 > -1) and (l2 > -1) ) then begin
      // Select AND Cast WORKS AS INTENDED
      ImageEnView1.LayersCurrent:= l1;
      ImageEnView1.Deselect();
      // Build Select Points From PolyLine
      for i:= 0 to Length(SelectArray1)-1 do begin
        ImageEnView1.AddSelPoint(SelectArray1[i].X, SelectArray1[i].Y);
      end; // for
      ImageEnView1.EndSelect();
      // With Mask or Without - same results
      TIEPolylineLayer(ImageEnView1.CurrentLayer).IsMask:= True;
      // Focus Base Image
      ImageEnView1.LayersCurrent:= 0;
      ImageEnView1.Proc.CastColorRange(iMinColor, iMaxColor, FloodColour); 
      ImageEnView1.Update();

      // Select AND Cast FAILS TO STAY WITHIN THE SELECT AREA - CHANGES THE WHOLE IMAGE
      ImageEnView1.LayersCurrent:= l2;
      ImageEnView1.Deselect();
      // Build Select Points From PolyLine
      for i:= 0 to Length(SelectArray2)-1 do begin
        ImageEnView1.AddSelPoint(SelectArray2[i].X, SelectArray2[i].Y);
      end; // for
      ImageEnView1.EndSelect();
      // With Mask or Without - same results
      TIEPolylineLayer(ImageEnView1.CurrentLayer).IsMask:= True;
      // Focus Base Image
      ImageEnView1.LayersCurrent:= 0;
      ImageEnView1.Proc.CastColorRange(iMinColor, iMaxColor, FloodColour); 
      ImageEnView1.Update();

      // Remove Polyline Layers
      ImageEnView1.LayersRemove(l2, False);
      ImageEnView1.LayersRemove(l1, False);
      // Focus Base Layer
      ImageEnView1.LayersCurrent:= 0;
    end;


Once Base Image has the first CastColorChange applied, the Base Image no longer responds correctly to the second CastColorChange process ???

Please advise how to accomplish - thanks in advance.


Andy

xequte

38611 Posts

Posted - Aug 28 2022 :  23:16:25  Show Profile  Reply
Hi Andy

Ensure that you have activated the layer that the selection should apply to before calling AddSelPoint().

In this case (most cases) you want the selection on the background image, so:

ImageEnView1.LayersCurrent := 0; // Selecting layer 0


Nigel
Xequte Software
www.imageen.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: