1 // Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // VISU OBJECT : interactive object for VISU entities implementation
24 // File: VISU_img2vti.cxx
25 // Author: Oleg UVAROV
28 #include <vtkImageData.h>
29 #include <vtkBMPReader.h>
30 #include <vtkPNGReader.h>
31 #include <vtkJPEGReader.h>
32 #include <vtkXMLImageDataWriter.h>
35 static int MYDEBUG = 0;
37 static int MYDEBUG = 0;
40 int main( int argc, char** argv )
42 if(MYDEBUG) std::cout << "Converting the image to VTI format" << std::endl;
46 std::cout << "Usage : VISU_img2vti ImageFormat InputFileName OutputFileName" << std::endl;
51 std::cout << argv[1] << std::endl;
52 std::cout << argv[2] << std::endl;
53 std::cout << argv[3] << std::endl;
56 vtkImageReader2* aReader = NULL;
57 if( !strcmp( argv[1], "BMP" ) || !strcmp( argv[1], "bmp" ) )
59 if(MYDEBUG) std::cout << "Input image format - BMP" << std::endl;
60 aReader = vtkBMPReader::New();
62 else if( !strcmp( argv[1], "PNG" ) || !strcmp( argv[1], "png" ) )
64 if(MYDEBUG) std::cout << "Input image format - PNG" << std::endl;
65 aReader = vtkPNGReader::New();
67 else if( !strcmp( argv[1], "JPG" ) || !strcmp( argv[1], "jpg" ) )
69 if(MYDEBUG) std::cout << "Input image format - JPG" << std::endl;
70 aReader = vtkJPEGReader::New();
74 std::cout << "Unknown input image format... Must be BMP, PNG or JPG." << std::endl;
77 aReader->SetFileName( argv[2] );
80 vtkXMLImageDataWriter* aWriter = vtkXMLImageDataWriter::New();
81 aWriter->SetInput( aReader->GetOutput() );
82 aWriter->SetFileName( argv[3] );