~ubuntu-branches/ubuntu/precise/insighttoolkit/precise

« back to all changes in this revision

Viewing changes to Code/IO/itkPNGImageIO.cxx

  • Committer: Bazaar Package Importer
  • Author(s): Steve M. Robbins
  • Date: 2008-12-19 20:16:49 UTC
  • mfrom: (1.2.1 upstream) (4.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20081219201649-drt97guwl2ryt0cn

* New upstream version.
  - patches/nifti-versioning.patch: Remove.  Applied upstream.
  - control:
  - rules: Update version numbers, package names.

* control: Build-depend on uuid-dev (gdcm uses it).

* copyright: Update download URL.

* rules: Adhere to parallel=N in DEB_BUILD_OPTIONS by setting MAKEFLAGS.

* compat: Set to 7.
* control: Update build-dep on debhelper to version >= 7.

* CMakeCache.txt.debian: Set CMAKE_BUILD_TYPE to "RELEASE" so that we
  build with -O3 (not -O2), necessary to optimize the templated code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
  Program:   Insight Segmentation & Registration Toolkit
4
4
  Module:    $RCSfile: itkPNGImageIO.cxx,v $
5
5
  Language:  C++
6
 
  Date:      $Date: 2007-08-13 21:38:38 $
7
 
  Version:   $Revision: 1.64 $
 
6
  Date:      $Date: 2008-09-30 22:01:48 $
 
7
  Version:   $Revision: 1.70 $
8
8
 
9
9
  Copyright (c) Insight Software Consortium. All rights reserved.
10
10
  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
25
25
 
26
26
extern "C"
27
27
{
 
28
  #include <setjmp.h>
28
29
  /* The PNG library does not expect the error function to return.
29
30
     Therefore we must use this ugly longjmp call.  */
30
31
  void itkPNGWriteErrorFunction(png_structp png_ptr,
73
74
    return false;
74
75
    }
75
76
 
 
77
  this->AddSupportedWriteExtension(".png");
 
78
  this->AddSupportedWriteExtension(".PNG");
 
79
 
 
80
  this->AddSupportedReadExtension(".png");
 
81
  this->AddSupportedReadExtension(".PNG");
 
82
 
76
83
  // Now check the file header
77
84
  PNGFileWrapper pngfp(file,"rb");
78
85
  if(pngfp.m_FilePointer==NULL)
172
179
    return;
173
180
    }
174
181
  
 
182
  //  VS 7.1 has problems with setjmp/longjmp in C++ code
 
183
#if !defined(MSC_VER) || _MSC_VER != 1310
175
184
  if( setjmp( png_jmpbuf( png_ptr ) ) )
176
185
    {
177
186
    png_destroy_read_struct( &png_ptr, &info_ptr, &end_info );
178
187
    itkExceptionMacro("File is not png type " << this->GetFileName());
179
188
    return;
180
189
    }
 
190
#endif
181
191
 
182
192
  png_init_io(png_ptr, fp);
183
193
  png_set_sig_bytes(png_ptr, 8);
427
437
 
428
438
void PNGImageIO::WriteSlice(const std::string& fileName, const void* buffer)
429
439
{
430
 
  const unsigned char *outPtr = ( (const unsigned char *) buffer);
 
440
  volatile const unsigned char *outPtr = ( (const unsigned char *) buffer);
431
441
 
432
442
  // use this class so return will call close
433
443
  PNGFileWrapper pngfp(fileName.c_str(),"wb");
443
453
    throw excp; 
444
454
    }
445
455
 
446
 
  int bitDepth;
 
456
  volatile int bitDepth;
447
457
  switch (this->GetComponentType())
448
458
    {
449
459
    case UCHAR:
481
491
    }
482
492
 
483
493
  png_init_io(png_ptr, fp);
 
494
 
 
495
//  VS 7.1 has problems with setjmp/longjmp in C++ code
 
496
#if !defined(_MSC_VER) || _MSC_VER != 1310
484
497
  png_set_error_fn(png_ptr, png_ptr,
485
498
                   itkPNGWriteErrorFunction, itkPNGWriteWarningFunction);
486
499
  if (setjmp(png_ptr->jmpbuf))
493
506
                      << itksys::SystemTools::GetLastSystemError());
494
507
    return;
495
508
    } 
 
509
#endif
496
510
 
497
511
  int colorType;
498
512
  unsigned int numComp = this->GetNumberOfComponents();