[Insight-users] bmp read write

Julien Jomier julien.jomier at kitware.com
Wed Mar 21 16:13:11 EST 2007


Hello,

I just tried your code and it works well.
Could you send me the images that are having issues (private email or 
post them on the bug tracker http://www.itk.org/Bug).

Thanks,

Julien

medamine wrote:
> hi, 
> I would like to read and write bmp image;but it lost her color and for other
> image it become black. 
> thank; 
> 
> 
> #if defined(_MSC_VER) 
> #pragma warning ( disable : 4786 ) 
> #endif 
> 
> #ifdef __BORLANDC__ 
> #define ITK_LEAN_AND_MEAN 
> #endif 
> 
> 
> #include "itkImageFileReader.h" 
> #include "itkImageFileWriter.h" 
> #include <list> 
> #include <fstream> 
> typedef   itk::RGBPixel<unsigned char >     InternalPixelType; 
> typedef itk::Image< InternalPixelType, 2 >   ImageType; 
> typedef itk::ImageFileReader< ImageType > ReaderType; 
> typedef itk::RescaleIntensityImageFilter< ImageType, ImageType >
> RescaleFilterType; 
> typedef itk::Image< InternalPixelType, 2 > WriteImageType; 
> typedef itk::ImageFileWriter< WriteImageType >  WriterType; 
> 
> int main( int argc, char* argv[] ) 
> { 
>                /*********LECTURE****************/ 
>     
> 
>    ReaderType::Pointer reader = ReaderType::New(); 
>    reader->SetFileName("test.bmp"); 
>    try 
>       { 
>       reader->Update(); 
>       } 
>    catch( itk::ExceptionObject & excp ) 
>       { 
>       std::cerr << "error " << excp << std::endl; 
>       return; 
>       } 
>    //ImageType::ConstPointer image = reader->GetOutput(); 
> 
> 
>            /*********ECRITURE****************/ 
> 
>   //typedef itk::Image< unsigned char, 2 > WriteImageType; 
>   //typedef itk::ImageFileWriter< WriteImageType >  WriterType; 
>   WriterType::Pointer writer = WriterType::New(); 
>   writer->SetFileName( "resultat.bmp" ); 
>   
>   writer->SetInput(reader->GetOutput()); 
>   try 
>     { 
>     writer->Update(); 
>     } 
>   catch (itk::ExceptionObject & e) 
>     { 
>     std::cerr << "exception in file writer " << std::endl; 
>     std::cerr << e << std::endl; 
>     
>     } 
> 
> 
> 
>   
> } 
> 
> 



More information about the Insight-users mailing list