Skip to content
Snippets Groups Projects
Commit 6e0ce59d authored by Cyrille Valladeau's avatar Cyrille Valladeau
Browse files

BUG: add test for ImageWidget dump image. bug #323

parent ce628596
No related branches found
No related tags found
No related merge requests found
......@@ -40,6 +40,29 @@ ${INPUTDATA}/poupees.png 1
)
ENDIF(OTB_GL_USE_ACCEL)
ADD_TEST(vrTvImageWidgetImageDumpWithoutGlAcceleration ${VISUALIZATION_TESTS1}
--compare-image ${NOTOL}
${BASELINE}/vrTvImageWidgetImageDumpWithoutGlAcceleration.png
${TEMP}/vrTvImageWidgetImageDumpWithoutGlAcceleration.png
otbImageWidgetImageDump
${INPUTDATA}/qb_RoadExtract2sub200x200.tif # input image
0 # use glAcceleration
2 # resize factor
${TEMP}/vrTvImageWidgetImageDumpWithoutGlAcceleration.png
)
IF(OTB_GL_USE_ACCEL)
ADD_TEST(vrTvImageWidgetImageDumpWithGlAcceleration ${VISUALIZATION_TESTS1}
${BASELINE}/vrTvImageWidgetImageDumpWithGlAcceleration.png
${TEMP}/vrTvImageWidgetImageDumpWithGlAcceleration.png
otbImageWidgetImageDump
${INPUTDATA}/qb_RoadExtract2sub200x200.tif
1
${TEMP}/vrTvImageWidgetImageDumpWithGlAcceleration.png
)
ENDIF(OTB_GL_USE_ACCEL)
#------------ otb::ImageWidgetActionHandler -------------
ADD_TEST(vrTuImageWidgetActionHandlerNew ${VISUALIZATION_TESTS1}
......@@ -445,6 +468,7 @@ SET(Visualization_SRCS1
otbVisualizationTests1.cxx
otbImageWidgetNew.cxx
otbImageWidget.cxx
otbImageWidgetImageDump.cxx
otbImageWidgetActionHandlerNew.cxx
otbImageWidgetControllerNew.cxx
otbImageWidgetController.cxx
......
/*=========================================================================
Program: ORFEO Toolbox
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
See OTBCopyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#define OTB_DISABLE_GL_USE_ACCEL
#include "otbImageWidget.h"
#include "otbImageFileReader.h"
#include <FL/Fl.H>
#include "otbScalarBufferToImageFileWriter.h"
int otbImageWidgetImageDump(int argc, char * argv[])
{
const char * infname = argv[1];
const bool useAccel = atoi(argv[2]);
unsigned int sizeFactor = atoi(argv[3]);
const char * filename = argv[4];
// typedefs
typedef otb::ImageWidget<> WidgetType;
typedef WidgetType::InputImageType ImageType;
typedef otb::ImageFileReader<ImageType> ReaderType;
typedef otb::ScalarBufferToImageFileWriter<unsigned char, unsigned char> DumperType;
// Reading the input image
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName(infname);
reader->Update();
ImageType::RegionType region = reader->GetOutput()->GetLargestPossibleRegion();
ImageType::RegionType::SizeType size = region.GetSize();
size[0] /= sizeFactor;
size[1] /= sizeFactor;
region.SetSize(size);
// Create a widget
WidgetType::Pointer widget = WidgetType::New();
// Set the acceleration mode
widget->SetUseGlAcceleration(useAccel);
// Resize it
widget->resize(0, 0, region.GetSize()[0], region.GetSize()[1]);
// Show it
widget->show();
// Refresh display
Fl::check();
// Read the OpenGl buffer
widget->ReadBuffer(reader->GetOutput(), region);
// Redraw it
widget->redraw();
// Refresh display
Fl::check();
// Dump image
DumperType::Pointer dumper = DumperType::New();
dumper->SetNumberOfChannels(3);
dumper->SetBuffer( widget->GetOpenGlBuffer() );
dumper->SetImageSize(widget->GetOpenGlBufferedRegion().GetSize());
dumper->SetFileName(filename);
dumper->SetInverseXSpacing(true);
dumper->Update();
return EXIT_SUCCESS;
}
......@@ -26,6 +26,7 @@ void RegisterTests()
{
REGISTER_TEST(otbImageWidgetNew);
REGISTER_TEST(otbImageWidget);
REGISTER_TEST(otbImageWidgetImageDump);
REGISTER_TEST(otbImageWidgetActionHandlerNew);
REGISTER_TEST(otbImageWidgetControllerNew);
REGISTER_TEST(otbImageWidgetController);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment