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
 How do I save&recall ObjUserData in multiple 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
superdev Posted - Aug 06 2019 : 13:47:10
type
  TMyData=record
    szName: String[64];
    dMatch: double;
    Color : TColor;
  end;
  PMyData=^TMyData;

TMyGroup=class(TObject)
  private
    FszName : string;
  public
    imgSource : TImageEnVect;
    Light : TLight;
  published
   property Name : string read FszName write FszName;
end;


var    MyGroup : TObjectList;


function TfrmMain.Add_AreaVector(var imgTarget: TImageEnVect; Area: TArea): Boolean;
var i : Integer;
  rec : TRect;
  mydata: PMyData;
  t :  TMyData;
begin
  with imgTarget do begin
    rec.Left := Area.posXY.X;
    rec.Top := Area.posXY.Y;
    rec.Right := Area.posXY.X + Area.sizeXY.Width;
    rec.Bottom := Area.posXY.Y + Area.sizeXY.Height;
    i:=AddNewObject(iekTEXT,rec,Area.Color);
    ObjName[i] := Area.szName;
    ObjText[i] := Area.szName;
    ObjTextAlign[i] := iejCenter;
    ObjTextEditable[i]:=False;
    t.szName := Area.szName;
    t.dMatch := Area.dMatch;
    getmem(mydata, sizeof(TMyData));
    mydata^.szName := t.szName;
    mydata^.dMatch := t.dMatch;
    mydata^.Color := t.Color;
    ObjUserData[i] := mydata;
    ObjUserDataLength[i] := sizeof(TMyData);
  end;
end;

procedure TfrmMain.btnGroup_AddClick(Sender: TObject);
var Group_ : TMyGroup;
  Area_ : TArea;
begin
  imgView.RemoveAllObjects;

  Group_ := TMyGroup.Create;
  with Group_ do begin
    Name := edtGroupName.Text;
    imgSource := TImageEnVect.Create(nil);
    imgSource.Assign(imgView);
    Light.Top := edtControl_LightTop.Value;
    Light.Bottom := edtControl_LightBottom.Value;
  end;

  with Area_ do begin
    szName:='Align Start';
    dMatch := edtGroupMatch.FloatValue;
    sizeXY.Width := 120;
    sizeXY.Height := 120;
    posXY := Point(Round(imgView.Bitmap.Width * 1/4) - sizeXY.Width div 2,Round(imgView.Bitmap.Height * 1/2) - sizeXY.Height div 2 );
    Color := clFuchsia;
  end;
  Add_AreaVector(Group_.imgSource,Area_);

  with Area_ do begin
    szName:='Align End';
    dMatch := edtGroupMatch.FloatValue;
    sizeXY.Width := 120;
    sizeXY.Height := 120;
    posXY := Point(Round(imgView.Bitmap.Width * 3/4) - sizeXY.Width div 2,Round(imgView.Bitmap.Height * 1/2) - sizeXY.Height div 2 );
    Color := clFuchsia;
  end;
  Add_AreaVector(Group_.imgSource,Area_);
  MyGroup.Add(Group_);
  imgView.Assign(Group_.imgSource);
  Update_GroupGrid;
  grdGroup.Row:=MyGroup.Count;
end;


1   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Aug 07 2019 : 03:34:58
Hi

Have you tried the UserData demo:

Demos\VectorEditor\UserDataVect\UserDataVect.dpr

Nigel
Xequte Software
www.imageen.com