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
 Errors in TImageEnVect v4.3.0

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
ksvenkat Posted - Dec 17 2020 : 11:12:01
Dear Sir,
I am using TImageEnvect component (vers 4.3.0) with Image Kind IEKMemo in a tool. I wanted to achieve the following
- Insert an image into the component
- Add single or multiple text controls -> we used IEKMemo kind here
- Should change the text color, font size
- Save the image.
Here it should be possible to save the image at any time. i.e after adding single text or multiple texts

I made this but frequently i am getting Access violation and list index out of bounds issue.

I have attached the codesnippets used for changing the font color and size etc and then methods to save the image

Could you please advise me to overcome these issues ?

Code to change the font color and size


    Procedure Tftext.TryChangeFontSize(aImgPreview : TImageEnVect) ;
    Var
      iCTR, iSelObj : Integer ;
    Begin
      For iCTR := 0 to aImgPreview.SelObjectsCount-1 do begin
        iSelObj := aImgPreview.SelObjects[iCTR];
        aImgPreview.ObjFontHeight[iSelObj]   := CharInfo.Font.Size ;
        //aImgPreview.ObjFontStyles[iSelObj]   := CharInfo.Font.Style ;

        if BoldButton.Down then
          CharInfo.Font.Style := CharInfo.Font.Style + [fsBold]
        else
          CharInfo.Font.Style := CharInfo.Font.Style - [fsBold];

        if ItalicButton.Down then
          CharInfo.Font.Style := CharInfo.Font.Style + [fsItalic]
        else
          CharInfo.Font.Style := CharInfo.Font.Style - [fsItalic];

        if UnderlineButton.Down then
          CharInfo.Font.Style := CharInfo.Font.Style + [fsUnderline]
        else
          CharInfo.Font.Style := CharInfo.Font.Style - [fsUnderline];

        aImgPreview.ObjFontName[iSelObj]     := FontName.Text;
        aImgPreview.ObjFontStyles[iSelObj]   := CharInfo.Font.Style ;
        //aImgPreview.ObjTextEditable[iSelObj] := True ;
        aImgPreview.Update ;
      end;
    End;
-----------------------

procedure Tftext.Controls2MemoText(Sender: TObject);
var
  sText: String;
//  iCurrobj: Integer;
begin
  if not changing then
  begin

    changing := True;

    // sText := TImageEnvect(frmViewImage.PopupMenu.PopupComponent).ObjText[TImageEnvect(frmViewImage.PopupMenu.PopupComponent).SelObjects[0]];
    if frmViewImage.pgReport.TabIndex = 0 then
      CharInfo := frmViewImage.Imgpreview1.MemoEditingGetCharInfo
    else
      CharInfo := frmViewImage.Imgpreview2.MemoEditingGetCharInfo;

    // font
    if BoldButton.Down then
      CharInfo.Font.Style := CharInfo.Font.Style + [fsBold]
    else
      CharInfo.Font.Style := CharInfo.Font.Style - [fsBold];
    if ItalicButton.Down then
      CharInfo.Font.Style := CharInfo.Font.Style + [fsItalic]
    else
      CharInfo.Font.Style := CharInfo.Font.Style - [fsItalic];
    if UnderlineButton.Down then
      CharInfo.Font.Style := CharInfo.Font.Style + [fsUnderline]
    else
      CharInfo.Font.Style := CharInfo.Font.Style - [fsUnderline];
    CharInfo.Font.Name := FontName.Text;
    CharInfo.Font.Size := StrToIntDef(FontSize.Text, 10);
    CharInfo.Font.Color := ColorSelect.Brush.Color;
    // align
    if LeftAlign.Down then
      CharInfo.Align := iejLeft;
    if CenterAlign.Down then
      CharInfo.Align := iejCenter;
    if RightAlign.Down then
      CharInfo.Align := iejRight;
    if JustifyAlign.Down then
      CharInfo.Align := iejJustify;
    if frmViewImage.pgReport.TabIndex = 0 then
    Begin
      frmViewImage.Imgpreview1.MemoEditingSetCharInfo(CharInfo);
      TryChangeFontSize(frmViewImage.Imgpreview1);
    End
    Else
    Begin
      frmViewImage.Imgpreview2.MemoEditingSetCharInfo(CharInfo);
      TryChangeFontSize(frmViewImage.Imgpreview2);
    End;
    //CharInfo.free;
    changing := false;
  end;
