The R Project SVN R

Rev

Rev 6458 | Rev 6644 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6458 Rev 6459
Line 397... Line 397...
397
      }
397
      }
398
    }
398
    }
399
  }
399
  }
400
  /* Compute some part of the header */
400
  /* Compute some part of the header */
401
  if (withpalette) {
401
  if (withpalette) {
402
    bfOffBits = HEADERSIZE + 4 * 256;
402
    bfOffBits = HEADERSIZE + 4 * 256; 
403
    bfSize = bfOffBits + width * height ;
403
    bfSize = bfOffBits + width * height ;
404
    biBitCount = 8;
404
    biBitCount = 8;
405
    biClrUsed = 256;
405
    biClrUsed = 256;
406
  } else {
406
  } else {
407
    bfOffBits = HEADERSIZE ;
407
    bfOffBits = HEADERSIZE + 4;
408
    bfSize = bfOffBits + 3 * width * height ;
408
    bfSize = bfOffBits + 3 * width * height ;
409
    biBitCount = 24;
409
    biBitCount = 24;
410
    biClrUsed = 0;
410
    biClrUsed = 0;
411
  }
411
  }
412
 
412
 
Line 425... Line 425...
425
  BMPLONG(0); /* XPels/M <- used only by Windows?*/
425
  BMPLONG(0); /* XPels/M <- used only by Windows?*/
426
  BMPLONG(0); /* XPels/M */
426
  BMPLONG(0); /* XPels/M */
427
  BMPDW(biClrUsed); /* biClrUsed */
427
  BMPDW(biClrUsed); /* biClrUsed */
428
  BMPDW(0) ; /* biClrImportant All colours are important */
428
  BMPDW(0) ; /* biClrImportant All colours are important */
429
 
429
 
430
  /* and now the pixels */
430
  /* and now the image */
431
  if (withpalette) {
431
  if (withpalette) {
432
    /* 8 bit image; write the palette */
432
    /* 8 bit image; write the palette */
433
    for ( i=0; i<256; i++) {
433
    for ( i=0; i<256; i++) {
434
      col = palette[i];
434
      col = palette[i];
435
      BMPPUTC(GETBLUE(col));
435
      BMPPUTC(GETBLUE(col));
Line 459... Line 459...
459
    /* 24 bits image */
459
    /* 24 bits image */
460
    BMPDW(0); /* null bmiColors */
460
    BMPDW(0); /* null bmiColors */
461
    for ( pad=0 ; ((3*width+pad) & 3) != 0; pad++); /*padding*/    
461
    for ( pad=0 ; ((3*width+pad) & 3) != 0; pad++); /*padding*/    
462
    for (i=height-1 ; i>=0 ; i--) { 
462
    for (i=height-1 ; i>=0 ; i--) { 
463
      for ( j=0 ; j<width ; j++) {
463
      for ( j=0 ; j<width ; j++) {
464
	col = gp(d, i, j);
464
	col = gp(d, i, j)&0xFFFFFFUL;
465
	BMPPUTC(GETBLUE(col));
465
	BMPPUTC(GETBLUE(col));
466
	BMPPUTC(GETGREEN(col));
466
	BMPPUTC(GETGREEN(col));
467
	BMPPUTC(GETRED(col));
467
	BMPPUTC(GETRED(col));
468
      }
468
      }
469
      for (j=0; j<pad; j++) BMPPUTC(0);
469
      for (j=0; j<pad; j++) BMPPUTC(0);