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
 CreatePolygonsFromSelection out of memory
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

AndyColmes

USA
351 Posts

Posted - Feb 15 2016 :  13:26:28  Show Profile  Reply
I am unable to call ImageEnVect1.CreatePolygonsFromSelection to create a polygon object since it keeps giving me a "out of memory" error. Is there an alternative to create a polygon object from a selection?

Thanks in advance.

Andy

xequte

39209 Posts

Posted - Feb 15 2016 :  17:32:08  Show Profile  Reply
Hi Andy

What version are you using? Can you give us the steps to reproduce this issue?

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

AndyColmes

USA
351 Posts

Posted - Feb 16 2016 :  01:12:55  Show Profile  Reply
Hello Nigel, I am using the latest version 6.2.2. I just set the MouseInteract to allow making a Polygon selection and when it is closed, I called CreatePolygonsFromSelection.

ImageEnVect1.MouseInteract := [miSelectPolygon];

ImageEnVect1.CreatePolygonsFromSelection;

If I make a small selection, the error does not happen. Is there a way to get around this? I am not allowed to resize the whole image to a smaller size.

Thanks Nigel.

Andy

Go to Top of Page

xequte

39209 Posts

Posted - Feb 18 2016 :  17:02:41  Show Profile  Reply
Hi Andy

I cannot reproduce that even with highly complex selections.



Is there any more information you can give me?

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

AndyColmes

USA
351 Posts

Posted - Feb 19 2016 :  08:15:20  Show Profile  Reply
Hi Nigel, thanks for checking this for me. It seems to happen when my file is a TIF file. I converted it to a JPG which reduces its size dramatically and the error disappears. But the TIF file definitely gives the error.

I am trying to make a selection around each label image in the TIF file and convert the selection to a polygon object.

https://onedrive.live.com/redir?resid=3C7651B735240773!61019&authkey=!AC_PrsJJ7QhryBg&ithint=file%2czip

Thanks Nigel. I hope you can reproduce this on your end.

Andy
Go to Top of Page

spetric

Croatia
308 Posts

Posted - Feb 19 2016 :  14:28:35  Show Profile  Reply
Hi Andy,

I've tried with my prog. (built with Ien 5.2.0) and yes, it crashes when four selections are marked (using shift key). I'm converting selections into vector polygons and draw strokes through polygon points. Here is Eurekalog screen (if it can be of any help):

Go to Top of Page

AndyColmes

USA
351 Posts

Posted - Feb 19 2016 :  15:17:34  Show Profile  Reply
Thanks very much Spetric. I am doing the same functions too. I hope there is a fix for this.

Andy
Go to Top of Page

xequte

39209 Posts

Posted - Feb 21 2016 :  19:42:39  Show Profile  Reply
Hi Andy

Tested that TIFF and still had no failure. What version of Delphi are you on?

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

AndyColmes

USA
351 Posts

Posted - Feb 22 2016 :  07:46:53  Show Profile  Reply
Hi Nigel, I am using Delphi Seattle 10 with the latest ImageEn 6.2.2, although I have similar results with XE6 Update 1 as well.

Andy
Go to Top of Page

spetric

Croatia
308 Posts

Posted - Feb 23 2016 :  06:49:48  Show Profile  Reply
Hi,

I've tried with C++ XE5 32-bit and Ien 6.2.2 and the error "out of memory" is thrown in CreatePolygonsFromSelection method.

I've used lasso selection and selected four labels (roughly).
This is selection scenario that produces error:



Go to Top of Page

xequte

39209 Posts

Posted - Feb 23 2016 :  13:10:39  Show Profile  Reply
OK, thanks. We wil investigate.

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

AndyColmes

USA
351 Posts

Posted - Feb 25 2016 :  09:25:09  Show Profile  Reply
Thank you spetric and Nigel. I have also encountered "Floating point error" when calling CopySelectionToBitmap after making the polygon selection with the same file. I think the issue could be related.

Andy
Go to Top of Page

xequte

39209 Posts

Posted - Feb 28 2016 :  20:54:58  Show Profile  Reply
Hi

We have an update to improve the memory handling (though still not fast with very large selections). Email us if you want the updated source.



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

AndyColmes

USA
351 Posts

Posted - Mar 01 2016 :  03:57:50  Show Profile  Reply
Hi Nigel,

My associate, Jenny have sent you an email requesting the update. Thanks again, Nigel.

