With IoT development, it becomes more popular that image data is transmitted via wireless communication systems. If bit errors occur during transmission, the recovered image will become useless. To solve this problem, a bit‐error aware lossless image compression based on bi‐level coding is proposed for gray image compression. But bi‐level coding has not considered the inherent statistical correlation in 2D context region. To resolve this shortage, a novel variable‐size 2D‐block extraction and encoding method with built‐in bi‐level coding for color image is developed to decrease the entropy of information and improve the compression ratio. A lossless color transformation from RGB to the YCrCb color space is used for the decorrelation of color components. Particularly, the layer‐extraction method is proposed to keep the Laplacian distribution of the data in 2D blocks which is suitable for bi‐level coding. In addition, optimization of 2D‐block start bits is used to improve the performance. To evaluate the performance of our proposed method, many experiments including the comparison with state‐of‐the‐art methods, the effects with different color space, etc. are conducted. The comparison experiments under a bit‐error environment show that the average compression rate of our method is better than bi‐level, Jpeg2000, WebP, FLIF, and L3C (deep learning method) with hamming code. Also, our method achieves the same image quality with the bi‐level method. Other experiments illustrate the positive effect of built‐in bi‐level encoding and encoding with zero‐mean values, which can maintain high image quality. At last, the results of the decrease of entropy and the procedure of our method are given and discussed.