end;



-------------------------------------------------------------------------

Code to save image with multiple objects


Procedure TfrmViewImage.SaveImage(aImg : TImageEnVect; abFirstRep : Boolean);
var
  sTempFile : String;
  iCntrlCnt : Integer;
  iObjCTR   : Integer ;
Begin
    Try
      if aImg.ObjectsCount > 0 then Begin

        ResetFontColor(aImg) ;
        aImg.CopyObjectsToBack(true);
        ResetFontColor(aImg) ; //doesn't change yet
        sTempFile := GetTempFileNameforSave(abFirstRep);
        aImg.IO.SaveToFileJpeg(sTempFile);

        aImg.RemoveAllObjects;

        if abFirstRep then Begin
          for iCntrlCnt := 0 to pnlFirstReport.ControlCount - 1 do Begin
            if (pnlFirstReport.Controls[iCntrlCnt] is TImageEnVect) and (UpperCase(pnlFirstReport.Controls[iCntrlCnt].Name) = 'IMGREP'+ IntToStr(aImg.Tag)) then Begin
              TImageEnVect(pnlFirstReport.Controls[iCntrlCnt]).IO.LoadFromFileJpeg(sTempFile);
              Break;
            End Else {no need};
          End; {end of for loop}
        End Else Begin
          for iCntrlCnt := 0 to pnlSecondReport.ControlCount - 1 do Begin
            if (pnlSecondReport.Controls[iCntrlCnt] is TImageEnVect) and (UpperCase(pnlSecondReport.Controls[iCntrlCnt].Name) = 'IMGREP'+ IntToStr(aImg.Tag)) then Begin
              TImageEnVect(pnlSecondReport.Controls[iCntrlCnt]).IO.LoadFromFileJpeg(sTempFile);
              Break;
            End Else {no need};
          End; {end of for loop}
        End;

      End Else {no need};


    Except
      On E : Exception do Begin
        CodeSite.Send('Error in saving modified image - ' + E.Message);
        Showmessage('Unable to save the image ' + #13+#10+#10 + E.Message);
      End;
    End;
  End;




TIA
Venkatesan




attach/ksvenkat/2020121711620_codeforedit_fontchanges.txt

attach/ksvenkat/2020121711712_CodeToSave with objects.txt

ksvenkat77
7   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Dec 28 2020 : 17:51:37
Hi

I'm afraid that email address does not match any customer on our system. Please email us.



Nigel
Xequte Software
www.imageen.com
ksvenkat Posted - Dec 28 2020 : 11:46:52
Dear Nigel

Please find below my Email for your reference: ks.venkatesan@gmail.com

Thank you


ksvenkat77
xequte Posted - Dec 22 2020 : 13:48:13
OK, please email us your details.



Nigel
Xequte Software
www.imageen.com
ksvenkat Posted - Dec 22 2020 : 06:31:48
Dear Nigel,

Thank you for your reply. Yes please it would be useful to get the latest IEVect.pas for comparison

TIA
Venkat

ksvenkat77
xequte Posted - Dec 21 2020 : 00:28:05
Hi Venkat

V4.3.0 is old version, so it hard to debug it without going through 8 years of code changes. Please email me and I will send you the updated source of ievect. You can then compare the two versions.



Nigel
Xequte Software
www.imageen.com
ksvenkat Posted - Dec 20 2020 : 06:11:41
Dear Nigel,

Thank you for your quick reply.

I tried your suggestions to narrow down the cause. It turns out that the first exception is being raised while removing the objects after the save operation using RemoveAllObjects method.

aImg.RemoveAllObjects;

I tried using the RemoveObjects() in a loop and the result is the same error.

Could you please help us to overcome this issue.

TIA
Best regards,
Venkat



ksvenkat77
xequte Posted - Dec 17 2020 : 14:16:04
Hi Venkatesan

I can't see anything particularly wrong in the code. Have you tried commenting out lines/blocks to see if you can narrow down the cause?

Also, v4.3.0 is eight years old. You should consider moving to a newer version (although, I can't be sure it will affect this issue as we have been moving more towards layers, than objects).

https://www.imageen.com/help/TImageEnVect_vs_TIELayers.html

Nigel
Xequte Software
www.imageen.com