From 168d7c88f5c45f81dbdd4e62c582ebf14e25e014 Mon Sep 17 00:00:00 2001 From: ouv Date: Thu, 22 Sep 2005 12:57:53 +0000 Subject: [PATCH] Convertor from PNG, BMP and JPEG to VTI format --- src/PIPELINE/Makefile.in | 2 +- src/PIPELINE/VISU_img2vti.cxx | 76 +++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 src/PIPELINE/VISU_img2vti.cxx diff --git a/src/PIPELINE/Makefile.in b/src/PIPELINE/Makefile.in index 5f41e6ac..14274e17 100644 --- a/src/PIPELINE/Makefile.in +++ b/src/PIPELINE/Makefile.in @@ -63,7 +63,7 @@ LIB_SRC = \ # Executables targets -BIN = VISUPipeLine +BIN = VISUPipeLine VISU_img2vti BIN_SRC = CPPFLAGS+= \ diff --git a/src/PIPELINE/VISU_img2vti.cxx b/src/PIPELINE/VISU_img2vti.cxx new file mode 100644 index 00000000..31ee9bcb --- /dev/null +++ b/src/PIPELINE/VISU_img2vti.cxx @@ -0,0 +1,76 @@ +// VISU OBJECT : interactive object for VISU entities implementation +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// File: VISU_img2vti.cxx +// Author: Oleg UVAROV +// Module : VISU + +#include +#include +#include +#include +#include + +int main( int argc, char** argv ) +{ + std::cout << "Converting the image to VTI format" << std::endl; + + if( argc != 4 ) + { + std::cout << "Usage : VISU_img2vti ImageFormat InputFileName OutputFileName" << std::endl; + return 1; + } + + std::cout << argv[1] << std::endl; + std::cout << argv[2] << std::endl; + std::cout << argv[3] << std::endl; + + vtkImageReader2* aReader; + if( !strcmp( argv[1], "BMP" ) || !strcmp( argv[1], "bmp" ) ) + { + std::cout << "Input image format - BMP" << std::endl; + aReader = vtkBMPReader::New(); + } + else if( !strcmp( argv[1], "PNG" ) || !strcmp( argv[1], "png" ) ) + { + std::cout << "Input image format - PNG" << std::endl; + aReader = vtkPNGReader::New(); + } + else if( !strcmp( argv[1], "JPG" ) || !strcmp( argv[1], "jpg" ) ) + { + std::cout << "Input image format - JPG" << std::endl; + aReader = vtkJPEGReader::New(); + } + else + { + std::cout << "Unknown input image format... Must be BMP, PNG or JPG." << std::endl; + return 1; + } + + aReader->SetFileName( argv[2] ); + aReader->Update(); + + vtkXMLImageDataWriter* aWriter = vtkXMLImageDataWriter::New(); + aWriter->SetInput( aReader->GetOutput() ); + aWriter->SetFileName( argv[3] ); + return 1 - aWriter->Write(); +} -- 2.39.2