ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Errors in TImageEnVect v4.3.0
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

ksvenkat

India
6 Posts

Posted - Dec 17 2020 :  11:12:01  Show Profile  Reply
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

xequte

38627 Posts

Posted - Dec 17 2020 :  14:16:04  Show Profile  Reply
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
Go to Top of Page

ksvenkat

India
6 Posts

Posted - Dec 20 2020 :  06:11:41  Show Profile  Reply
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
Go to Top of Page

xequte

38627 Posts

Posted - Dec 21 2020 :  00:28:05  Show Profile  Reply
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
Go to Top of Page

ksvenkat

India
6 Posts

Posted - Dec 22 2020 :  06:31:48  Show Profile  Reply
Dear Nigel,

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

TIA
Venkat

ksvenkat77
Go to Top of Page

xequte

38627 Posts

Posted - Dec 22 2020 :  13:48:13  Show Profile  Reply
OK, please email us your details.



Nigel
Xequte Software
www.imageen.com
Go to Top of Page

ksvenkat

India
6 Posts

Posted - Dec 28 2020 :  11:46:52  Show Profile  Reply
Dear Nigel

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

Thank you


ksvenkat77
Go to Top of Page

xequte

38627 Posts

Posted - Dec 28 2020 :  17:51:37  Show Profile  Reply
Hi

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



Nigel
Xequte Software
www.imageen.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: