delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/09/09/13:02:58

Message-ID: <8D53104ECD0CD211AF4000A0C9D60AE301650959@probe-2.acclaim-euro.net>
From: Shawn Hargreaves <ShawnH AT Probe DOT co DOT uk>
To: djgpp AT delorie DOT com
Subject: Re: Does Allegro BLIT really convert between colordepths
Date: Thu, 9 Sep 1999 10:25:25 +0100
MIME-Version: 1.0
X-Mailer: Internet Mail Service (5.0.1460.8)
Reply-To: djgpp AT delorie DOT com

Anders David Skarin writes:
> There is one small thing i can't get over though... blit will
> not (as the manual sas) convert between differnt colordepths.
[...]
>	BITMAP *test = create_bitmap_ex(32,320,240);

You create a 256 color bitmap.

>	destroy_bitmap(test);

Now you destroy it.

>	set_color_depth(16);
>	if(set_gfx_mode(GFX_VESA2L,320,240,0,0)!=0)printf("sorry\n");

Now you set a 16 bit video mode. btw. it would be better to use
GFX_AUTODETECT instead of GFX_VESA2L, because hardcoding the
driver selection is a great way to make sure that your programs
won't run on any other machines that have different hardware to
your own...

>		putpixel(test,x,y,0x00FF5500);

Now you draw a pixel onto the test bitmap, which you previously
destroyed. Not a good idea! Also, it looks as if you are expecting
the color parameter to be in 24 bit RGB format, which is wrong
because a) test was a 256 color bitmap, not truecolor, and b)
you should never hardcode your bit patterns in any case, because
not all graphics cards use the same color encodings. Use the
makecol() function to construct a suitable color value at runtime.

>	blit(test,screen,0,0,0,0,320,240);

This would work, if your test bitmap still existed, and if you
had draw sensible 256 color values onto it. But you really ought
to set a palette before you do this, because expanding a 256
color source onto a truecolor destination will have pretty much
random results unless you tell it what palette you want to use
first.


	Shawn Hargreaves.

- Raw text -


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