|
Copying pixels from one bitmap to another |
fatboy2
Member #8,239
January 2007
|
How do I copy a set of pixels from one bitmap to another. This is the code I am trying to write BITMAP *draw = create_bitmap(640,480); BITMAP *bmp = create_bitmap(640,480); line (draw,10,10,500,10,makecol(255,255,255)); line (bmp,50,50,500,50,makecol(255,255,255)); masked_blit(draw,screen,0,0,0,0,640,480); masked_blit(bmp,screen,0,0,0,0,640,480); The problem I have is that only one of the lines copies. Please help to solve this problem. |
Kris Asick
Member #1,424
July 2001
|
masked_blit() uses colour #0 as the transparent colour in 256 colour mode, and magic pink, which is makecol(255,0,255), for 15/16/24/32-bit modes. Thus if your background is black on your draw and bmp BITMAP objects, and you're using a colour depth above 8-bit, the black isn't considered transparent to masked_blit(). Try clearing the backgrounds of draw and bmp to 255,0,255 and see if that helps. --- Kris Asick (Gemini) --- Kris Asick (Gemini) |
Paul whoknows
Member #5,081
September 2004
|
BITMAP *draw = create_bitmap(640,480); BITMAP *bmp = create_bitmap(640,480); clear_to_color(draw, makecol(255, 0, 255)); clear_to_color(bmp, makecol(255, 0, 255)); line (draw,10,10,500,10,makecol(255,255,255)); line (bmp,50,50,500,50,makecol(255,255,255)); masked_blit(draw,screen,0,0,0,0,640,480); masked_blit(bmp,screen,0,0,0,0,640,480);
[EDIT] ____ "The unlimited potential has been replaced by the concrete reality of what I programmed today." - Jordan Mechner. |
ImLeftFooted
Member #3,935
October 2003
|
Quote: Try clearing the backgrounds of draw and bmp to 255,0,255 and see if that helps. You really shouldn't be using 255,0,255. What you want to use is this little function: int col = bitmap_mask_color(theBitmap);
|
BAF
Member #2,981
December 2002
|
You should do your masked_blit's to an intermediate buffer rather than directly to screen. |
|