|
Al_save_bitmap problem |
alex glez
Member #16,757
October 2017
|
Hi, I would like to comment on a problem. When saving a bmp of 25 mb with al_save_bitmap it takes me 20 seconds even saving it in a ramdisk. What can I do to solve it? Thank you. |
Chris Katko
Member #1,881
January 2002
|
- What file format are you using? Thanks. (You could also run a profile to see where it's lagging the most on your system if you know how.) -----sig: |
alex glez
Member #16,757
October 2017
|
Hi. Use bmp, 2432 * 3648, color depth I have not configured anything, windows 10, visual studio, alllegro 5.2.2.1 |
Elias
Member #358
May 2000
|
How long does it take if you save it as .png instead? Just as a test. If the .png saves in 0.1 seconds, then the problem is likely the .bmp encoding. If the .png also saves in 21 seconds, then the problem is likely not the encoding but either reading the input bitmap or writing the encoded data to file. Once we know which it is we can investigate further. -- |
alex glez
Member #16,757
October 2017
|
about 25 seconds my program is a group photo processor, mini type "adobe lightroom". There is no problem in reading files and processing them. Only when exporting I make a program just with this .. al_draw_text(font, al_map_rgb(255, 100, 255), 400, 345, ...20 seconds in BMP... 24 bits (color) 2432*3648 - 25.3 mb |
Elias
Member #358
May 2000
|
What if you use BBB.png instead of BBB.bmp? Or is that what you did and BBB.png takes 25 seconds and BBB.bmp takes 20 seconds? -- |
alex glez
Member #16,757
October 2017
|
bmp takes 20 seconds and png 25 seconds. I do not understand why it takes so long. |
Edgar Reynaldo
Major Reynaldo
May 2007
|
You have to 'download' the texture off of the gpu first, which takes a bunch of time. But 20-25 seconds is still too long. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
beoran
Member #12,636
March 2011
|
I tried it out with the attached C program on Linux, with a 24 bit bitmap of 2000x2000, and it takes about 2 seconds to load and save. So, no, what you are seeing isn't normal. Could you try out my attached program and see if it works for you? The input bitmap must be named input.bmp and be in the same folder as the executable. It might be that it takes a long time for the Allegro shared libraries to be loaded, but otherwise I can't see why it would be so slow unless your system is seriously underpowered. If you know how to use a debugger, you could interrupt your program with it during saving and see where it is getting stuck. |
alex glez
Member #16,757
October 2017
|
hi beoran, my cpu is an amd athlon 64 x2 4200+, i have 4 gb ram ddr2, nvidia gforce 210 graphics card with 1024 mb. I ran my program on an Intel i3 and it takes 9 seconds. Where can I see your program attached? |
Chris Katko
Member #1,881
January 2002
|
It's to the right of the "posted on" text, the second icon. Looks like this: That image size sounds incredibly big for a computer that slow. But there could still be Allegro-related issues going on. alex glez said: nvidia gforce 210 graphics card with 1024 mb What's the maximum texture size for that card? You may be accidentally falling back into a system bitmap (read: no graphics card acceleration). [edit] Looks like you're fine on texture size. Quote: Max Texture Size: 8192 x 8192 pixels -----sig: |
beoran
Member #12,636
March 2011
|
How long does it take to save the bitmap with an image editor on your system? The bottleneck is likely to be the hard disk. If an image editor is comparably slow, it might be your system really is underpowered. Now, however it may be, let's talk mitigation. If you want to save such a large image "live", without interrupting your program, you will need to do it in a worker thread. Allegro5 has threads to help you achieve this. |
alex glez
Member #16,757
October 2017
|
Hi. Beoran compiled your code adapted to "visual studio" but it takes the same. |
Chris Katko
Member #1,881
January 2002
|
The big one to try is a profiler. Visual Studio has one. Google for "basic profiler tutorial visual studio [my year version]" and run one for your program. A profiler tells you how long each section of code takes to run (including the ALLEGRO function). So it'll show you the exact lines that are pausing for 30 seconds. This video might be perfect and it's a minute long: -----sig: |
alex glez
Member #16,757
October 2017
|
Thanks for the input. I measure the time in the following way ... |
Elias
Member #358
May 2000
|
One other thing you could try is save as .tga... I didn't check the code but maybe both .bmp and .png use some slow windows function. TGA is always handled internally I believe. -- |
beoran
Member #12,636
March 2011
|
No, i checked the code, and saving a bmp bitmap seems to be handled internally. However , it locks the bitmap in 8888 format, which might be slow. Could you try to call al_lock_bitmap(bmp, ALLEGRO_PIXEL_FORMAT_ABGR_8888_LE, Edit, I should have read a bit more because I was wrong, there is a windows specific image loader and saver for bmp. So yes, also try the tfa file format. |
torhu
Member #2,727
September 2002
|
If you run it in the debugger you can just press F12 a few times to pause it, that should tell you which functions are taking so long. |
alex glez
Member #16,757
October 2017
|
I will try all these ideas, to see if I accelerate it. if it could be compiled in 64 bits I guess it would improve a lot but I think it's not possible. It is possible that it could be compiled for some reason. Everything else with allegro works perfect. I have already tried the solutions. saving in TGA format takes 33 seconds. al_lock_bitmap (original_photo, ALLEGRO_PIXEL_FORMAT_ABGR_8888_LE, ALLEGRO_LOCK_READONLY); using the f12 key gives me the error of source code not available .. |
|