I am trying to copy one panel bmap to another using pixel for bmap and pixel to bmap. I am using the following code:

PANEL* panel_one =
{ pos_x = 10;
pos_y = 10;
layer = 10;
flags = SHOW;
}

PANEL* panel_two =
{ pos_x = 30;
pos_y = 10;
layer = 10;
flags = SHOW;
}


function main()
{ var count;
var count2;
var pixel;
panel_one.bmap = bmap_create("my_bmap.tga");
panel_two.bmap = bmap_createblack(bmap_width(panel_one.bmap),bmap_height(panel_one.bmap),32);
bmap_lock(panel_one.bmap);
bmap_lock(panel_two.bmap);
count = 0;
while(count<bmap_height(panel_one.bmap))
{ count2 = 0;
while(count2<bmap_width(panel_one.bmap))
{ pixel = pixel_for_bmap(panel_one.bmap,count,count2);
pixel_to_bmap(panel_two.bmap,count,count2,pixel);
count2 += 1;
}
count += 1;
}
bmap_unlock(panel_one.bmap);
bmap_unlock(panel_two.bmap);
}

When I run this code i get a crash. upon testing im finding that the pixel read from pixel_for_bmap is zero. Why is this? and would feeding a zero value for the pixel to pixel to bmap cause a crash?

(P.S. please do not tell me to just use panel_two.bmap = panel_one.bmap - this will not work for my purposes.)