Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » how to resize a bitmap image

This thread is locked; no one can reply to it. rss feed Print
how to resize a bitmap image
raja peter
Member #7,835
October 2006

I have loaded a image(gif, jpg,..) of Dimension 800*600 into a bitmap. I want to resize the image into the dimension 500*400.

Thanks.

luv,

raja

Frank Drebin
Member #2,987
December 2002
avatar

FMC
Member #4,431
March 2004
avatar

to resize it you must create a new bitmap of the appropriate size:

BITMAP *a,*b;
a = load_bitmap("jj.bmp",NULL);
b = create_bitmap(500,400);
stretch_blit(a, b, 0, 0, a->w, a->h, 0, 0, b->w, dest_b->h);
destroy_bitmap(a); //free the memory, you can use b from now on

[FMC Studios] - [Caries Field] - [Ctris] - [Pman] - [Chess for allegroites]
Written laws are like spiders' webs, and will, like them, only entangle and hold the poor and weak, while the rich and powerful will easily break through them. -Anacharsis
Twenty years from now you will be more disappointed by the things that you didn't do than by the ones you did do. So throw off the bowlines. Sail away from the safe harbor. Catch the trade winds in your sails. Explore. Dream. Discover. -Mark Twain

raja peter
Member #7,835
October 2006

I think these functions will display the resized image on the destination image.

Will it store it in the destination image.

I want to make it clear.

I have a bitmap of size 800* 600 and want the same image reduced to 500*400. Then I'll use the resulted image further more.

Thanks FMC U cleared it.

luv,

raja

TeamTerradactyl
Member #7,733
September 2006
avatar

FMC's suggestion will store it in the destination image. It creates a new image, stretches your current image and saves that result in the 500x400 bitmap, so you have your full-sized image and your new smaller image in two separate memory locations.

Erkle
Member #3,493
May 2003
avatar

Display and store, in this case, mean the same thing. You cannot display an image without storing it. Even blitting to the screen results in the bitmap being stored in the primary video bitmap.

If the writing above has offended you, you've read it wrong.....fool.
And if you read that wrong it means 'All of the above is opinion and is only to be treated as such.'

julian boolean
Member #7,941
November 2006

How baddly does stretching distort the bitmap?

raja peter
Member #7,835
October 2006

Thanks one and all.

I could make a fine stretching.

luv,

raja

Go to: