Background color issue
Marton

I have a small issue:

I'm loading a bitmap from my datafile and displaying it, but for some reason I get a colored border on the background.
I tried with clear_to_color(bitmap, makecol(0,0,0)) with no luck.
If I don't set the palette, I don't get the border but the colors are obviously wrong on the bitmap.
I don't want that border because my bitmap already has one.

      datafile = load_datafile("test.dat");
      set_color_conversion(COLORCONV_NONE);
      set_palette(datafile[2].dat);
      set_color_conversion(COLORCONV_TOTAL);
      bitmap = create_bitmap(320,200);
      blit(datafile[1].dat, bitmap, 0, 0, 0, 0, 320, 200);
      blit(bitmap, screen, 0, 0, 0, 0, 320, 200);

Any clues??

Many thanks in advance!

orz

I think you are missunderstanding what set_color_conversion does. You should probably call it only once, before the load_datafile call.

If you don't want a border, you should probably be using masked_blit instead of blit, or perhaps the "sprite" functions.

What color depths are your data file image and your screen?

edit: when you say "a colored border on the background", do you mean around the edges of the screen, or around the edges of your image? If you mean around the edges of the screen, that usually comes from setting a non-black color to palette entry 0 in an 8 bit per pixel video mode. If you mean around the edges of your sprite, that usually comes from misshandling the "mask" color.

Marton

set_color_conversion is called before and after changing the palette in Allegro's examples so I thought it would be OK if I do the same :)
The border is around the edges of the screen so I think it is like you say, the entry number 0 on the palette. I created that palette using the grabber tool... If I change it to black it will solve the issue I believe from what you say, but will the image keep showing the right colors?

Thanks for the reply!!

Edit: The image is in 8 bit per pixel and I did not call set_color_depth.

orz

If you don't call set_color_depth, Allegro defaults to 8 bits per pixel for historical reasons.

Your first call for to set_color_conversion should be moved up to before the load_datafile call.

I'm not sure whether or not your second call to set_color_depth is correct or not. That is, it's not incorrect, but it might be meaningless. It appears to be refering to a features added in 4.2.x, and it matches the example exdata.c. However, by my reading of the 4.2.0 docs and header files, it doesn't actually do anything.

Anyway, if you just want to get rid of the colored border, you can switch color depths (the border color generally only occurs in 8bpp), or you can change your palette to have color 0 be black. Or there might be another solution I don't know of. There is an item in the Allegro FAQ "Why do I have a funny color border at the edges of my monitor?", but all it says is to make your color 0 be black.

Marton

Setting bit depth to 16 did not solve the issue... doing a set_color(0, &rgb) with rgb values at 0 did solve it. MANY THANKS for your help!!!

Thread #588090. Printed from Allegro.cc