Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Using different sampling for scaled bitmap

This thread is locked; no one can reply to it. rss feed Print
Using different sampling for scaled bitmap
simon77c
Member #20,398
June 2021

Can anyone tell me whether or not it is possible to change sampling of the bitmap scaling while doing any variant of al_draw_scaled_bitmap()? I don't want it to be only nearest neighbour and I don't want it to be only bi-linear. Is it possible? Or should I use some external library for it? If so, can you recommend such a library?

(I'm an absolute newcomer to this and I have less than 1 month of c++ experience too, so might have ignored a part of allegro which does this)

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

simon77c
Member #20,398
June 2021

Also, I have another question on these bitmaps. Why does each pixel occupy 4 times the size as normal, and why are channels stored as floats instead of chars? i was going to use a 20000x8000px bitmap, but realized that it would seriously affect ram usage.

Edit: i used al_set_new_bitmap_flags with ALLEGRO_MEMORY_BITMAP and it cut the memory usage in 4.
Now a 73 mb bmp actually uses 73 mb in ram instead 292 mb.... somehow. Can you explain it? My explanation would be that it uses chars instead of floats now, am i right?

Dizzy Egg
Member #10,824
March 2009
avatar

I think you're referring to pixel format; a 32-bit image will use 8bits each for RGB, and 8bits for alpha. That's 32bits for each pixel.

----------------------------------------------------
Please check out my songs:
https://soundcloud.com/dont-rob-the-machina

simon77c
Member #20,398
June 2021

Uhh, nope. I was getting 16 bytes per pixel on 32 bit bmp's, 12 bytes per pixel on 24 bit bmps, and so on. it was multiplying itself by four. i think it's because a,b,g and r are new_float_byte() things (i think they mean floats) according to al_load_bitmap_flags (check no_premultiplied_alpha, it clearly says allegro does new_float_byte() for all 4 four channels).

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

If you're using the DX driver, load your bitmaps with ALLEGRO_NO_PRESERVE_TEXTURE. That will keep only ONE copy of a bitmap around.

Dizzy Egg is right, one byte for each color component makes 4 bytes, or 32 bits.

simon77c
Member #20,398
June 2021

Now it's solved, using ALLEGRO_VIDEO_BITMAP no longer keeps 4 copies of one image, when i use ALLEGRO_OPENGL. It also cuts cpu + gpu usage in half, ram in 1/4th and increases fps by twice.

I wonder what I did with the DX backend to cause overuse of my resources:-(

Go to: