- /* initialize */
- memset(&cmptparm[0], 0, sizeof(cmptparm));
- memset(&lut_R[0], 0, sizeof(lut_R));
- memset(&lut_G[0], 0, sizeof(lut_G));
- memset(&lut_B[0], 0, sizeof(lut_B));
+ /* FILE HEADER */
+ /* ------------- */
+ header->bfSize = (OPJ_UINT32)getc(IN);
+ header->bfSize |= (OPJ_UINT32)getc(IN) << 8;
+ header->bfSize |= (OPJ_UINT32)getc(IN) << 16;
+ header->bfSize |= (OPJ_UINT32)getc(IN) << 24;
+
+ header->bfReserved1 = (OPJ_UINT16)getc(IN);
+ header->bfReserved1 |= (OPJ_UINT16)((OPJ_UINT32)getc(IN) << 8);
+
+ header->bfReserved2 = (OPJ_UINT16)getc(IN);
+ header->bfReserved2 |= (OPJ_UINT16)((OPJ_UINT32)getc(IN) << 8);
+
+ header->bfOffBits = (OPJ_UINT32)getc(IN);
+ header->bfOffBits |= (OPJ_UINT32)getc(IN) << 8;
+ header->bfOffBits |= (OPJ_UINT32)getc(IN) << 16;
+ header->bfOffBits |= (OPJ_UINT32)getc(IN) << 24;
+ return OPJ_TRUE;
+}
+static OPJ_BOOL bmp_read_info_header(FILE* IN, OPJ_BITMAPINFOHEADER* header)
+{
+ memset(header, 0, sizeof(*header));
+ /* INFO HEADER */
+ /* ------------- */
+ header->biSize = (OPJ_UINT32)getc(IN);
+ header->biSize |= (OPJ_UINT32)getc(IN) << 8;
+ header->biSize |= (OPJ_UINT32)getc(IN) << 16;
+ header->biSize |= (OPJ_UINT32)getc(IN) << 24;
+
+ switch (header->biSize) {
+ case 12U: /* BITMAPCOREHEADER */
+ case 40U: /* BITMAPINFOHEADER */
+ case 52U: /* BITMAPV2INFOHEADER */
+ case 56U: /* BITMAPV3INFOHEADER */
+ case 108U: /* BITMAPV4HEADER */
+ case 124U: /* BITMAPV5HEADER */
+ break;
+ default:
+ fprintf(stderr,"Error, unknown BMP header size %d\n", header->biSize);
+ return OPJ_FALSE;
+ }
+
+ header->biWidth = (OPJ_UINT32)getc(IN);
+ header->biWidth |= (OPJ_UINT32)getc(IN) << 8;
+ header->biWidth |= (OPJ_UINT32)getc(IN) << 16;
+ header->biWidth |= (OPJ_UINT32)getc(IN) << 24;
+
+ header->biHeight = (OPJ_UINT32)getc(IN);
+ header->biHeight |= (OPJ_UINT32)getc(IN) << 8;
+ header->biHeight |= (OPJ_UINT32)getc(IN) << 16;
+ header->biHeight |= (OPJ_UINT32)getc(IN) << 24;
+
+ header->biPlanes = (OPJ_UINT16)getc(IN);
+ header->biPlanes |= (OPJ_UINT16)((OPJ_UINT32)getc(IN) << 8);
+
+ header->biBitCount = (OPJ_UINT16)getc(IN);
+ header->biBitCount |= (OPJ_UINT16)((OPJ_UINT32)getc(IN) << 8);