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
 ImageEnVect sometimes doesn't save objects

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
jonneve Posted - Apr 08 2016 : 08:43:58
Hi all,

I've got an ImageEnVect that I'm using to load photos which the end user can edit or add vector-based arrows to. I then save the edited photos to a database, in vector format so that the end user can move/delete the arrows later if necessary. Most of the time, it works, but from time to time, it ignores the changes made and doesn't save them correctly to the database, but I can't figure out why. Here's my code:


procedure TfmPhotoRetouche.SavePhoto;
var
  str: TStream;
begin
  if lImageChanged then
  begin
    qPoints.Edit;
    str := qPoints.CreateBlobStream(qPointsPHOTO_MODIFIEE, bmWrite);
    try
      qPoints.Edit;
      str.Seek(0, soFromBeginning);
      ImageEnVect.SaveToStreamAll(str);
    finally
      str.Free;
     end;
    qPoints.Post;
    lImageChanged := False;
  end;
end;

procedure TfmPhotoRetouche.qPointsBeforeScroll(DataSet: TDataSet);
begin
  SavePhoto;
end;

procedure TfmPhotoRetouche.qPointsAfterScroll(DataSet: TDataSet);
var
  str: TStream;
  f: TBlobField;
begin
  if qPointsPHOTO_MODIFIEE.IsNull then
    f := qPointsPHOTO_ORIGINALE
  else
    f := qPointsPHOTO_MODIFIEE;

  str := qPoints.CreateBlobStream(f, bmRead);
  try
    ImageEnVect.Clear;
    ImageEnVect.RemoveAllObjects;

    if f = qPointsPHOTO_ORIGINALE then
      ImageEnVect.IO.LoadFromStreamJpeg(str)
    else
      ImageEnVect.LoadFromStreamAll(str);
  finally
    str.Free;
   end;
  lImageChanged := false;
end;

procedure TfmPhotoRetouche.FormShow(Sender: TObject);
begin
  if fmMain.FormDocker.FormParameters[Self] <> nil then
    FDepart := fmMain.FormDocker.FormParameters[Self][0];

  lImageChanged := False;
  imageenvect.ObjEndShape[-1] := iesOUTARROW;
  imageenvect.ObjBrushColor[-1] := clRed;
  imageenvect.ObjBrushStyle[-1] := bsSolid;
  imageenvect.ObjPenWidth[-1] := 15;
  imageenvect.ObjPenColor[-1] := clRed;
  imageenvect.ObjAnchorToLayers := False;
  imageenvect.MouseInteractVt := [miObjectSelect];
  imageenvect.MouseInteract := [];
  ImageEnVect.SelectionAspectRatio := dmFich.tParamsPHOTOS_PROPORTIONS_RECADRAGE.Value;
  ImageEnVect.MouseWheelParams.Action := iemwZoom;
  ImageEnVect.MouseWheelParams.Variation := iemwPercentage;
  ImageEnVect.MouseWheelParams.value := 15;
  ImageEnVect.MouseWheelParams.InvertDirection := True;

  qPoints.Close;
  qPoints.ParamByName('depart').Value := FDepart;
  qPoints.Open;
end;

procedure TfmPhotoRetouche.ImageEnVectImageChange(Sender: TObject);
begin
  lImageChanged := True;
end;

procedure TfmPhotoRetouche.ImageEnVectNewObject(Sender: TObject; hobj: Integer);
begin
  qPoints.Edit;
  qPointsPHOTO_ETAT_RETOUCHE.Value := 2;
  btSelection.Click;
  lImageChanged := True;
end;

procedure TfmPhotoRetouche.ImageEnVectObjectMoveResize(Sender: TObject; hobj,
  Grip: Integer; var OffsetX, OffsetY: Integer);
begin
  qPoints.Edit;
  qPointsPHOTO_ETAT_RETOUCHE.Value := 2;
  lImageChanged := True;
end;



Is there anything obvious I'm doing wrong?

Thanks in advance,
Jonathan
1   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Apr 08 2016 : 20:46:42
Hi Jonathan

I don't know if it is the cause, but there are a number of issues in the code. In two events, you call Edit(), without calling Post() or Cancel(). And in your SavePhoto() event you call Edit() twice.



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com