This patch adds support for 32-bit-per-pixel BMP files. *** /home/bradley/src/x11/xv-3.10a/xvbmp.c Thu Dec 22 17:34:42 1994 --- xvbmp.c Wed May 10 12:15:46 2000 *************** *** 32,38 **** static int loadBMP1 PARM((FILE *, byte *, u_int, u_int)); static int loadBMP4 PARM((FILE *, byte *, u_int, u_int, u_int)); static int loadBMP8 PARM((FILE *, byte *, u_int, u_int, u_int)); ! static int loadBMP24 PARM((FILE *, byte *, u_int, u_int)); static u_int getshort PARM((FILE *)); static u_int getint PARM((FILE *)); static void putshort PARM((FILE *, int)); --- 32,38 ---- static int loadBMP1 PARM((FILE *, byte *, u_int, u_int)); static int loadBMP4 PARM((FILE *, byte *, u_int, u_int, u_int)); static int loadBMP8 PARM((FILE *, byte *, u_int, u_int, u_int)); ! static int loadBMP24 PARM((FILE *, byte *, u_int, u_int, u_int)); static u_int getshort PARM((FILE *)); static u_int getint PARM((FILE *)); static void putshort PARM((FILE *, int)); *************** *** 127,133 **** /* error checking */ ! if ((biBitCount!=1 && biBitCount!=4 && biBitCount!=8 && biBitCount!=24) || biPlanes!=1 || biCompression>BI_RLE4) { sprintf(buf,"Bogus BMP File! (bitCount=%d, Planes=%d, Compression=%d)", --- 127,134 ---- /* error checking */ ! if ((biBitCount!=1 && biBitCount!=4 && biBitCount!=8 && ! biBitCount!=24 && biBitCount!=32) || biPlanes!=1 || biCompression>BI_RLE4) { sprintf(buf,"Bogus BMP File! (bitCount=%d, Planes=%d, Compression=%d)", *************** *** 137,143 **** goto ERROR; } ! if (((biBitCount==1 || biBitCount==24) && biCompression != BI_RGB) || (biBitCount==4 && biCompression==BI_RLE8) || (biBitCount==8 && biCompression==BI_RLE4)) { --- 138,145 ---- goto ERROR; } ! if (((biBitCount==1 || biBitCount==24 || biBitCount==32) ! && biCompression != BI_RGB) || (biBitCount==4 && biCompression==BI_RLE8) || (biBitCount==8 && biCompression==BI_RLE4)) { *************** *** 159,165 **** } /* load up colormap, if any */ ! if (biBitCount!=24) { int i, cmaplen; cmaplen = (biClrUsed) ? biClrUsed : 1 << biBitCount; --- 161,167 ---- } /* load up colormap, if any */ ! if (biBitCount!=24 && biBitCount!=32) { int i, cmaplen; cmaplen = (biClrUsed) ? biClrUsed : 1 << biBitCount; *************** *** 197,203 **** /* create pic8 or pic24 */ ! if (biBitCount==24) { pic24 = (byte *) calloc((size_t) biWidth * biHeight * 3, (size_t) 1); if (!pic24) return (bmpError(bname, "couldn't malloc 'pic24'")); } --- 199,205 ---- /* create pic8 or pic24 */ ! if (biBitCount==24 || biBitCount==32) { pic24 = (byte *) calloc((size_t) biWidth * biHeight * 3, (size_t) 1); if (!pic24) return (bmpError(bname, "couldn't malloc 'pic24'")); } *************** *** 212,227 **** if (biBitCount == 1) rv = loadBMP1(fp,pic8,biWidth,biHeight); else if (biBitCount == 4) rv = loadBMP4(fp,pic8,biWidth,biHeight, biCompression); ! else if (biBitCount == 8) rv = loadBMP8(fp,pic8,biWidth,biHeight, biCompression); ! else rv = loadBMP24(fp,pic24,biWidth,biHeight); if (rv) bmpError(bname, "File appears truncated. Winging it.\n"); fclose(fp); ! if (biBitCount == 24) { pinfo->pic = pic24; pinfo->type = PIC24; } --- 214,231 ---- if (biBitCount == 1) rv = loadBMP1(fp,pic8,biWidth,biHeight); else if (biBitCount == 4) rv = loadBMP4(fp,pic8,biWidth,biHeight, biCompression); ! else if (biBitCount == 8) rv = loadBMP8(fp,pic8,biWidth,biHeight, biCompression); ! else rv = loadBMP24(fp,pic24,biWidth,biHeight, ! biBitCount); ! if (rv) bmpError(bname, "File appears truncated. Winging it.\n"); fclose(fp); ! if (biBitCount == 24 || biBitCount == 32) { pinfo->pic = pic24; pinfo->type = PIC24; } *************** *** 384,393 **** u_int w,h,comp; { int i,j,c,c1,padw,x,y,rv; ! byte *pp; rv = 0; if (comp == BI_RGB) { /* read uncompressed data */ padw = ((w + 3)/4) * 4; /* 'w' padded to a multiple of 4pix (32 bits) */ --- 388,399 ---- u_int w,h,comp; { int i,j,c,c1,padw,x,y,rv; ! byte *pp, *pend; rv = 0; + pend = pic8 + w * h; + if (comp == BI_RGB) { /* read uncompressed data */ padw = ((w + 3)/4) * 4; /* 'w' padded to a multiple of 4pix (32 bits) */ *************** *** 407,418 **** x = y = 0; pp = pic8 + x + (h-y-1)*w; ! while (y=0; i--) { pp = pic24 + (i * w * 3); *************** *** 474,479 **** --- 481,487 ---- pp[2] = getc(fp); /* blue */ pp[1] = getc(fp); /* green */ pp[0] = getc(fp); /* red */ + if (bits==32) getc(fp); pp += 3; } .