Recent

Author Topic: Load Very large image  (Read 4257 times)

aradeonas

  • Hero Member
  • *****
  • Posts: 824
Load Very large image
« on: April 14, 2016, 01:51:31 am »
Hi,

I want to load a very large image (20000*20000) with Lazarus and tried many things like TImage, BGRABitmap and OpenGL.
Problem is they all will face error because of memory size or texture limit.
I know I can split image into peases like mapping or load a resized version but I want to know how far I can go without these and then what is the best approach with way like theses and in the end is there any code that I can use?
Also I prefer to use it in OpenGL after image is loaded but texture is a limit.

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 754
Re: Load Very large image
« Reply #1 on: April 14, 2016, 02:52:11 am »
hello,
have a look to  imagemagick (imagemagick wrapper included in fp :  fpc\3.0.0\source\packages\imagemagick\src ). You need to install imagemagick in your computer.

Quote
ImageMagick can read, process, or write mega-, giga-, or tera-pixel image sizes. An image width or height can range from 1 to 2 giga-pixels on a 32 bit OS and up to 9 exa-pixels on a 64-bit OS. Note, that some image formats have restrictions on image size. For example, Photoshop images are limited to 300,000 pixels for width or height

Friendly, J.P
« Last Edit: April 14, 2016, 03:07:49 am by Jurassic Pork »
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

aradeonas

  • Hero Member
  • *****
  • Posts: 824
Re: Load Very large image
« Reply #2 on: April 14, 2016, 09:48:38 am »
Thanks Jurassic Pork, it is a powerful way but I like to have a no-dependency way.

circular

  • Hero Member
  • *****
  • Posts: 3195
    • Personal webpage
Re: Load Very large image
« Reply #3 on: April 14, 2016, 09:50:04 am »
Hi,

Such image would take 1.6 Gb in memory, even if it is split. So if the computer has loads of memory, that would be possible to have it in RAM. But that's not guaranteed a computer has so much memory.

So I would suggest to have a mechanism to load part of the image you need by splitting the image in tiles. For example, if it is a background that scrolls, the program can load the tiles that are visible. As you progress, the program can free the tiles are not visible anymore and load the new tiles.

If you need to display everything at the same time at a reduced size, then you would need to have prepared thumbnails. You can probably use imagemagick to prepare those thumbnails.
Conscience is the debugger of the mind

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8107
Re: Load Very large image
« Reply #4 on: April 14, 2016, 10:20:18 am »
The topic is loading, but I guess it is the displaying? Does loading in a TLazIntfImage or some fcl-image type work without displaying?

I myself have done similar tests for a smaller images and I found that the advertised texture sizes don't always work.

So tiling with say 4k x 4k images seems prudent.

aradeonas

  • Hero Member
  • *****
  • Posts: 824
Re: Load Very large image
« Reply #5 on: April 14, 2016, 03:58:04 pm »
The case is both, Loading and displaying.
Something like mapping as @circular said is a good way but @marcov do you know any good way to do this with any bitmap or OpenGL?
About loading no they cant load the Image as @circular it takes to much memory.
Yes I can make a tile system but is it needed to make it from beginning or there is one already or another way?

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8107
Re: Load Very large image
« Reply #6 on: April 14, 2016, 05:26:06 pm »
I would look at the openstreetmap demo here on the forum. That is a tiled based map.

But no, I haven't done it myself. I hit the limit when doing discovery for a project that would generate  a 8kpx wide image, but the project fell through.

aradeonas

  • Hero Member
  • *****
  • Posts: 824
Re: Load Very large image
« Reply #7 on: April 14, 2016, 05:30:42 pm »
I would look at the openstreetmap demo here on the forum. That is a tiled based map.

But no, I haven't done it myself. I hit the limit when doing discovery for a project that would generate  a 8kpx wide image, but the project fell through.
If you mean this I saw it, Thanks.

If there is other way especially done in OpenGL I appreciate to know about.
And also loading a large image like JPEG is a problem for it self even for parts. How can I read a tile of it?