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
 Layers HELP

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
AndyColmes Posted - Oct 13 2016 : 06:11:33
I upgraded ImageEn to the latest version 6.3.2 but layers seem to work a little strange.

I am trying to load an image in layer 0 and then another in layer 1. I would like to be able to move and resize layer 1. The same code for an older version of ImageEn works as expected but the latest version seem to load both images in layer 1 (see attached snapshot).

What went wrong on my end?

Thanks in advance.

Andy

ImageEnView1.MouseInteract := [ miMoveLayers, miResizeLayers ];
ImageEnView1.Proc.AutoUndo := False;
ImageEnView1.Proc.UndoLimit := 15;
ImageEnView1.LayersAdd;
ImageEnView1.Update;

ImageENView1.LayersCurrent := 0;
//ImageENView1.IEBitmap.Assign( stdView.IEBitmap );
ImageENView1.IO.LoadFromFile( fs1 );

ImageENView1.LayersCurrent := 1;
//ImageENView1.IEBitmap.Assign( stdView.IEBitmap );
ImageENView1.IO.LoadFromFile( fs2 );
ImageENView1.Update;



15   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Oct 17 2016 : 18:24:02
Hi Bill

Unfortunately it is a bug in v6.3.2. Please download the latest version from Git or email me for updated source.



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
w2m Posted - Oct 17 2016 : 09:52:38
Nigel,

I have shown that auto cursors are not functioning with layers. Can this be fixed? See my posts.

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
AndyColmes Posted - Oct 15 2016 : 08:32:03
Thanks again Bill. I will give it a peek and let you know.

Andy
w2m Posted - Oct 14 2016 : 10:39:23
I made a one line fix to the component source so that the mouse cursors appear without handling OnMouseMove in the project. Debugging a OnMouseMove event is difficult so there may be a better way to achieve this, but the fix seems to work. All I had to do is add an exit in the OnMouseMove event so the cursor code is executed and not overwritten by code following the exit. The exit is shown in boldface:

procedure TImageEnView.MouseMove(Shift: TShiftState; X, Y: Integer);

procedure _MoveSelLayers(iMoveX, iMoveY: Integer);
  var
    aLayer: TIELayer;
    i: Integer;
  begin
    if ( iMoveX = 0 ) and ( iMoveY = 0 ) then
      exit;

    for i := 0 to LayersCount - 1 do
    begin
      // Moving aLayer
      aLayer := TIELayer( fLayers[ I ]);
      if ( aLayer.Locked = False ) and aLayer.Selected then
      begin
        aLayer.PosX := aLayer.PosX - iMoveX;
        aLayer.PosY := aLayer.PosY - iMoveY;
      end;
    end;
  end;

  procedure _RotateSelLayers(Value: Double; bSnapToStep: Boolean);
  var
    aLayer: TIELayer;
    i: Integer;
  begin
    for i := 0 to LayersCount - 1 do
    begin
      // Rotating aLayer
      aLayer := TIELayer( fLayers[ I ]);
      if ( aLayer.Locked = False ) and ( aLayer.Selected or ( i = fRotatingLayer )) then
      begin
        if bSnapToStep then
          aLayer.Rotate := trunc( Value / fLayersRotateStep ) * fLayersRotateStep
        else
          aLayer.Rotate := Value;
      end;
    end;
  end;

var
  inLayerX, inLayerY: integer;
  grip: TIEGrip;
  ii: integer;
  layer: TIELayer;
  cx, cy: Integer;
  dx, dy: Double;
  max_x, max_y: Integer;
  ox, oy: Integer;
begin
  inherited;

  fSavedSelectionBase := fSelectionBase;
  fSelectionBase := iesbClientArea;

  inLayerX := ilimit( X, CurrentLayer.ClientAreaBox.Left, CurrentLayer.ClientAreaBox.Right + 1 );
  inLayerY := ilimit( Y, CurrentLayer.ClientAreaBox.Top, CurrentLayer.ClientAreaBox.Bottom + 1 );

  if not UserInteractions_MouseMoveExclusive(Shift, X, Y, MouseCapture) then
  begin

    if MouseCapture then
    begin

      // inside Mouse Capture

      if miScroll in fMouseInteract then
      begin
        // panning
        SetViewXY(fHSVX1 - trunc((X - fMouseDownX)*fMouseScrollRate), fHSVY1 - trunc((Y - fMouseDownY)*fMouseScrollRate) ); // 3.0.2
      end

      else
      if fRectResizing <> ieNone then
      begin
        // resize rectangular selection
        MouseMoveScroll;
        fRectResizing := SelectResizeEx(fRectResizing, inLayerX, inLayerY, (ssAlt in Shift) or fForceALTkey or (fSelectionAspectRatio>0));
        DoSelectionChanging;
      end

      else
      if fSelectMoving > -1 then
      begin
        // move selection
        if iesoCanScroll in fSelectionOptions then
          MouseMoveScroll;
        fSelectMoving := SelectMoveEx(fSelectMoving,
                                      CurrentLayer.ConvXScr2Bmp(inLayerX) - CurrentLayer.ConvXScr2Bmp(fPredX),
                                      CurrentLayer.ConvYScr2Bmp(inLayerY) - CurrentLayer.ConvYScr2Bmp(fPredY),
                                      iesoCutBorders in fSelectionOptions);
        DoSelectionChanging;
      end

      else
      if fRectSelecting then
      begin
        // select rectangle
        MouseSelectRectangle(inLayerX, inLayerY, Shift);
      end

      else
      if fPolySelecting then
      begin
        // select polygon
        MouseMoveScroll;
        Paint;
        PolyDraw1;
        AnimPolygonAddPtEx(fHPolySel, CurrentLayer.ConvXScr2Bmp(inLayerX), CurrentLayer.ConvYScr2Bmp(inLayerY));
        AniPolyFunc(self, true);
        DoSelectionChanging;
      end

      else
      if fCircSelecting then
      begin
        // select circle
        MouseSelectCircle(inLayerX, inLayerY, Shift);
      end

      else
      if (fMovingLayer > -1) then
      begin
        // Moving a layer
        layer := TIELayer(fLayers[fMovingLayer]);
        if not layer.Locked then
        begin
          if not fMovResRotLayerStarted and Proc.AutoUndo and ( loAutoUndoLayerChanges in fLayerOptions ) then
            Proc.SaveUndo(ieuLayer);
          fMovResRotLayerStarted := true;
          MouseMoveScroll;
          ox := Layer.PosX + ( XScr2Bmp(X) - XScr2Bmp(fPredLX));
          oy := Layer.PosY + ( YScr2Bmp(Y) - YScr2Bmp(fPredLY));
          fLayerMoved := ( ox <> layer.PosX ) or ( oy <> layer.PosY ) or fLayerMoved;
          _MoveSelLayers( layer.PosX - ox, layer.PosY - oy );
          SetInteractionHint('X=' + IntToStr( Layer.PosX ) + ' Y=' + IntToStr( Layer.PosY ), X, Y, 'X=000 Y=000');
          fUpdate_MaskCache := fMovingLayer;
          if fDelayZoomFilter then
            fStable := fStableReset;
          Update;
          if fLayerMoved then
            DoLayerNotify(fLayersCurrent, ielMoving);
        end;
      end

      else
      if fMovingRotationCenter > -1 then
      begin
        // moving rotation center
        layer := TIELayer(fLayers[fMovingRotationCenter]);
        layer.RotateCenterX := layer.ConvXScr2Bmp(X) / layer.Bitmap.Width;
        layer.RotateCenterY := layer.ConvYScr2Bmp(Y) / layer.Bitmap.Height;
        SetInteractionHint('X='+IntToStr(trunc(layer.RotateCenterX*layer.Width)) + ' Y='+IntToStr(trunc(layer.RotateCenterY*layer.Height)), X, Y, 'X=000 Y=000');
        fUpdate_MaskCache := fMovingRotationCenter;
        Update;
      end

      else
      if (fRotatingLayer > -1) then
      begin
        // Rotating a layer
        layer := TIELayer(fLayers[fRotatingLayer]);
        if not layer.Locked then
        begin
          if not fMovResRotLayerStarted and Proc.AutoUndo and ( loAutoUndoLayerChanges in fLayerOptions ) then
            Proc.SaveUndo(ieuFullLayer);
          fMovResRotLayerStarted := true;
          dx := ((XScr2Bmp(X) - XScr2Bmp(fPredLX)))/4;
          dy := ((YScr2Bmp(Y) - YScr2Bmp(fPredLY)))/4;
          cx := CurrentLayer.ConvXBmp2Scr( trunc(CurrentLayer.RotateCenterX * CurrentLayer.Bitmap.Width) );
          cy := CurrentLayer.ConvYBmp2Scr( trunc(CurrentLayer.RotateCenterY * CurrentLayer.Bitmap.Height) );
          if X > cx then
            dy := -dy;
          if Y < cy then
            dx := -dx;
          fRotatingLayerValue := fRotatingLayerValue + dx + dy;
          _RotateSelLayers( fRotatingLayerValue, ssShift in Shift );
          SetInteractionHint(IEFloatToStrS(layer.Rotate)+'°', X, Y, '0000°');
          fUpdate_MaskCache := fRotatingLayer;
          if fLayersRotationDelayFilterOnPreview then
            fStable := fStableReset;
          Update;
          DoLayerNotify(fLayersCurrent, ielRotating);
        end;
      end

      else
      if (fLayerResizing <> ieNone) and (not CurrentLayer.Locked) then
      begin
        // Resizing a layer
        if not fMovResRotLayerStarted and Proc.AutoUndo and ( loAutoUndoLayerChanges in fLayerOptions ) then
          Proc.SaveUndo(ieuLayer);
        if not fMovResRotLayerStarted then
          fLayersResizingAR := CurrentLayer.Height / CurrentLayer.Width;
        fMovResRotLayerStarted := true;
        MouseMoveScroll;
        MouseResizeLayer(X, Y, (ssAlt in Shift) or fForceALTkey);
        SetInteractionHint(IntToStr(CurrentLayer.Width)+' x '+IntToStr(CurrentLayer.Height), X, Y, '0000 x 0000');
        fUpdate_MaskCache := fLayersCurrent;
        Update;
        DoLayerNotify(fLayersCurrent, ielResizing);
      end;

      // out of Mouse Capture

    end
    else
    if fPolySelecting and not (fLassoSelecting) then
    begin
      PolyDraw1;
      if (ssAlt in Shift) or fForceALTkey then
        with PIEAnimPoly(fHPolySel)^ do
          if (PolyCount > 0) and (Poly^[PolyCount - 1].x <> IESELBREAK) then
            _CastPolySelCC(Poly^[PolyCount - 1].x - fViewX + fOffX, Poly^[PolyCount - 1].y - fViewY + fOffY, inLayerX, inLayerY);
      fMMoveX := inLayerX;
      fMMoveY := inLayerY;
      PolyDraw1;
      DoSelectionChanging;
    end
    else
    if (miSelect in fMouseInteract) or (miSelectPolygon in fMouseInteract) or
       (miSelectCircle in fMouseInteract) or
       (miSelectMagicWand in fMouseInteract) or (miSelectLasso in fMouseInteract) then
    begin
      grip := GetResizingGrip(X, Y, Shift);
      DoMouseInResizingGrip(grip);
      if grip = ieNone then
      begin
        ii := GetMovingGrip(X, Y, Shift);
        if ii > -1 then
          // moving cursor
          SetTempCursor(crIESizeAll)
        else
        begin
          // default cursor
          if (ssShift in Shift) and fEnableShiftKey then
          begin
            case cursor of
              crIECrossSight : SetTempCursor(crIECrossSightPlus);
              crIEThickCross : SetTempCursor(crIEThickCrossPlus);
            end;
          end
          else
            RestoreCursor;
        end;
      end
      else
      begin
        // resizing cursors
        case grip of
          ieTopLeft,  ieBottomRight: SetTempCursor(crIESizeNWSE);
          ieTopRight, ieBottomLeft:  SetTempCursor(crIESizeNESW);
          ieLeftSide, ieRightSide:   SetTempCursor(crIESizeWE);
          ieTopSide,  ieBottomSide:  SetTempCursor(crIESizeNS);
        end;
      end;
    end
    else
    if (miRotateLayers in fMouseInteract) then
    begin
      // layers rotation. Rotate only the currently selected layer.
      if IsPointInsideLayer(X, Y, fLayersCurrent) then
        RestoreCursor
      else
      begin
        cx := CurrentLayer.ConvXBmp2Scr( trunc(CurrentLayer.RotateCenterX * CurrentLayer.Bitmap.Width) );
        cy := CurrentLayer.ConvYBmp2Scr( trunc(CurrentLayer.RotateCenterY * CurrentLayer.Bitmap.Height) );
        if (X < cx) and (Y < cy) then
          SetTempCursor(crIERotateSE)
        else
        if (X < cx) and (Y > cy) then
          SetTempCursor(crIERotateNE)
        else
        if (X > cx) and (Y < cy) then
          SetTempCursor(crIERotateSW)
        else
        if (X > cx) and (Y > cy) then
          SetTempCursor(crIERotateNW);
      end;
    end
    else
    if ((miResizeLayers in fMouseInteract) or (miMoveLayers in fMouseInteract)) then
    begin
      grip := ieNone;
      if (miResizeLayers in fMouseInteract) then
      begin
        if LayersAllowMultiSelect then
          grip := FindLayerGripAnySel(X, Y)
        else                           
        if TIELayer(fLayers[fLayersCurrent]).Locked = False then
          grip := FindLayerGrip(X, Y);
      end;

      if grip = ieNone then
      begin
        ii := FindLayerAt(X, Y);
        if (ii > -1) and (not TIELayer(fLayers[ii]).Locked) and (miMoveLayers in fMouseInteract) then
          // moving cursor
          SetTempCursor(crIESizeAll)
        else
          // default cursor
          RestoreCursor;
      end
      else
      begin
        // resizing cursors
        case grip of
          ieTopLeft, ieBottomRight : SetTempCursor(crIESizeNWSE);
          ieTopRight, ieBottomLeft : SetTempCursor(crIESizeNESW);
          ieLeftSide, ieRightSide  : SetTempCursor(crIESizeWE);
          ieTopSide, ieBottomSide  : SetTempCursor(crIESizeNS);
        end;
        exit; // Temporary fix so correct cursor appears
      end;
    end;
  end;

  UserInteractions_MouseMove(Shift, X, Y, MouseCapture);

  // Rulers
  if fRulerParams.HandleMouseMove( Shift, X, Y ) then
    SetTempCursor( crDefault )
  else
    RestoreCursor;

  if (miMovingScroll in fMouseInteract) and ((fPredLx <> X) or (fPredLy <> Y)) and not MouseCapture then
  begin
    GetMaxViewXY(max_x, max_y);
    cx := trunc( (imax(imin(ClientWidth -1, X), 0)/(ClientWidth )-0.02) * 1.05 * (max_x) );
    cy := trunc( (imax(imin(ClientHeight-1, Y), 0)/(ClientHeight)-0.02) * 1.05 * (max_y) );
    SetViewXYSmooth( cx, cy );
  end;

  if fSelectionMask.IsPointInside(CurrentLayer.ConvXScr2Bmp(inLayerX), CurrentLayer.ConvYScr2Bmp(inLayerY)) then
    DoMouseInSel;

  fMMoveX := inLayerX;
  fMMoveY := inLayerY;
  fSelectionBase := fSavedSelectionBase;
  fPredX := inLayerX;
  fPredY := inLayerY;
  fPredLx := X;
  fPredLy := Y;
