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
 Working on drawing a rectangle on the Canvas below will increase the memory.
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

superdev

20 Posts

Posted - Apr 23 2023 :  13:26:10  Show Profile  Reply
Working on drawing a rectangle on the Canvas below will increase the memory. There is no memory increase if commented out.
what's the problem?? I can't possibly know.



Try
    ObjCount := _imgRef.ObjectsCount;
    _imgFind := TImageEnView.Create(nil);
    _imgBackground := TImageEnView.Create(nil);
    for i := 0 to ObjCount-1 do begin
      hObj := _imgRef.GetObjFromIndex(i);
      szPara := _imgRef.ObjName[hobj];
      if pos('GRID',szPara)>0 then begin
        ObjType := otGrid;
      end else begin
        ObjType := otLine;
      end;
      if ObjType = otGrid then begin
        MyGetString(',',1,szPara,szValue);
        cx :=  szValue.ToInteger();
        MyGetString(',',2,szPara,szValue);
        cy :=  szValue.ToInteger();
        MyGetString(',',3,szPara,szValue);
        nMatch := szValue.ToInteger();
        for y := 0 to cy-1 do begin
          for x := 0 to cx-1 do begin
            _imgFind.Clear;
            _imgBackground.Clear;
            Core.VisionPro.Get_GridImage(_imgRef,i, cx,cy,x,y,_imgFind,rec_);
            _imgBackground.IEBitmap.Width := rec_.Width + nTolerance*2;
            _imgBackground.IEBitmap.Height := rec_.Height + nTolerance*2;
            imgProcess.IEBitmap.CopyRectTo(_imgBackground.IEBitmap,rec_.Left-nTolerance, rec_.Top-nTolerance,0,0, rec_.Width+nTolerance * 2, rec_.Height+nTolerance * 2);
            dRank := Core.VisionPro.FindImage(_imgFind,_imgBackground,frec_);
            if dRank < nMatch then begin
              imgProcess.IEBitmap.Canvas.Brush.Style :=bsClear;
              imgProcess.IEBitmap.Canvas.Pen.Width :=3;
              imgProcess.IEBitmap.Canvas.Pen.Color :=clRed;
              inc(nNG);
            end else begin
              imgProcess.IEBitmap.Canvas.Brush.Style :=bsClear;
              imgProcess.IEBitmap.Canvas.Pen.Width :=3;
              imgProcess.IEBitmap.Canvas.Pen.Color :=clLime;
            end;
//            imgProcess.IEBitmap.Canvas.Rectangle(rec_);
          end;
        end;
      end;
    end;
  finally
    _imgFind.Free;
    _imgBackground.Free;
  End;

xequte

38610 Posts

Posted - Apr 23 2023 :  17:46:21  Show Profile  Reply
Hi

If you access theTCanvas of TIEBitmap, it will change the state to ieTBitmap (i.e. store the image in memory as a TBitmap), which is presumably what is happening here.

https://www.imageen.com/help/TIEBitmap.Location.html


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