How do I copy a set of pixels from one bitmap to another.
I have a line on each of the 2 bitmaps. I want to be able to copy the line from bitmap1 to bitmap2 without erasing the line that is already there on bitmap2.
I tried reading the manual and masked_blit does not seem to work.
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.
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)
--- http://www.pixelships.com
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]
Beaten!>:(
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);
You should do your masked_blit's to an intermediate buffer rather than directly to screen.