- Timestamp:
- May 3, 2010, 8:45:22 AM (16 years ago)
- Location:
- branches/simmosaic_branches
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
psLib/src/fits/psFitsImage.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/simmosaic_branches
- Property svn:mergeinfo changed
-
branches/simmosaic_branches/psLib/src/fits/psFitsImage.c
r22729 r27839 439 439 440 440 p_psFitsReadInfo *info = p_psFitsReadInfoAlloc(fits, region, z); 441 if (!info) { 442 psError(PS_ERR_IO, false, "Unable to read FITS information"); 443 return NULL; 444 } 441 445 442 446 // Size of image … … 494 498 psImage *inImage; // Image to read in 495 499 if (floatType == PS_FITS_FLOAT_NONE) { 496 inImage = psImageRecycle(outImage, numCols, numRows, info->psDatatype); 497 outImage = psMemIncrRefCounter(inImage); 500 if (!outImage || outImage->type.type == info->psDatatype) { 501 outImage = psImageRecycle(outImage, numCols, numRows, info->psDatatype); 502 inImage = psMemIncrRefCounter(outImage); 503 } else { 504 outImage = psImageRecycle(outImage, numCols, numRows, outImage->type.type); 505 inImage = psImageAlloc(numCols, numRows, info->psDatatype); 506 } 498 507 } else { 499 508 inImage = psImageAlloc(numCols, numRows, info->psDatatype); … … 507 516 return NULL; 508 517 } 509 psFree(info);510 518 511 519 if (floatType != PS_FITS_FLOAT_NONE) { 512 520 outImage = psFitsFloatImageFromDisk(outImage, inImage, floatType); 513 } 521 } else if (outImage->type.type != info->psDatatype) { 522 outImage = psImageCopy(outImage, inImage, outImage->type.type); 523 } 524 psFree(info); 514 525 psFree(inImage); 515 526 … … 612 623 } 613 624 625 bool createPHU = false; // Are we creating a PHU? 626 614 627 // Create the image HDU 615 628 int hdus = psFitsGetSize(fits); // Number of HDUs in file … … 617 630 // We're creating the first image 618 631 fits_create_img(fits->fd, bitPix, naxis, naxes, &status); 632 createPHU = true; 619 633 } else { 620 634 if (!after) { … … 623 637 // Set status to signal fits_insert_img to insert a new primary HDU 624 638 status = PREPEND_PRIMARY; 639 createPHU = true; 625 640 } else { 626 641 // Move back one to perform an insert after the previous HDU … … 637 652 638 653 // write the header, if any. 639 if (header && !psFitsWriteHeader (fits, header)) {654 if (header && !psFitsWriteHeaderImage(fits, header, createPHU)) { 640 655 psError(PS_ERR_IO, false, "Unable to write FITS header.\n"); 641 656 success = false;
Note:
See TracChangeset
for help on using the changeset viewer.
