Is this correct way to check if bits are set in some variable and store them in another variable? Just ignore variable names, image[] and mask variables are 1 byte and first_hline_first_row and second_hline_first_row are 2 byte.
for(i=0; i<16; i++){
if(image[i] & mask1) first_hline_first_row |= (1<<i);
else first_hline_first_row &=~ (0<<i);
if(image[i] & mask2) second_hline_first_row |= (1<<i);
else second_hline_first_row &=~ (0<<i);
}