Mail Archives: djgpp/1998/03/02/09:45:23
D. Huizenga wrote:
>
> Hi,
>
> I am working on a game using DJGPP and Allegro. I have a function which
> is supposed to resize bitmaps so that they are the same size in all
> resolutions. When I call it, the bitmaps are the same size as before I
> ran the function on them. Any help is greatly appreciated
>
> heres the function:
>
> void scale_bmp(BITMAP *b, int origsw, int origsh)
> {
> BITMAP *temp;
> int nw, nh;
> nw = (b->w * SCREEN_W) / origsw;
> nh = (b->w * SCREEN_H) / origsh;
> temp = create_bitmap(nw, nh);
> stretch_blit(b, temp, 0, 0, b->w, b->h, 0, 0, nw, nh);
> destroy_bitmap(b);
> b = temp;
> }
>
> --------------------------------------------------
> Dan Huizenga E-Mail: Skis AT Concentric DOT net
I think the problem is that your trying to set BITMAP *b to BITMAP *temp
within your function. This will not affect the address that *b points to
outside of your function call.
Either replace the parameter BITMAP *b with BITMAP **b and all
subsequent access to *b needs to be changed to *(b) and the function
needs calling with
void scale_bmp(&b, origsw, origsh);
or something like that. I'm not completely sure of the syntax.
Or more easily make the scale_bmp function return a pointer to the newly
created bitmap.
so that instead of b = temp you'll write return temp;
something like
BITMAP* scale_bmp(BITMAP *b, int origsw, int origsh)
{
BITMAP *temp;
int nw, nh;
nw = (b->w * SCREEN_W) / origsw;
nh = (b->w * SCREEN_H) / origsh;
temp = create_bitmap(nw, nh);
stretch_blit(b, temp, 0, 0, b->w, b->h, 0, 0, nw, nh);
destroy_bitmap(b);
return temp;
}
then call it with.
my_bitmap = scale_bmp(my_bitmap, origsw, origsh);
I hope that makes sense.
Richard.P.Gatehouse
- Raw text -