Andy
Go to Top of Page

AndyColmes

USA
351 Posts

Posted - Mar 03 2016 :  23:22:47  Show Profile  Reply
Hi Nigel, thanks for the updated code. Unfortunately, I am still getting the error. I created a polygon object using the same image file by manually drawing it. I then save it to .iev file. I would load it back and do the following:



                    if (ImageEnVect1.ObjKind[0] = IEKPolyLine) or (ImageEnVect1.ObjKind[0] = IEKEllipse) then begin
                      for x:=0 to ImageEnVect1.ObjPolylinePointsCount[0]-1 do
                         ImageEnVect1.AddSelPoint( ImageEnVect1.ObjPolylinePoints[0, x].x, ImageEnVect1.ObjPolylinePoints[0, x].y );
                      ImageEnVect1.EndSelect();
                    end;

                    ImageEnVect1.RemoveAllObjects;
                    ImageEnVect1.Update;

                    Bmp := TBitmap.Create;
                    try
                      ImageEnVect1.CopySelectionToBitmap( Bmp, True );

                      FTempVect.Bitmap.Assign( Bmp );
                      FTempVect.Update;

                      FTempVect.IO.SaveToFileBMP( fsc );         <--- Error (Floating point)
                    finally
                      Bmp.Free;
                    end;



I get a floating point error. This code works with smaller files or smaller selection but not with this file for some reason.

Can you verify if you can reproduce this error?

Thanks again.

Andy
Go to Top of Page

AndyColmes

USA
351 Posts

Posted - Mar 04 2016 :  01:23:17  Show Profile  Reply
I did a test where I created a rectangle object instead of a polygon and it also seems to fail. There is no error but it appears to hang:


                    if (ImageEnVect1.ObjKind[0] = IEKBOX) then begin
                       x1:=ImageEnVect1.ObjLeft[0];
                       y1:=ImageEnVect1.ObjTop[0];
                       x2:=(ImageEnVect1.ObjWidth[0]+ImageEnVect1.ObjLeft[0]);
                       y2:=(ImageEnVect1.ObjHeight[0]+ImageEnVect1.ObjTop[0]);

                       ImageEnVect1.Select( x1, y1, x2, y2, iespReplace  );
                    end;


It looks like the issue is the CopySelectionToBitmap for all cases, at least with my sample file.

Andy
Go to Top of Page

w2m

USA
1990 Posts

Posted - Mar 06 2016 :  07:59:35  Show Profile  Reply
I assume you are compiling with Win32 platform. Try compiling with Win64 platform and see if the error still occurs.

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
Go to Top of Page

AndyColmes

USA
351 Posts

Posted - Mar 07 2016 :  11:55:36  Show Profile  Reply
Hi Bill, yes I am compiling with Win32 because I don't have a choice. The other libraries that are in the application are not 64-bit compliant...yet. So, I am in a bind...

Andy
Go to Top of Page

xequte

39209 Posts

Posted - Mar 07 2016 :  18:47:23  Show Profile  Reply
Hi Andy

Your first bit of code is wrong. You can't use ImageEnVect1.ObjKind[ 0 ], because TImageEnVect objects are not indexed, but listed by hObj, so you must call:

    ihobj := ImageEnVect1.GetObjFromIndex( 0 );
    if (ImageEnVect1.ObjKind[ ihobj ] = IEKPolyLine) or (ImageEnVect1.ObjKind[ ihobj ] = IEKEllipse) then
    begin
      for x:=0 to ImageEnVect1.ObjPolylinePointsCount[ ihobj ]-1 do
         ImageEnVect1.AddSelPoint( ImageEnVect1.ObjPolylinePoints[ ihobj, x ].x, ImageEnVect1.ObjPolylinePoints[ ihobj, x ].y );
      ImageEnVect1.EndSelect();
    end;


Also, what is the purpose of FTempVect? If it is just for saving your BMP, then you can just make BMP a TIEBitmap and call BMP.write( fsc );

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

AndyColmes

USA
351 Posts

Posted - Mar 09 2016 :  04:32:12  Show Profile  Reply
Thanks Nigel, I will make the changes and report back.

Andy
Go to Top of Page

AndyColmes

USA
351 Posts

Posted - Mar 12 2016 :  23:57:04  Show Profile  Reply
Hi Nigel, GetObjFromIndex helped to get his solved. Thanks very much for solving this very nagging issue for a while now.

Andy
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: