Load large image like size 1.5GB and width 81000 and height 180000

Hi

I am new to SDL.

How to load the larger size image. for example image size is 1.5GB width 81000 Height 180000.

and i need to scroll the images.

Kindly do the needful.

I am pretty sure you will need to break up your images / textures.
4096x4096 is probably the best you can expect.

Can you explain the need why and we might be able to offer a different solution.

Hi
Thanks for your reply.
I am pretty sure you will need to break up your images / textures.
Without breaking possible?

Can you explain the need why and we might be able to offer a different solution.

I have different type of dpi images like 300,500,640,700,1000,1280,1920 and 3000
I need to load the image and scrolling from left to right and find the speed or velocity. Does it possible?
based on speed like 10 , 15, 20 pixel it should scroll based on user input.

If you have any idea , let me know .

Thanks

I have done something very similar for the background of a side-scroller video game. It was necessary to split the image into multiple textures because of the size limitation (which varies significantly between platforms) but you ‘cannot see the joins’ and the end result was perfectly satisfactory for my application.

Hi

Glad to hear you have done that. can you give some idea how to do that? Spliting image using SDL or some other tools. if you can , can you share the source code. Kindly do the needful.

Thanks.

If your image is in an uncompressed format like BMP you may be able to split it into multiple textures when loaded. If it’s compressed, like JPG or PNG, you will probably need to load it into a large surface (as far as I know there is no limit on the size of a surface) and then use SDL_BlitSurface() to split it into smaller surfaces which can be converted to textures using SDL_CreateTextureFromSurface().

I don’t think my code would be very useful to you because it was written in BBC BASIC!

The main purpose of the program is to be able to scroll around an image based on the users input for scrolling speed ?

Are you forced to use huge images as part of this ?

You could have an array of textures that make up one big texture

std::vector<SDL_Textures*> textures; // 4 textures of size 100*100 for example.
void someDrawFunction() {
    // Very basic example
    SDL_Rect r1(0,-100,100,100);
    SDL_Rect r2(100,-100,100,100);
    SDL_Rect r3(0,0,100,100);
    SDL_Rect r4(100,0,100,100);
    SDL_RenderCopy(renderer, texture[0], NULL, r1);
    SDL_RenderCopy(renderer, texture[1], NULL, r2);
    SDL_RenderCopy(renderer, texture[2], NULL, r3);
    SDL_RenderCopy(renderer, texture[3], NULL, r4);
}
// 

End up with something like this
[ 1 ][ 2 ]
[ 3 ][ 4 ]

You say your images are 81’000*180’000 pixels - at 3 bytes per pixel (24bit color) this is 81’000*180’000*3 = 43’740’000’000 bytes, which is over 40GB of raw pixel data.
This means that you can’t even load the whole uncompressed image into main memory!
(This also means that even if you split it up into multiple textures, they can’t all fit into video memory)

So you’ll need to extract only parts of the image from you image file into a texture - the part you currently want to show and will show (=> scroll to) soon - and you will need to load another part after scrolling a bit and throw away the texture of the old part (this is a bit simplified, you’d probably need multiple textures so you can show part of the first and the second while scrolling, later part of the second and the third and the first can be discarded then when not visible anymore and a fourth can be loaded then that will be visible soon etc).

So the first part of the problem is completely independent of SDL: You must be able to extract a part (rectangle) of the image file without loading the whole image file. If/how this is possible depends on the image format.

Hi

Thanks for your quick reply.

I am using tif file. attached image properties.

Which method should i use for tif file?

Thanks

HI

The main purpose of the program is to be able to scroll around an image based on the users input for scrolling speed ?

Yes. Auto scroll the image from left to right , scroll speed based on user input.

Are you forced to use huge images as part of this ?

Yes. I should use 300DPI to 3000DPI image.

Thanks i will try and update you.

Ok, bit depth is 1, which makes it a bit smaller indeed: instead of 81’000*180’000*3 it’s 81’000*180’000/8 (/8 because 8 bits in one byte) which is about 1.7GB which is probably feasible to load into main memory.
Extracting rectangles from that in a format that SDL supports might be a bit tricky (but certainly doable).

I think the proper way to load a .tif file is using libtiff, but I have no experience with it and I don’t know if it can indeed give you raw 1bit/pixel data. I guess you’ll find that out.

HI

This image scroll used for printing purpose. so 300 DPI image size 8100X18000 pixels. i need to use this image and all other DPI images for scrolling.

Using SDL we can get smooth scrolling. I faced non smooth scroll in .NET application.

Will give some sample video. can you share your email id i will share the sample video developed in .NET.

Hi

I think the proper way to load a .tif file is using libtiff

Tried with libtiff - But i am getting error.

Is it possible to load the image using SDL_image ?

Thanks.

no it’s not, SDL_Image uses libtiff, so if libtiff can’t load it, SDL_Image can’t either.

Also, SDL_Image will convert it to RGB data (instead of 1bit/pixel data) which would be too big to fit into main memory.
Try getting libtiff to work, assuming your .tif file is not broken/invalid, you probably did something wrong.

I don’t think that follows. Whilst 40GB is a lot, it’s not impossible as the amount of physical memory in a 64-bit system (Windows supports up to 192 Gbytes of RAM I think) and is entirely feasible as the amount of virtual memory with efficient paging to disk.

that would be quite slow and requires a big enough swap file, I don’ think it’s a good idea (and in this case it’s not necessary at all).
And either way, to display it, it must be split into smaller parts that the graphics card can handle.

You could probably replicate the functionality DPI by using zoom and some basic maths which would avoid the texture issue.

Is this homework or personal ?

HI

Is this homework or personal ?

Personal.

Does it possible to split the image and load part by part as horizontal?

like
[ 1 ][ 2 ]3 ][ 4 ][ 5 ]…

Thanks

if you have imagemagick you could do this

convert image.png -crop 1024x1024 parts-%02d.png

to split the image automatically in a number of files,
and then load the files with SDL

I guess that translates as “for work” :stuck_out_tongue: