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
 How to buffer display for large images
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

AndyColmes

USA
351 Posts

Posted - Jun 06 2018 :  11:11:05  Show Profile  Reply
I need to display large images like maps and I run into a lot of "not enough storage" memory issues usually when zooming or panning around the image with TImageEnVect.

Is there a way to load only the portion of the image in view and will this help with the "not enough storage" issue?

A sample code would help greatly.

Thanks in advance!

Andy

xequte

38179 Posts

Posted - Jun 06 2018 :  15:38:04  Show Profile  Reply
Hi Andy

That should be handled automatically. Can you check that ImageEnVect1.LegacyBitmap = False.

I assume you have not made any changes to:

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


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

AndyColmes

USA
351 Posts

Posted - Jun 07 2018 :  02:05:38  Show Profile  Reply
Hi Nigel,

I did do the ieFile for Location and LegacyBitmap to False, but I did not do the MinFileSize. MinFileSize really helped tremendously.

Thanks Nigel..

Andy
Go to Top of Page

AndyColmes

USA
351 Posts

Posted - Jun 07 2018 :  03:20:51  Show Profile  Reply
Hi Nigel,

There is still a threshold where very large images still get the "not enough storage" issue. It usually happens in the zooming, but commands like Fit To Window or Actual Size does not trigger the error. Either zooming with the mouse or a trackbar gives that error. I was wondering if there is any way to get around it..

Andy
Go to Top of Page

xequte

38179 Posts

Posted - Jun 07 2018 :  06:22:58  Show Profile  Reply
Hi Andy

Can you send me the test file and instructions to reproduce?


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

AndyColmes

USA
351 Posts

Posted - Jun 11 2018 :  06:05:58  Show Profile  Reply
Hi Nigel,

This is a sample file that is causing the issue. It is a big file. Basically, I wrote this function to remove the gray and highlight whites and blacks. This function works fine for small images but with large images, it gives out of memory. Is there a way to make this function work for large images?


Thanks Nigel. I appreciate any help you can offer.


Files:
https://mega.nz/#!TII2AJ5I!Tai-CJUCbplBgNmMfDf9gJgTs91r7agXuU3SuliqvfY


Calling:
DoColorizeMap2( 'FCS1.bmp', 'FCS2.bmp', 'outfile.png', True, 1 );


procedure TForm3.DoColorizeMap2( tmpStandard, tmpDefect, tmpOutput: string; colorized: Boolean; clrmode: Integer );
var
  VTemp: TImageEnVect;
  beginDiffColor: TColor;
  endDiffColor: TColor;
  beginMissColor: TColor;
  endMissColor: TColor;
  newColor: TColor;
  w: Integer;
  h: Integer;
  map: array [0..255] of TRGB;
  i: Integer;
  ImgProc: TImageEnProc;
  Bmp: TIEBitmap;
begin
 beginDiffColor := $00525252;
 endDiffColor := $00989898;

 beginMissColor := $00010101;
 endMissColor := $00090909;

 newColor := clWhite;

 try

  Bmp := TIEBitmap.Create( tmpDefect );
  Bmp.Location := ieFile;
  // Make current bitmap use file storage if image is larger than 1MB
  Bmp.MinFileSize := 1 * 1024 * 1024;

  ImgProc := TImageEnProc.Create( Self );
  ImgProc.AttachedIEBitmap := Bmp;

  try

    ImgProc.CastColorRange(TColor2TRGB(beginDiffColor), TColor2TRGB(endDiffColor), TColor2TRGB(newColor));
    ImgProc.SetTransparentColors(TColor2TRGB(clWhite), TColor2TRGB(clWhite), 0);

    ImgProc.CastColorRange(TColor2TRGB(beginMissColor), TColor2TRGB(endMissColor), TColor2TRGB(clGray));

    ImgProc.Update;

    if (colorized = True) then begin
        if (clrmode = 0) then begin
         //Method 1
         ImgProc.Colorize(40, 50, 1.1);
        end else if (clrmode = 1) then begin
         //Method 2
         for i := 0 to 255 do begin
           map[i].r := i;
           map[i].g := 255-i;
           map[i].b := i;
         end;
         ImgProc.MapGrayToColor(map);
        end;
     ImgProc.Update;
    end;

    w := Bmp.Width;
    h := Bmp.Height;

  finally

    Bmp.Write( tmpOutput );


   FreeAndNil( ImgProc );
   FreeAndNil( Bmp );
  end;

 except
    on E : Exception do
       ShowMessage(E.ClassName+' error raised, with message : '+E.Message);
 end;
end;

Go to Top of Page

xequte

38179 Posts

Posted - Jun 12 2018 :  16:29:58  Show Profile  Reply
I'm sorry, SampleFiles.rar comes through as corrupted.

Also, does the memory issue consistently occur in a particular area of this code?

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

AndyColmes

USA
351 Posts

Posted - Jun 13 2018 :  10:59:43  Show Profile  Reply
Hi Nigel, sorry for the corrupted file. I uploaded it again:

https://mega.nz/#!jJojABgJ!09E_vRt0SmeP3rg2BaJ4DnORjqLt1miT17XWzVnzaXo

I'm not sure if the memory issue happens in any particular part of the code. I think it is the size of the file that seems to cause the memory issue.

The function that I wrote should just be DoColorizeMap2( 'Test.bmp', 'output.png', 1 ) instead of what I had given earlier.

Thanks Nigel for your help.

Andy
Go to Top of Page

xequte

38179 Posts

Posted - Jun 13 2018 :  17:07:16  Show Profile  Reply
Hi Andy

I just looped this code 100 times (phew, took twenty minutes to run), but did not see any error. Memory for the app peaked at 1GB, but remainined constant.

What are the specs of the system?


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

AndyColmes

USA
351 Posts

Posted - Jun 20 2018 :  10:40:27  Show Profile  Reply
Hi Nigel, the specs are high (i7 with 32GB of RAM and SSD).. I compiled the code alone in a console application and it seems to work like you, but when it is run in an application that has other stuff in it like 2 TImageEnVects and 2 TImageEnViews, for example, the memory bombs out when I run the code inside the application.

Andy
Go to Top of Page

xequte

38179 Posts

Posted - Jun 20 2018 :  15:37:00  Show Profile  Reply
Hi Andy

We've now tested on multiple machines. The only time we can reproduce the error is when there is less than 1GB of disk space left on the system (i.e. disk caching fails).

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