end;

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
AndyColmes Posted - Oct 13 2016 : 19:28:09
Thanks a million Bill. Your demos help tremendously.

Andy
w2m Posted - Oct 13 2016 : 15:23:10
Here is the demo which fixes the layer cursor problem in the component. The layer cursors are handled in the ImageEnView1.OnMouseMoveEvent.
attach/w2m/2016101315216_LayerCursors.zip
2481.95 KB

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
w2m Posted - Oct 13 2016 : 13:12:19
Add this to the demo to get correct cursor handling:
procedure TForm1.ImageEnView1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
var
  iGrip: TIEGrip;
  iLayer: integer;
begin
  if ((miResizeLayers in ImageEnView1.MouseInteract) or (miMoveLayers in ImageEnView1.MouseInteract)) then
    begin
      iGrip := ieNone;
      if (miResizeLayers in ImageEnView1.MouseInteract) then
      begin
        if loAllowMultiSelect in ImageEnView1.LayerOptions then
          iGrip := ImageEnView1.FindLayerGripAnySel(X, Y)
        else
        if TIELayer(ImageEnView1.Layers[ImageEnView1.LayersCurrent]).Locked = False then
          iGrip := ImageEnView1.FindLayerGrip(X, Y);
      end;
      if iGrip = ieNone then
      begin
        iLayer := ImageEnView1.FindLayerAt(X, Y);
        if (iLayer > -1) and (not TIELayer(ImageEnView1.Layers[iLayer]).Locked) and (miMoveLayers in ImageEnView1.MouseInteract) then
          // moving cursor
          ImageEnView1.Cursor:= crIESizeAll
        else
          // default cursor
          ImageEnView1.Cursor:= 1784;
      end
      else
      begin
        // resizing cursors
        case iGrip of
          ieTopLeft, ieBottomRight : ImageEnView1.Cursor:= crIESizeNWSE;
          ieTopRight, ieBottomLeft : ImageEnView1.Cursor:= crIESizeNESW;
          ieLeftSide, ieRightSide  : ImageEnView1.Cursor:= crIESizeWE;
          ieTopSide, ieBottomSide  : ImageEnView1.Cursor:= crIESizeNS;
        end;
      end;
    end;
end;

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
w2m Posted - Oct 13 2016 : 11:50:46
Try this demo:
attach/w2m/20161013114955_Layers.zip
55.7 KB
Here it works, except for the resize cursors.

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
w2m Posted - Oct 13 2016 : 11:29:42
Do your cursors appear when over a layer grip?

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
AndyColmes Posted - Oct 13 2016 : 11:06:53
Thanks for the response, Bill. After much going back and forth, I had to break the code into 2 parts in FormShow to make it work. Not sure why.

Andy

procedure TForml.LoadFile1;
begin
  with ImageENView1 do begin

    LayersCurrent := 0;

    Layers [ LayersCurrent ].Bitmap.Assign( stdView.IEBitmap );

    Update;
  end;
end;

procedure TForm1.LoadFile2;
begin
  with ImageENView1 do begin

    LayersAdd;

    LayersCurrent := 1;

    Layers [ LayersCurrent ].Bitmap.Assign( smpView.IEBitmap );
    Layers [ LayersCurrent ].PosX := 0;
    Layers [ LayersCurrent ].PosY := 0;
    Layers [ LayersCurrent ].Height := smpView.IEBitmap.Height;
    Layers [ LayersCurrent ].Width := smpView.IEBitmap.Width;
    Layers [ LayersCurrent ].Rotate := 0;
    Layers [ LayersCurrent ].RotateCenterX := 0;
    Layers [ LayersCurrent ].RotateCenterY := 0;

    MouseInteract := [ miMoveLayers, miResizeLayers ];

    Update;
  end;

end;

w2m Posted - Oct 13 2016 : 10:51:29
Selection and movement of layers works as expected here with 32-bit images except the resize cursors and drag cursor do not appear when the mouse is over a layer grip. You can still move and resize a layer however.

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
w2m Posted - Oct 13 2016 : 10:04:04
Please send me a small demo that shows the problem along with the two bitmaps so I can evaluate. Is the code you posted all the real code?

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
AndyColmes Posted - Oct 13 2016 : 10:01:31
Thanks for the tip, Bill. I set iesoSelectTranspLayers for SelectionOptions but I still get the same result. I also set Layers[ 1 ].Transparency to 128, thus that faded look.

What else could be wrong?

Andy
w2m Posted - Oct 13 2016 : 09:27:23
It appears that layer 1 contains a transparent (32-bit with alphachannel) bitmap so you need to set SelectionOptions to iesoSelectTranspLayers:
ImageEnView1.SelectionOptions := ImageEnView1.SelectionOptions +
      [iesoSelectTranspLayers];

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
AndyColmes Posted - Oct 13 2016 : 06:15:59
I did set LayersSync to False.

Andy