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
 DragDrop map pin

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 - Feb 28 2016 : 09:46:07
Hello, I would like to drag something and drop onto a TImageEnVect and create an image object on the spot in code. I also need to get the point where the drop happened so I can get a color sample of the spot. The image object should be transparent and have no borders. What is the best way to go about doing this?

Thanking you all in advance.

Andy
9   L A T E S T    R E P L I E S    (Newest First)
AndyColmes Posted - Mar 04 2016 : 01:03:26
Hi Bill, thank you very much. That is exactly what I wanted to achieve.

Andy
w2m Posted - Mar 02 2016 : 08:24:20
To remove the grips add ievsHideGrips to ObjStyle:
procedure TForm1.ImageEnVect1DragDrop(Sender, Source: TObject; X, Y: Integer);
const
  TA: array [0 .. 3] of TIEAlignment = (iejLeft, iejRight, iejCenter,
    iejJustify);
  PS: array [0 .. 6] of TPenStyle = (psSolid, psDash, psDot, psDashDot,
    psDashDotDot, psClear, psInsideFrame);
  BS: array [0 .. 7] of TBrushStyle = (bsSolid, bsClear, bsBDiagonal,
    bsFDiagonal, bsCross, bsDiagCross, bsHorizontal, bsVertical);
var
  ihObj: Integer;
begin
  if Source is TImageEnView then
  begin
    ImageEnVect1.ObjSaveUndo;
    ImageEnVect1.ObjStyle[IEV_NEXT_INSERTED_OBJECT] := ImageEnVect1.ObjStyle
      [IEV_NEXT_INSERTED_OBJECT] + [ievsHideGrips];
    ihObj := ImageEnVect1.AddNewObject;
    ImageEnVect1.MouseInteractVt := [miPutBitmap];
    ImageEnVect1.ObjKind[ihObj] := iekBITMAP;
    ImageEnVect1.ObjBitmap[ihObj] := ImageEnView1.IEBitmap;
    ImageEnVect1.ObjStyle[ihObj] := ImageEnVect1.ObjStyle[ihObj] + [ievsHideGrips];
    ImageEnVect1.ObjName[ihObj] :=
      AnsiString('Bitmap ' + IntToStr(ImageEnVect1.ObjectsCount));
    ImageEnVect1.ObjWidth[ihObj] := ImageEnView1.IEBitmap.Width;
    ImageEnVect1.ObjHeight[ihObj] := ImageEnView1.IEBitmap.Height;
    ImageEnVect1.ObjLeft[ihObj] := ImageEnVect1.Layers
      [ImageEnVect1.LayersCurrent].ConvXScr2Bmp(X);
    ImageEnVect1.ObjTop[ihObj] := ImageEnVect1.Layers
      [ImageEnVect1.LayersCurrent].ConvYScr2Bmp(Y);
    ImageEnVect1.MouseInteractVt := [miObjectSelect];
    ImageEnVect1.UnSelAllObjects;
    ImageEnVect1.SelObjects[ihObj];
    ImageEnVect1.AddSelObject(ihObj);
  end;
end;
To paint the border with a color when selected set the ObjPenColor:
procedure TForm1.ImageEnVect1SelectObject(Sender: TObject);
var
  i: Integer;
  ihObj: Integer;
begin
  for i := ImageEnVect1.ObjectsCount - 1 downto 0 do
  begin
    ihObj := ImageEnVect1.GetObjFromIndex(i);
    if ImageEnVect1.IsSelObject(ihObj) then
    begin
      ImageEnVect1.ObjPenColor[ihObj] := clBlue;
      ImageEnVect1.ObjBitmapBorder[ihObj] := True;
    end
    else
    begin
      ImageEnVect1.ObjPenColor[ihObj] := clNone;
      ImageEnVect1.ObjBitmapBorder[ihObj] := False;
    end;
  end;
  ImageEnVect1.Update;
end;
Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
AndyColmes Posted - Mar 01 2016 : 21:03:58
Hi Bill, I would like to have a color border around the bitmap object instead of the resizing grip handles. How would I do this?

Thanks Bill.

Andy
AndyColmes Posted - Mar 01 2016 : 04:01:45
Hi Bill, fantastic. Thank you for the tip as usual.

Andy
w2m Posted - Feb 29 2016 : 12:38:58
procedure TForm1.ImageEnVect1SelectObject(Sender: TObject);
{ Show bitmap border if selected. }
var
  i: Integer;
  ihObj: Integer;
begin
  for i := ImageEnVect1.ObjectsCount - 1 downto 0 do
  begin
    ihObj := ImageEnVect1.GetObjFromIndex(i);
    if ImageEnVect1.IsSelObject(ihObj) then
      ImageEnVect1.ObjBitmapBorder[ihObj] := True
    else
      ImageEnVect1.ObjBitmapBorder[ihObj] := False;
  end;
  ImageEnVect1.Update;
end;

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
AndyColmes Posted - Feb 29 2016 : 11:44:20
Thank you Bill and Nigel. Your code helped me a lot to work this through. I am dragging info from a DevExpress Grid and upon dropping that to a TImageEnVect, I am creating a bitmap object with the properties defined in the dragobject.

I am using a transparent map pin image (png) like in your example code. How do I define some kind of color border on the selected bitmap object and no border on the unselected ones?

Andy
w2m Posted - Feb 29 2016 : 08:54:46
Simple drag and drop from TimageEnView to TImageEnVect bitmap object:
procedure TForm1.FormCreate(Sender: TObject);
begin
  ImageEnView1.IO.LoadFromFile('Pin.png');
  ImageEnVect1.ObjBitmapHandleTransparencyOnSel := True;
  ImageEnVect1.ObjBoxInnerSelectable := True;
  ImageEnVect1.SelectionOptions := ImageEnVect1.SelectionOptions +
    [iesoSelectTranspLayers];
end;

procedure TForm1.ImageEnVect1DragDrop(Sender, Source: TObject; X, Y: Integer);
const
  TA: array [0 .. 3] of TIEAlignment = (iejLeft, iejRight, iejCenter,
    iejJustify);
  PS: array [0 .. 6] of TPenStyle = (psSolid, psDash, psDot, psDashDot,
    psDashDotDot, psClear, psInsideFrame);
  BS: array [0 .. 7] of TBrushStyle = (bsSolid, bsClear, bsBDiagonal,
    bsFDiagonal, bsCross, bsDiagCross, bsHorizontal, bsVertical);
var
  ihObj: Integer;
begin
  if Source is TImageEnView then
  begin
    ImageEnVect1.ObjSaveUndo;
    ImageEnVect1.ObjStyle[IEV_NEXT_INSERTED_OBJECT] := ImageEnVect1.ObjStyle
      [IEV_NEXT_INSERTED_OBJECT] + [ievsSelectable, ievsMoveable, ievsSizeable,
      ievsVisible];
    ihObj := ImageEnVect1.AddNewObject;
    ImageEnVect1.MouseInteractVt := [miPutBitmap];
    ImageEnVect1.ObjKind[ihObj] := iekBITMAP;
    ImageEnVect1.ObjBitmap[ihObj] := ImageEnView1.IEBitmap;
    ImageEnVect1.ObjName[ihObj] :=
      AnsiString('Bitmap ' + IntToStr(ImageEnVect1.ObjectsCount));
    ImageEnVect1.ObjWidth[ihObj] := ImageEnView1.IEBitmap.Width;
    ImageEnVect1.ObjHeight[ihObj] := ImageEnView1.IEBitmap.Height;
    ImageEnVect1.ObjLeft[ihObj] := ImageEnVect1.Layers
      [ImageEnVect1.LayersCurrent].ConvXScr2Bmp(X);
    ImageEnVect1.ObjTop[ihObj] := ImageEnVect1.Layers
      [ImageEnVect1.LayersCurrent].ConvYScr2Bmp(Y);
    ImageEnVect1.MouseInteractVt := [miObjectSelect];
    ImageEnVect1.UnSelAllObjects;
    ImageEnVect1.SelObjects[ihObj];
    ImageEnVect1.AddSelObject(ihObj);
  end
  else
  begin
    ImageEnVect1.MouseInteractVt := [miObjectSelect];
    ImageEnVect1.UnSelAllObjects;
  end;
end;

procedure TForm1.ImageEnVect1DragOver(Sender, Source: TObject; X, Y: Integer;
  State: TDragState; var Accept: Boolean);
begin
  Accept := Source is TImageEnView;
end;

procedure TForm1.LoadObjectBitmap1Click(Sender: TObject);
var
  i: Integer;
  iFilename: string;
  ihObj: Integer;
begin
  if OpenPictureDialog1.Execute then
    iFilename := OpenPictureDialog1.FileName;
  if FileExists(iFilename) then
  begin
    ImageEnView1.IO.LoadFromFile(iFilename);
    for i := ImageEnVect1.ObjectsCount - 1 downto 0 do
    begin
      ImageEnVect1.ObjSaveUndo;
      ihObj := ImageEnVect1.GetObjFromIndex(i);
      if ImageEnVect1.IsSelObject(ihObj) then
      begin
        ImageEnVect1.ObjBitmap[ihObj] := ImageEnVect1.IEBitmap;
        ImageEnVect1.Update;
      end;
    end;
  end;
end;

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
xequte Posted - Feb 28 2016 : 16:57:28
Hi Andy

This demo might help too:

http://www.imageen.com/ieforum/topic.asp?TOPIC_ID=2472


Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
w2m Posted - Feb 28 2016 : 10:47:09
1. You said you are dragging something... what component are you dragging from?
2. Should the dropped bitmap object contain an image when it is dropped?
3. You said you want to get the color from the point where the object is dropped, but do you want to get the color from the background bitmap or from the dropped bitmap object? What are you going to do the color?
4. You said the image object should be transparent and have no borders. Do you mean the dropped bitmap should just have a transparent alpha channel such as a 32-bit RGBA png image or should the bitmap be entirely transparent? By the title of your post I assume the dropped bitmap will be a transparent png image that looks like a map pin?
5. If the bitmap is a map pin, can you post a transparent png image of the map pin?

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development