www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/03/02/09:45:23

From: "Richard.P.Gatehouse" <thedreamscaper AT geocities DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: HELP! Why doesn't this work?!
Date: Mon, 02 Mar 1998 13:45:36 +0000
Organization: SCO
Lines: 64
Message-ID: <34FAB800.DCF57983@geocities.com>
References: <34F8627A DOT EAF8EB96 AT concentric DOT net>
NNTP-Posting-Host: richardg.london.sco.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019