Update of /cvsroot/hugin/hugin/src/foreign/vigra_impex
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11684/foreign/vigra_impex
Modified Files:
Tag: vigra140-branch
auto_file.hxx bmp.cxx bmp.hxx byteorder.cxx byteorder.hxx
codecmanager.cxx codecmanager.hxx error.hxx gif.cxx gif.hxx
imageinfo.cxx jpeg.cxx jpeg.hxx png.cxx png.hxx pnm.cxx
pnm.hxx sun.cxx sun.hxx tiff.cxx tiff.hxx viff.cxx viff.hxx
void_vector.cxx void_vector.hxx
Log Message:
Update to (patched) vigra 1.4.0
Index: jpeg.hxx
===================================================================
RCS file: /cvsroot/hugin/hugin/src/foreign/vigra_impex/jpeg.hxx,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -u -d -r1.1 -r1.1.2.1
--- jpeg.hxx 3 Jul 2004 09:55:16 -0000 1.1
+++ jpeg.hxx 3 Mar 2006 00:31:48 -0000 1.1.2.1
@@ -4,24 +4,39 @@
/* Cognitive Systems Group, University of Hamburg, Germany */
/* */
/* This file is part of the VIGRA computer vision library. */
-/* ( Version 1.2.0, Aug 07 2003 ) */
-/* You may use, modify, and distribute this software according */
-/* to the terms stated in the LICENSE file included in */
-/* the VIGRA distribution. */
-/* */
+/* ( Version 1.4.0, Dec 21 2005 ) */
/* The VIGRA Website is */
/* http://kogs-www.informatik.uni-hamburg.de/~koethe/vigra/ */
/* Please direct questions, bug reports, and contributions to */
-/* koethe@... */
+/* koethe@... or */
+/* vigra@... */
/* */
-/* THIS SOFTWARE IS PROVIDED AS IS AND WITHOUT ANY EXPRESS OR */
-/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
-/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */
+/* Permission is hereby granted, free of charge, to any person */
+/* obtaining a copy of this software and associated documentation */
+/* files (the "Software"), to deal in the Software without */
+/* restriction, including without limitation the rights to use, */
+/* copy, modify, merge, publish, distribute, sublicense, and/or */
+/* sell copies of the Software, and to permit persons to whom the */
+/* Software is furnished to do so, subject to the following */
+/* conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the */
+/* Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES */
+/* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND */
+/* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT */
+/* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, */
+/* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING */
+/* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR */
+/* OTHER DEALINGS IN THE SOFTWARE. */
/* */
/************************************************************************/
-#ifndef VIGRA_IMPEX2_JPEG_HXX
-#define VIGRA_IMPEX2_JPEG_HXX
+#ifndef VIGRA_IMPEX_JPEG_HXX
+#define VIGRA_IMPEX_JPEG_HXX
#include <vector>
#include "vigra/codec.hxx"
Index: viff.cxx
===================================================================
RCS file: /cvsroot/hugin/hugin/src/foreign/vigra_impex/viff.cxx,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -u -d -r1.2 -r1.2.2.1
--- viff.cxx 27 Oct 2004 18:12:51 -0000 1.2
+++ viff.cxx 3 Mar 2006 00:31:48 -0000 1.2.2.1
@@ -4,26 +4,46 @@
/* Cognitive Systems Group, University of Hamburg, Germany */
/* */
/* This file is part of the VIGRA computer vision library. */
-/* ( Version 1.2.0, Aug 07 2003 ) */
-/* You may use, modify, and distribute this software according */
-/* to the terms stated in the LICENSE file included in */
-/* the VIGRA distribution. */
-/* */
+/* ( Version 1.4.0, Dec 21 2005 ) */
/* The VIGRA Website is */
/* http://kogs-www.informatik.uni-hamburg.de/~koethe/vigra/ */
/* Please direct questions, bug reports, and contributions to */
-/* koethe@... */
+/* koethe@... or */
+/* vigra@... */
/* */
-/* THIS SOFTWARE IS PROVIDED AS IS AND WITHOUT ANY EXPRESS OR */
-/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
-/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */
+/* Permission is hereby granted, free of charge, to any person */
+/* obtaining a copy of this software and associated documentation */
+/* files (the "Software"), to deal in the Software without */
+/* restriction, including without limitation the rights to use, */
+/* copy, modify, merge, publish, distribute, sublicense, and/or */
+/* sell copies of the Software, and to permit persons to whom the */
+/* Software is furnished to do so, subject to the following */
+/* conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the */
+/* Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES */
+/* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND */
+/* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT */
+/* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, */
+/* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING */
+/* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR */
+/* OTHER DEALINGS IN THE SOFTWARE. */
/* */
/************************************************************************/
-
-#include <config.h>
+/* Modifications by Pablo d'Angelo
+ * updated to vigra 1.4 by Douglas Wilkins
+ * as of 18 Febuary 2006:
+ * - Replaced size_t with unsigned int.
+ */
#include <iostream>
#include <fstream>
+#include "vigra/config.hxx"
+#include "vigra/sized_int.hxx"
#include "error.hxx"
#include "byteorder.hxx"
#include "void_vector.hxx"
@@ -164,14 +184,10 @@
namespace vigra {
- typedef short int16_t;
- typedef int int32_t;
-
// added by dangelo, this is probably a hack, but the some of
// the fields seem to be unsigned int, but other have size_t (which is
// probably not unsigned int on 64 bit machines). Force the usage
// of unsigned int here..
- typedef unsigned int my_size_t;
template< class T1, class T2 >
class colormap
@@ -250,35 +266,35 @@
// this function encapsulates the colormap functor
template< class storage_type, class map_storage_type >
void map_multiband( void_vector<map_storage_type> & dest,
- my_size_t & dest_bands,
+ UInt32 & dest_bands,
const void_vector<storage_type> & src,
- my_size_t src_bands, my_size_t src_width, my_size_t src_height,
+ UInt32 src_bands, UInt32 src_width, UInt32 src_height,
const void_vector<map_storage_type> & maps,
- my_size_t map_bands, my_size_t map_width, my_size_t map_height )
+ UInt32 map_bands, UInt32 map_width, UInt32 map_height )
{
typedef colormap< storage_type, map_storage_type > colormap_type;
- const my_size_t num_pixels = src_width * src_height;
+ const UInt32 num_pixels = src_width * src_height;
// build the color map
- const my_size_t map_band_size = map_width * map_height;
+ const UInt32 map_band_size = map_width * map_height;
colormap_type colormap( map_height, map_bands, map_width );
- for ( my_size_t i = 0; i < map_bands; ++i )
+ for ( UInt32 i = 0; i < map_bands; ++i )
colormap.initialize( maps.data() + map_band_size * i, i );
// map each pixel
- const my_size_t band_size = src_width * src_height;
+ const UInt32 band_size = src_width * src_height;
dest_bands = map_bands * map_width;
dest.resize( band_size * dest_bands );
if ( map_width > 1 ) {
// interleaved maps => there is only one band in the image
- for( my_size_t bandnum = 0; bandnum < dest_bands; ++bandnum )
- for( my_size_t i = 0; i < num_pixels; ++i )
+ for( UInt32 bandnum = 0; bandnum < dest_bands; ++bandnum )
+ for( UInt32 i = 0; i < num_pixels; ++i )
dest[ bandnum * band_size + i ]
= colormap( src[i], bandnum );
} else {
// non-interleaved bands => map can be used per band
- for( my_size_t bandnum = 0; bandnum < dest_bands; ++bandnum )
- for( my_size_t i = 0; i < num_pixels; ++i )
+ for( UInt32 bandnum = 0; bandnum < dest_bands; ++bandnum )
+ for( UInt32 i = 0; i < num_pixels; ++i )
dest[ bandnum * band_size + i ]
= colormap( src[ bandnum * band_size + i ], bandnum );
}
@@ -312,6 +328,9 @@
desc.fileExtensions.resize(1);
desc.fileExtensions[0] = "xv";
+ desc.bandNumbers.resize(1);
+ desc.bandNumbers[0] = 0;
+
return desc;
}
@@ -327,7 +346,7 @@
class ViffHeader
{
- typedef unsigned long field_type;
+ typedef UInt32 field_type;
public:
@@ -499,7 +518,7 @@
struct ViffDecoderImpl
{
- my_size_t width, height, components, map_width,
+ UInt32 width, height, components, map_width,
map_height, num_maps;
std::string pixelType;
int current_scanline;
@@ -517,7 +536,7 @@
ViffDecoderImpl::ViffDecoderImpl( const std::string & filename )
: pixelType("undefined"), current_scanline(-1)
{
-#ifdef WIN32
+#ifdef VIGRA_NEED_BIN_STREAMS
std::ifstream stream( filename.c_str(), std::ios::binary );
#else
std::ifstream stream( filename.c_str() );
@@ -555,17 +574,17 @@
const unsigned int maps_size = map_width * map_height * num_maps;
if ( header.map_storage_type == VFF_MAPTYP_1_BYTE ) {
- typedef void_vector< unsigned char > maps_type;
+ typedef void_vector<UInt8> maps_type;
maps_type & castmaps = static_cast< maps_type & >(maps);
castmaps.resize(maps_size);
read_array( stream, bo, castmaps.data(), maps_size );
} else if ( header.map_storage_type == VFF_MAPTYP_2_BYTE ) {
- typedef void_vector<int16_t> maps_type;
+ typedef void_vector<Int16> maps_type;
maps_type & castmaps = static_cast< maps_type & >(maps);
castmaps.resize(maps_size);
read_array( stream, bo, castmaps.data(), maps_size );
} else if ( header.map_storage_type == VFF_MAPTYP_4_BYTE ) {
- typedef void_vector<int32_t> maps_type;
+ typedef void_vector<Int32> maps_type;
maps_type & castmaps = static_cast< maps_type & >(maps);
castmaps.resize(maps_size);
read_array( stream, bo, castmaps.data(), maps_size );
@@ -580,22 +599,22 @@
void ViffDecoderImpl::read_bands( std::ifstream & stream, byteorder & bo )
{
- const my_size_t bands_size = width * height * components;
+ const UInt32 bands_size = width * height * components;
if ( header.data_storage_type == VFF_TYP_1_BYTE ) {
- typedef void_vector< unsigned char > bands_type;
+ typedef void_vector<UInt8> bands_type;
bands_type & castbands = static_cast< bands_type & >(bands);
castbands.resize(bands_size);
read_array( stream, bo, castbands.data(), bands_size );
pixelType = "UINT8";
} else if ( header.data_storage_type == VFF_TYP_2_BYTE ) {
- typedef void_vector<int16_t> bands_type;
+ typedef void_vector<Int16> bands_type;
bands_type & castbands = static_cast< bands_type & >(bands);
castbands.resize(bands_size);
read_array( stream, bo, castbands.data(), bands_size );
pixelType = "INT16";
} else if ( header.data_storage_type == VFF_TYP_4_BYTE ) {
- typedef void_vector<int32_t> bands_type;
+ typedef void_vector<Int32> bands_type;
bands_type & castbands = static_cast< bands_type & >(bands);
castbands.resize(bands_size);
read_array( stream, bo, castbands.data(), bands_size );
@@ -619,13 +638,13 @@
void ViffDecoderImpl::color_map()
{
void_vector_base temp_bands;
- my_size_t temp_num_bands;
+ UInt32 temp_num_bands;
if ( header.map_storage_type == VFF_MAPTYP_1_BYTE ) {
- typedef unsigned char map_storage_type;
+ typedef UInt8 map_storage_type;
if ( header.data_storage_type == VFF_TYP_1_BYTE ) {
- typedef unsigned char storage_type;
+ typedef UInt8 storage_type;
typedef void_vector<storage_type> bands_type;
typedef void_vector<map_storage_type> maps_type;
map_multiband( static_cast< maps_type & >(temp_bands),
@@ -636,7 +655,7 @@
num_maps, map_width, map_height );
} else if ( header.data_storage_type == VFF_TYP_2_BYTE ) {
- typedef unsigned short storage_type;
+ typedef UInt16 storage_type;
typedef void_vector<storage_type> bands_type;
typedef void_vector<map_storage_type> maps_type;
map_multiband( static_cast< maps_type & >(temp_bands),
@@ -647,7 +666,7 @@
num_maps, map_width, map_height );
} else if ( header.data_storage_type == VFF_TYP_4_BYTE ) {
- typedef unsigned int storage_type;
+ typedef UInt32 storage_type;
typedef void_vector<storage_type> bands_type;
typedef void_vector<map_storage_type> maps_type;
map_multiband( static_cast< maps_type & >(temp_bands),
@@ -663,10 +682,10 @@
pixelType = "UINT8";
} else if ( header.map_storage_type == VFF_MAPTYP_2_BYTE ) {
- typedef unsigned short map_storage_type;
+ typedef UInt16 map_storage_type;
if ( header.data_storage_type == VFF_TYP_1_BYTE ) {
- typedef unsigned char storage_type;
+ typedef UInt8 storage_type;
typedef void_vector<storage_type> bands_type;
typedef void_vector<map_storage_type> maps_type;
map_multiband( static_cast< maps_type & >(temp_bands),
@@ -677,7 +696,7 @@
num_maps, map_width, map_height );
} else if ( header.data_storage_type == VFF_TYP_2_BYTE ) {
- typedef unsigned short storage_type;
+ typedef UInt16 storage_type;
typedef void_vector<storage_type> bands_type;
typedef void_vector<map_storage_type> maps_type;
map_multiband( static_cast< maps_type & >(temp_bands),
@@ -688,7 +707,7 @@
num_maps, map_width, map_height );
} else if ( header.data_storage_type == VFF_TYP_4_BYTE ) {
- typedef unsigned int storage_type;
+ typedef UInt32 storage_type;
typedef void_vector<storage_type> bands_type;
typedef void_vector<map_storage_type> maps_type;
map_multiband( static_cast< maps_type & >(temp_bands),
@@ -704,10 +723,10 @@
pixelType = "INT16";
} else if ( header.map_storage_type == VFF_MAPTYP_4_BYTE ) {
- typedef unsigned int map_storage_type;
+ typedef UInt32 map_storage_type;
if ( header.data_storage_type == VFF_TYP_1_BYTE ) {
- typedef unsigned char storage_type;
+ typedef UInt8 storage_type;
typedef void_vector<storage_type> bands_type;
typedef void_vector<map_storage_type> maps_type;
map_multiband( static_cast< maps_type & >(temp_bands),
@@ -718,7 +737,7 @@
num_maps, map_width, map_height );
} else if ( header.data_storage_type == VFF_TYP_2_BYTE ) {
- typedef unsigned short storage_type;
+ typedef UInt16 storage_type;
typedef void_vector<storage_type> bands_type;
typedef void_vector<map_storage_type> maps_type;
map_multiband( static_cast< maps_type & >(temp_bands),
@@ -729,7 +748,7 @@
num_maps, map_width, map_height );
} else if ( header.data_storage_type == VFF_TYP_4_BYTE ) {
- typedef unsigned int storage_type;
+ typedef UInt32 storage_type;
typedef void_vector<storage_type> bands_type;
typedef void_vector<map_storage_type> maps_type;
map_multiband( static_cast< maps_type & >(temp_bands),
@@ -748,7 +767,7 @@
typedef float map_storage_type;
if ( header.data_storage_type == VFF_TYP_1_BYTE ) {
- typedef unsigned char storage_type;
+ typedef UInt8 storage_type;
typedef void_vector<storage_type> bands_type;
typedef void_vector<map_storage_type> maps_type;
map_multiband( static_cast< maps_type & >(temp_bands),
@@ -759,7 +778,7 @@
num_maps, map_width, map_height );
} else if ( header.data_storage_type == VFF_TYP_2_BYTE ) {
- typedef unsigned short storage_type;
+ typedef UInt16 storage_type;
typedef void_vector<storage_type> bands_type;
typedef void_vector<map_storage_type> maps_type;
map_multiband( static_cast< maps_type & >(temp_bands),
@@ -770,7 +789,7 @@
num_maps, map_width, map_height );
} else if ( header.data_storage_type == VFF_TYP_4_BYTE ) {
- typedef unsigned int storage_type;
+ typedef UInt32 storage_type;
typedef void_vector<storage_type> bands_type;
typedef void_vector<map_storage_type> maps_type;
map_multiband( static_cast< maps_type & >(temp_bands),
@@ -819,7 +838,7 @@
unsigned int ViffDecoder::getNumBands() const
{
- return static_cast<unsigned int>(pimpl->components);
+ return static_cast<UInt32>(pimpl->components);
}
std::string ViffDecoder::getPixelType() const
@@ -837,17 +856,17 @@
const unsigned int index = pimpl->width
* ( pimpl->height * band + pimpl->current_scanline );
if ( pimpl->pixelType == "UINT8" ) {
- typedef void_vector< unsigned char > bands_type;
+ typedef void_vector<UInt8> bands_type;
const bands_type & bands
= static_cast< const bands_type & >(pimpl->bands);
return bands.data() + index;
} else if ( pimpl->pixelType == "INT16" ) {
- typedef void_vector<int16_t> bands_type;
+ typedef void_vector<Int16> bands_type;
const bands_type & bands
= static_cast< const bands_type & >(pimpl->bands);
return bands.data() + index;
} else if ( pimpl->pixelType == "INT32" ) {
- typedef void_vector<int32_t> bands_type;
+ typedef void_vector<Int32> bands_type;
const bands_type & bands
= static_cast< const bands_type & >(pimpl->bands);
return bands.data() + index;
@@ -889,7 +908,7 @@
void_vector_base bands;
ViffEncoderImpl( const std::string & filename )
-#ifdef WIN32
+#ifdef VIGRA_NEED_BIN_STREAMS
: stream( filename.c_str(), std::ios::binary ),
#else
: stream( filename.c_str() ),
@@ -902,7 +921,7 @@
std::string msg("Unable to open file '");
msg += filename;
msg += "'.";
- vigra_precondition(0, msg.c_str());
+ vigra_precondition(false, msg);
}
}
@@ -925,31 +944,31 @@
void ViffEncoder::setWidth( unsigned int width )
{
- VIGRA_IMPEX2_FINALIZED(pimpl->finalized);
+ VIGRA_IMPEX_FINALIZED(pimpl->finalized);
pimpl->header.row_size = width;
}
void ViffEncoder::setHeight( unsigned int height )
{
- VIGRA_IMPEX2_FINALIZED(pimpl->finalized);
+ VIGRA_IMPEX_FINALIZED(pimpl->finalized);
pimpl->header.col_size = height;
}
void ViffEncoder::setNumBands( unsigned int numBands )
{
- VIGRA_IMPEX2_FINALIZED(pimpl->finalized);
+ VIGRA_IMPEX_FINALIZED(pimpl->finalized);
pimpl->header.num_data_bands = numBands;
}
void ViffEncoder::setCompressionType( const std::string & comp,
int quality )
{
- VIGRA_IMPEX2_FINALIZED(pimpl->finalized);
+ VIGRA_IMPEX_FINALIZED(pimpl->finalized);
}
void ViffEncoder::setPixelType( const std::string & pixelType )
{
- VIGRA_IMPEX2_FINALIZED(pimpl->finalized);
+ VIGRA_IMPEX_FINALIZED(pimpl->finalized);
pimpl->pixelType = pixelType;
if ( pixelType == "UINT8" )
pimpl->header.data_storage_type = VFF_TYP_1_BYTE;
@@ -976,15 +995,15 @@
* pimpl->header.col_size * pimpl->header.num_data_bands;
if ( pimpl->header.data_storage_type == VFF_TYP_1_BYTE ) {
- typedef void_vector< unsigned char > bands_type;
+ typedef void_vector<UInt8> bands_type;
bands_type & castbands = static_cast< bands_type & >(pimpl->bands);
castbands.resize(bands_size);
} else if ( pimpl->header.data_storage_type == VFF_TYP_2_BYTE ) {
- typedef void_vector<int16_t> bands_type;
+ typedef void_vector<Int16> bands_type;
bands_type & castbands = static_cast< bands_type & >(pimpl->bands);
castbands.resize(bands_size);
} else if ( pimpl->header.data_storage_type == VFF_TYP_4_BYTE ) {
- typedef void_vector<int32_t> bands_type;
+ typedef void_vector<Int32> bands_type;
bands_type & castbands = static_cast< bands_type & >(pimpl->bands);
castbands.resize(bands_size);
} else if ( pimpl->header.data_storage_type == VFF_TYP_FLOAT ) {
@@ -1006,15 +1025,15 @@
const unsigned int index = pimpl->header.row_size
* ( pimpl->header.col_size * band + pimpl->current_scanline );
if ( pimpl->pixelType == "UINT8" ) {
- typedef void_vector< unsigned char > bands_type;
+ typedef void_vector<UInt8> bands_type;
bands_type & bands = static_cast< bands_type & >(pimpl->bands);
return bands.data() + index;
} else if ( pimpl->pixelType == "INT16" ) {
- typedef void_vector<int16_t> bands_type;
+ typedef void_vector<Int16> bands_type;
bands_type & bands = static_cast< bands_type & >(pimpl->bands);
return bands.data() + index;
} else if ( pimpl->pixelType == "INT32" ) {
- typedef void_vector<int32_t> bands_type;
+ typedef void_vector<Int32> bands_type;
bands_type & bands = static_cast< bands_type & >(pimpl->bands);
return bands.data() + index;
} else if ( pimpl->pixelType == "FLOAT" ) {
@@ -1043,17 +1062,17 @@
* pimpl->header.col_size * pimpl->header.num_data_bands;
if ( pimpl->header.data_storage_type == VFF_TYP_1_BYTE ) {
- typedef void_vector< unsigned char > bands_type;
+ typedef void_vector<UInt8> bands_type;
bands_type & castbands = static_cast< bands_type & >(pimpl->bands);
write_array( pimpl->stream, pimpl->bo,
castbands.data(), bands_size );
} else if ( pimpl->header.data_storage_type == VFF_TYP_2_BYTE ) {
- typedef void_vector<short> bands_type;
+ typedef void_vector<Int16> bands_type;
bands_type & castbands = static_cast< bands_type & >(pimpl->bands);
write_array( pimpl->stream, pimpl->bo,
castbands.data(), bands_size );
} else if ( pimpl->header.data_storage_type == VFF_TYP_4_BYTE ) {
- typedef void_vector<int> bands_type;
+ typedef void_vector<Int32> bands_type;
bands_type & castbands = static_cast< bands_type & >(pimpl->bands);
write_array( pimpl->stream, pimpl->bo,
castbands.data(), bands_size );
Index: byteorder.cxx
===================================================================
RCS file: /cvsroot/hugin/hugin/src/foreign/vigra_impex/byteorder.cxx,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -u -d -r1.2 -r1.2.2.1
--- byteorder.cxx 27 Oct 2004 18:12:51 -0000 1.2
+++ byteorder.cxx 3 Mar 2006 00:31:48 -0000 1.2.2.1
@@ -1,7 +1,44 @@
-#include <config.h>
+/************************************************************************/
+/* */
+/* Copyright 2002-2004 by Ullrich Koethe and Gunnar Kedenburg */
+/* Cognitive Systems Group, University of Hamburg, Germany */
+/* */
+/* This file is part of the VIGRA computer vision library. */
+/* ( Version 1.4.0, Dec 21 2005 ) */
+/* The VIGRA Website is */
+/* http://kogs-www.informatik.uni-hamburg.de/~koethe/vigra/ */
+/* Please direct questions, bug reports, and contributions to */
+/* koethe@... or */
+/* vigra@... */
+/* */
+/* Permission is hereby granted, free of charge, to any person */
+/* obtaining a copy of this software and associated documentation */
+/* files (the "Software"), to deal in the Software without */
+/* restriction, including without limitation the rights to use, */
+/* copy, modify, merge, publish, distribute, sublicense, and/or */
+/* sell copies of the Software, and to permit persons to whom the */
+/* Software is furnished to do so, subject to the following */
+/* conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the */
+/* Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES */
+/* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND */
+/* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT */
+/* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, */
+/* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING */
+/* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR */
+/* OTHER DEALINGS IN THE SOFTWARE. */
+/* */
+/************************************************************************/
+
#include <algorithm>
#include <stdexcept>
#include "byteorder.hxx"
+#include "vigra/sized_int.hxx"
namespace vigra
{
@@ -11,9 +48,8 @@
{
// byteorder check: if the first byte is the least significant,
// we have little endian byteorder.
- unsigned int testint = 0x01;
- unsigned char * testchar
- = reinterpret_cast< unsigned char * >(&testint);
+ UIntBiggest testint = 0x01;
+ UInt8 * testchar = reinterpret_cast< UInt8 * >(&testint);
if ( testchar[0] == 0x01 )
m_string = "little endian";
else
Index: jpeg.cxx
===================================================================
RCS file: /cvsroot/hugin/hugin/src/foreign/vigra_impex/jpeg.cxx,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -u -d -r1.3 -r1.3.2.1
--- jpeg.cxx 1 Nov 2004 17:20:13 -0000 1.3
+++ jpeg.cxx 3 Mar 2006 00:31:48 -0000 1.3.2.1
@@ -4,28 +4,42 @@
/* Cognitive Systems Group, University of Hamburg, Germany */
/* */
/* This file is part of the VIGRA computer vision library. */
-/* ( Version 1.2.0, Aug 07 2003 ) */
-/* You may use, modify, and distribute this software according */
-/* to the terms stated in the LICENSE file included in */
-/* the VIGRA distribution. */
-/* */
+/* ( Version 1.4.0, Dec 21 2005 ) */
/* The VIGRA Website is */
/* http://kogs-www.informatik.uni-hamburg.de/~koethe/vigra/ */
/* Please direct questions, bug reports, and contributions to */
-/* koethe@... */
+/* koethe@... or */
+/* vigra@... */
/* */
-/* THIS SOFTWARE IS PROVIDED AS IS AND WITHOUT ANY EXPRESS OR */
-/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
-/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */
+/* Permission is hereby granted, free of charge, to any person */
+/* obtaining a copy of this software and associated documentation */
+/* files (the "Software"), to deal in the Software without */
+/* restriction, including without limitation the rights to use, */
+/* copy, modify, merge, publish, distribute, sublicense, and/or */
+/* sell copies of the Software, and to permit persons to whom the */
+/* Software is furnished to do so, subject to the following */
+/* conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the */
+/* Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES */
+/* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND */
+/* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT */
+/* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, */
+/* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING */
+/* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR */
+/* OTHER DEALINGS IN THE SOFTWARE. */
/* */
/************************************************************************/
-#include <config.h>
-
#ifdef HasJPEG
#include <stdexcept>
#include <csetjmp>
+#include "vigra/config.hxx"
#include "void_vector.hxx"
#include "error.hxx"
#include "auto_file.hxx"
@@ -65,6 +79,10 @@
desc.fileExtensions[0] = "jpg";
desc.fileExtensions[1] = "jpeg";
+ desc.bandNumbers.resize(2);
+ desc.bandNumbers[0] = 1;
+ desc.bandNumbers[1] = 3;
+
return desc;
}
@@ -164,7 +182,7 @@
};
JPEGDecoderImpl::JPEGDecoderImpl( const std::string & filename )
-#ifdef WIN32
+#ifdef VIGRA_NEED_BIN_STREAMS
: file( filename.c_str(), "rb" ),
#else
: file( filename.c_str(), "r" ),
@@ -300,7 +318,7 @@
};
JPEGEncoderImpl::JPEGEncoderImpl( const std::string & filename )
-#ifdef WIN32
+#ifdef VIGRA_NEED_BIN_STREAMS
: file( filename.c_str(), "wb" ),
#else
: file( filename.c_str(), "w" ),
@@ -323,9 +341,9 @@
{
}
- void JPEGEncoderImpl::finalize()
+void JPEGEncoderImpl::finalize()
{
- VIGRA_IMPEX2_FINALIZED(finalized);
+ VIGRA_IMPEX_FINALIZED(finalized);
// alloc memory for a single scanline
bands.resize( width * components );
@@ -389,26 +407,26 @@
void JPEGEncoder::setWidth( unsigned int width )
{
- VIGRA_IMPEX2_FINALIZED(pimpl->finalized);
+ VIGRA_IMPEX_FINALIZED(pimpl->finalized);
pimpl->width = width;
}
void JPEGEncoder::setHeight( unsigned int height )
{
- VIGRA_IMPEX2_FINALIZED(pimpl->finalized);
+ VIGRA_IMPEX_FINALIZED(pimpl->finalized);
pimpl->height = height;
}
void JPEGEncoder::setNumBands( unsigned int bands )
{
- VIGRA_IMPEX2_FINALIZED(pimpl->finalized);
+ VIGRA_IMPEX_FINALIZED(pimpl->finalized);
pimpl->components = bands;
}
void JPEGEncoder::setCompressionType( const std::string & comp,
int quality )
{
- VIGRA_IMPEX2_FINALIZED(pimpl->finalized);
+ VIGRA_IMPEX_FINALIZED(pimpl->finalized);
if ( comp == "LOSSLESS" )
vigra_fail( "lossless encoding is not supported by"
" the jpeg implementation impex uses." );
@@ -417,7 +435,7 @@
void JPEGEncoder::setPixelType( const std::string & pixelType )
{
- VIGRA_IMPEX2_FINALIZED(pimpl->finalized);
+ VIGRA_IMPEX_FINALIZED(pimpl->finalized);
if ( pixelType != "UINT8" )
vigra_precondition( false, "only UINT8 pixels are supported." );
}
Index: bmp.cxx
===================================================================
RCS file: /cvsroot/hugin/hugin/src/foreign/vigra_impex/bmp.cxx,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -u -d -r1.3 -r1.3.2.1
--- bmp.cxx 20 Jan 2005 19:20:45 -0000 1.3
+++ bmp.cxx 3 Mar 2006 00:31:48 -0000 1.3.2.1
@@ -1,29 +1,44 @@
/************************************************************************/
/* */
-/* Copyright 2002 by Gunnar Kedenburg */
+/* Copyright 2002-2004 by Gunnar Kedenburg */
/* Cognitive Systems Group, University of Hamburg, Germany */
/* */
/* This file is part of the VIGRA computer vision library. */
-/* ( Version 1.2.0, Aug 07 2003 ) */
-/* You may use, modify, and distribute this software according */
-/* to the terms stated in the LICENSE file included in */
-/* the VIGRA distribution. */
-/* */
+/* ( Version 1.4.0, Dec 21 2005 ) */
/* The VIGRA Website is */
/* http://kogs-www.informatik.uni-hamburg.de/~koethe/vigra/ */
/* Please direct questions, bug reports, and contributions to */
-/* koethe@... */
+/* koethe@... or */
+/* vigra@... */
/* */
-/* THIS SOFTWARE IS PROVIDED AS IS AND WITHOUT ANY EXPRESS OR */
-/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
-/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */
+/* Permission is hereby granted, free of charge, to any person */
+/* obtaining a copy of this software and associated documentation */
+/* files (the "Software"), to deal in the Software without */
+/* restriction, including without limitation the rights to use, */
+/* copy, modify, merge, publish, distribute, sublicense, and/or */
+/* sell copies of the Software, and to permit persons to whom the */
+/* Software is furnished to do so, subject to the following */
+/* conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the */
+/* Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES */
+/* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND */
+/* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT */
+/* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, */
+/* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING */
+/* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR */
+/* OTHER DEALINGS IN THE SOFTWARE. */
/* */
/************************************************************************/
-#include <config.h>
-
#include <iostream>
#include <fstream>
+#include "vigra/config.hxx"
+#include "vigra/sized_int.hxx"
#include "error.hxx"
#include "void_vector.hxx"
#include "byteorder.hxx"
@@ -61,6 +76,10 @@
desc.fileExtensions.resize(1);
desc.fileExtensions[0] = "bmp";
+ desc.bandNumbers.resize(2);
+ desc.bandNumbers[0] = 1;
+ desc.bandNumbers[1] = 3;
+
return desc;
}
@@ -79,11 +98,11 @@
// attributes
// the magic number
- unsigned short magic;
+ UInt16 magic;
// size of the whole file
- int size;
+ Int32 size;
// offset (from this field) to the data
- int offset;
+ Int32 offset;
// ctor
@@ -103,7 +122,7 @@
void BmpFileHeader::from_stream( std::ifstream & stream, byteorder & bo )
{
- unsigned short filemagic;
+ UInt16 filemagic;
read_field( stream, bo, filemagic );
vigra_precondition( filemagic == magic, "magic value is incorrect." );
read_field( stream, bo, size );
@@ -125,23 +144,23 @@
// attributes
// size of this header in the file
- int info_size;
+ Int32 info_size;
// image dimensions
- long width, height;
+ Int32 width, height;
// number of planes, always set to one
- short planes;
+ Int16 planes;
// bits per pixel
- short bit_count;
+ Int16 bit_count;
// compression type
- int compression;
+ Int32 compression;
// image size in bytes, may be zero for 24 bpp images
- int image_size;
+ Int32 image_size;
// image resolution
- long x_pixels_per_meter, y_pixels_per_meter;
+ Int32 x_pixels_per_meter, y_pixels_per_meter;
// number of used colors, may be zero
- int clr_used;
+ Int32 clr_used;
// number of important colors, may be zero
- int clr_important;
+ Int32 clr_important;
// methods
@@ -158,7 +177,7 @@
read_field( stream, bo, width );
vigra_precondition( width > 0, "width must be > 0" );
read_field( stream, bo, height );
- vigra_precondition( width > 0, "height must be > 0" );
+ vigra_precondition( height > 0, "height must be > 0" );
read_field( stream, bo, planes );
vigra_precondition( planes == 1, "planes must be 1" );
read_field( stream, bo, bit_count );
@@ -208,8 +227,8 @@
BmpInfoHeader info_header;
// image containers
- void_vector< unsigned char > pixels;
- void_vector< unsigned char > map;
+ void_vector< UInt8 > pixels;
+ void_vector< UInt8 > map;
int scanline;
@@ -240,12 +259,12 @@
// reads the header.
BmpDecoderImpl::BmpDecoderImpl( const std::string & filename )
:
-#ifdef WIN32
- stream (filename.c_str (), std::ios::binary)
+#ifdef VIGRA_NEED_BIN_STREAMS
+ stream (filename.c_str (), std::ios::binary),
#else
- stream (filename.c_str ())
+ stream (filename.c_str ()),
#endif
- , scanline(-1)
+ scanline(-1)
{
if( !stream.good() )
{
@@ -277,17 +296,17 @@
read_1bit_data ();
break;
case 4:
- if (info_header.compression)
+ if (info_header.compression) {
read_rle4_data ();
- else
+ } else {
read_4bit_data ();
- break;
+ } break;
case 8:
- if (info_header.compression)
+ if (info_header.compression) {
read_rle8_data ();
- else
+ } else {
read_8bit_data ();
- break;
+ } break;
case 24:
read_rgb_data ();
break;
@@ -316,7 +335,7 @@
const unsigned int ncomp = grayscale ? 1 : 3;
const unsigned int line_size = info_header.width * ncomp;
const unsigned int image_size = info_header.height * line_size;
- unsigned char c = 0;
+ int c = 0;
// seek to the data
stream.seekg( file_header.offset, std::ios::beg );
@@ -330,8 +349,8 @@
pad_size = 4 - pad_size;
// setup the base pointer at one line after the end
- unsigned char * base = pixels.data() + image_size;
- unsigned char * mover = base;
+ UInt8 * base = pixels.data() + image_size;
+ UInt8 * mover = base;
// read scanlines from bottom to top
for ( int y = info_header.height - 1; y >= 0; --y ) {
@@ -348,10 +367,10 @@
c = stream.get();
// get the color bit
- const unsigned char index = ( c >> ( 7 - ( x % 8 ) ) ) & 0x01;
+ const UInt8 index = ( c >> ( 7 - ( x % 8 ) ) ) & 0x01;
// map and assign the pixel
- const unsigned char * map_base = map.data() + 3 * index;
+ const UInt8 * map_base = map.data() + 3 * index;
for ( unsigned int i = 0; i < ncomp; ++i )
mover[i] = map_base[i];
mover += ncomp;
@@ -368,7 +387,7 @@
const unsigned int ncomp = grayscale ? 1 : 3;
const unsigned int line_size = info_header.width * ncomp;
const unsigned int image_size = info_header.height * line_size;
- unsigned char c = 0;
+ int c = 0;
// seek to the data
stream.seekg( file_header.offset, std::ios::beg );
@@ -382,8 +401,8 @@
pad_size = 4 - pad_size;
// setup the base pointer at one line after the end
- unsigned char * base = pixels.data() + image_size;
- unsigned char * mover = base;
+ UInt8 * base = pixels.data() + image_size;
+ UInt8 * mover = base;
// read scanlines from bottom to top
for ( int y = info_header.height - 1; y >= 0; --y ) {
@@ -400,10 +419,10 @@
c = stream.get();
// get the color index
- const unsigned char index = ( c >> ( 1 - ( x % 2 ) ) ) & 0x0f;
+ const UInt8 index = ( c >> ( 1 - ( x % 2 ) ) ) & 0x0f;
// map and assign the pixel
- const unsigned char * map_base = map.data() + 3 * index;
+ const UInt8 * map_base = map.data() + 3 * index;
for ( unsigned int i = 0; i < ncomp; ++i )
mover[i] = map_base[i];
mover += ncomp;
@@ -428,14 +447,14 @@
pixels.resize (image_size);
// setup the base pointer at the beginning of the last line.
- unsigned char * base = pixels.data() + image_size - line_size;
- unsigned char * mover = base;
+ UInt8 * base = pixels.data() + image_size - line_size;
+ UInt8 * mover = base;
// set the image's background color to black.
VIGRA_CSTD::memset (pixels.data (), 0, image_size);
// read the rle codes one by one.
- unsigned char c1, c2;
+ int c1, c2;
bool painting = true;
unsigned int x = 0;
@@ -508,17 +527,17 @@
// absolute mode. paint the following c2 nibbles.
// then, eventually skip one byte to respect 16 bit boundaries.
- unsigned int k = 0;
+ int k = 0;
while (true) {
- const unsigned char c = stream.get ();
+ const int c = stream.get ();
// the high-order and lower-order nibbles
- const unsigned char nh = (c & 0xf0) >> 4;
- const unsigned char nl = (c & 0x0f);
+ const int nh = (c & 0xf0) >> 4;
+ const int nl = (c & 0x0f);
// paint the the higher-order nibble.
- const unsigned char *map_base_h = map.data () + 3*nh;
+ const UInt8 *map_base_h = map.data () + 3*nh;
unsigned int j;
for (j = 0; j < ncomp; ++j)
mover [j] = map_base_h [j];
@@ -527,7 +546,7 @@
break;
// paint the lower-order nibble.
- const unsigned char *map_base_l = map.data () + 3*nl;
+ const UInt8 *map_base_l = map.data () + 3*nl;
for (j = 0; j < ncomp; ++j)
mover [j] = map_base_l [j];
mover += ncomp;
@@ -543,18 +562,18 @@
// plain rle: repeat the next byte mapped, c1 times.
// a line break may not happen here.
- for (unsigned char i = 0; i < c1; ++i) {
+ for (int i = 0; i < c1; ++i) {
// the high-order and lower-order nibbles
- const unsigned char nh = (c2 & 0xf0) >> 4;
- const unsigned char nl = (c2 & 0x0f);
+ const int nh = (c2 & 0xf0) >> 4;
+ const int nl = (c2 & 0x0f);
// paint the higher-order nibble.
- const unsigned char *map_base_h = map.data () + 3*nh;
+ const UInt8 *map_base_h = map.data () + 3*nh;
unsigned int j;
for (j = 0; j < ncomp; ++j)
mover [j] = map_base_h [j];
mover += ncomp;
// paint the lower-order nibble.
- const unsigned char *map_base_l = map.data () + 3*nl;
+ const UInt8 *map_base_l = map.data () + 3*nl;
for (j = 0; j < ncomp; ++j)
mover [j] = map_base_l [j];
mover += ncomp;
@@ -583,8 +602,8 @@
pad_size = 4 - pad_size;
// setup the base pointer at one line after the end
- unsigned char * base = pixels.data() + image_size;
- unsigned char * mover = base;
+ UInt8 * base = pixels.data() + image_size;
+ UInt8 * mover = base;
// read scanlines from bottom to top
for ( int y = info_header.height - 1; y >= 0; --y ) {
@@ -597,10 +616,10 @@
for ( int x = 0; x < info_header.width; ++x ) {
// get the color byte
- const unsigned char index = stream.get();
+ const int index = stream.get();
// map and assign the pixel
- const unsigned char * map_base = map.data() + 3 * index;
+ const UInt8 * map_base = map.data() + 3 * index;
for ( unsigned int i = 0; i < ncomp; ++i )
mover[i] = map_base[i];
mover += ncomp;
@@ -625,14 +644,14 @@
pixels.resize (image_size);
// setup the base pointer at the beginning of the last line.
- unsigned char * base = pixels.data() + image_size - line_size;
- unsigned char * mover = base;
+ UInt8 * base = pixels.data() + image_size - line_size;
+ UInt8 * mover = base;
// set the image's background color to black.
VIGRA_CSTD::memset (pixels.data (), 0, image_size);
// read the rle codes one by one.
- unsigned char c1, c2;
+ int c1, c2;
bool painting = true;
unsigned int x = 0;
@@ -704,9 +723,9 @@
// absolute mode. paint the following c2 bytes.
// then, eventually skip one byte to respect 16 bit boundaries.
- for (unsigned int k = 0; k < c2; ++k) {
- const unsigned char c = stream.get ();
- const unsigned char *map_base = map.data () + 3*c;
+ for (int k = 0; k < c2; ++k) {
+ const int c = stream.get ();
+ const UInt8 *map_base = map.data () + 3*c;
for (unsigned int j = 0; j < ncomp; ++j)
mover [j] = map_base [j];
mover += ncomp;
@@ -719,8 +738,8 @@
// plain rle: repeat c2 mapped, c1 times.
// a line break may not happen here.
- for (unsigned char i = 0; i < c1; ++i) {
- const unsigned char *map_base = map.data () + 3*c2;
+ for (int i = 0; i < c1; ++i) {
+ const UInt8 *map_base = map.data () + 3*c2;
for (unsigned int j = 0; j < ncomp; ++j)
mover [j] = map_base [j];
mover += ncomp;
@@ -741,13 +760,15 @@
// make room for the pixels
pixels.resize(image_size);
- // padding after each line
- const unsigned int pad_size = ( 3 * info_header.width ) % 4;
-
+ // padding after each scanline.
+ // citing Kevin D. Quitt's mail to wotsit.org:
+ // In RGB encoding (no compression), when using 8 bits per pixel, lines
+ // must start on a long-word boundary (i.e., low two bits zero).
+ const unsigned int pad_size = (line_size % 4) ? 4 - (line_size % 4) : 0;
// setup the base pointer at one line after the end
- unsigned char * base = pixels.data() + image_size;
- unsigned char * mover = base;
+ UInt8 * base = pixels.data() + image_size;
+ UInt8 * mover;
// read scanlines from bottom to top
for ( int y = info_header.height - 1; y >= 0; --y ) {
@@ -840,7 +861,7 @@
std::ofstream stream;
// image container
- void_vector< unsigned char > pixels;
+ void_vector< UInt8 > pixels;
int scanline;
@@ -865,7 +886,7 @@
BmpEncoderImpl::BmpEncoderImpl( const std::string & filename )
: bo( "little endian" ),
-#ifdef WIN32
+#ifdef VIGRA_NEED_BIN_STREAMS
stream( filename.c_str(), std::ios::binary ),
#else
stream( filename.c_str() ),
@@ -946,7 +967,7 @@
{
const unsigned int num_colors = 256;
for ( unsigned int i = 0; i < num_colors; ++i ) {
- const unsigned char c = i;
+ const int c = i;
stream.put(c);
stream.put(c);
stream.put(c);
@@ -962,8 +983,8 @@
if ( pad_size > 0 )
pad_size = 4 - pad_size;
- unsigned char * base = pixels.data() + image_size;
- unsigned char * mover = base;
+ UInt8 * base = pixels.data() + image_size;
+ UInt8 * mover = base;
// write scanlines, the scanlines are already in bottom-to-top
// order.
@@ -989,12 +1010,10 @@
{
const unsigned int line_size = 3 * info_header.width;
const unsigned int image_size = info_header.height * line_size;
- unsigned int pad_size = ( 3 * info_header.width ) % 4;
- if ( pad_size > 0 )
- pad_size = 4 - pad_size;
+ const unsigned int pad_size = (line_size % 4) ? 4 - (line_size % 4) : 0;
- unsigned char * base = pixels.data() + image_size;
- unsigned char * mover = base;
+ UInt8 * base = pixels.data() + image_size;
+ UInt8 * mover = base;
// write scanlines, the scanlines are already in bottom-to-top
// order.
@@ -1035,19 +1054,19 @@
void BmpEncoder::setWidth( unsigned int width )
{
- VIGRA_IMPEX2_FINALIZED(pimpl->finalized);
+ VIGRA_IMPEX_FINALIZED(pimpl->finalized);
pimpl->info_header.width = width;
}
void BmpEncoder::setHeight( unsigned int height )
{
- VIGRA_IMPEX2_FINALIZED(pimpl->finalized);
+ VIGRA_IMPEX_FINALIZED(pimpl->finalized);
pimpl->info_header.height = height;
}
void BmpEncoder::setNumBands( unsigned int bands )
{
- VIGRA_IMPEX2_FINALIZED(pimpl->finalized);
+ VIGRA_IMPEX_FINALIZED(pimpl->finalized);
vigra_precondition( ( bands == 1 ) || ( bands == 3 ),
"bmp supports only rgb and grayscale images" );
pimpl->grayscale = ( bands == 1 );
@@ -1056,12 +1075,12 @@
void BmpEncoder::setCompressionType( const std::string & comp,
int quality )
{
- VIGRA_IMPEX2_FINALIZED(pimpl->finalized);
+ VIGRA_IMPEX_FINALIZED(pimpl->finalized);
}
void BmpEncoder::setPixelType( const std::string & pixelType )
{
- VIGRA_IMPEX2_FINALIZED(pimpl->finalized);
+ VIGRA_IMPEX_FINALIZED(pimpl->finalized);
vigra_precondition( pixelType == "UINT8",
"bmp supports only the UINT8 pixeltype" );
}
@@ -1073,7 +1092,7 @@
void BmpEncoder::finalizeSettings()
{
- VIGRA_IMPEX2_FINALIZED(pimpl->finalized);
+ VIGRA_IMPEX_FINALIZED(pimpl->finalized);
pimpl->finalize();
}
Index: error.hxx
===================================================================
RCS file: /cvsroot/hugin/hugin/src/foreign/vigra_impex/error.hxx,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -u -d -r1.1 -r1.1.2.1
--- error.hxx 3 Jul 2004 09:55:16 -0000 1.1
+++ error.hxx 3 Mar 2006 00:31:48 -0000 1.1.2.1
@@ -1,9 +1,46 @@
-#ifndef VIGRA_IMPEX2_ERROR_HXX
-#define VIGRA_IMPEX2_ERROR_HXX
+/************************************************************************/
+/* */
+/* Copyright 2002-2004 by Ullrich Koethe and Gunnar Kedenburg */
+/* Cognitive Systems Group, University of Hamburg, Germany */
+/* */
+/* This file is part of the VIGRA computer vision library. */
+/* ( Version 1.4.0, Dec 21 2005 ) */
+/* The VIGRA Website is */
+/* http://kogs-www.informatik.uni-hamburg.de/~koethe/vigra/ */
+/* Please direct questions, bug reports, and contributions to */
+/* koethe@... or */
+/* vigra@... */
+/* */
+/* Permission is hereby granted, free of charge, to any person */
+/* obtaining a copy of this software and associated documentation */
+/* files (the "Software"), to deal in the Software without */
+/* restriction, including without limitation the rights to use, */
+/* copy, modify, merge, publish, distribute, sublicense, and/or */
+/* sell copies of the Software, and to permit persons to whom the */
+/* Software is furnished to do so, subject to the following */
+/* conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the */
+/* Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES */
+/* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND */
+/* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT */
+/* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, */
+/* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING */
+/* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR */
+/* OTHER DEALINGS IN THE SOFTWARE. */
+/* */
+/************************************************************************/
+
+#ifndef VIGRA_IMPEX_ERROR_HXX
+#define VIGRA_IMPEX_ERROR_HXX
#include "vigra/error.hxx"
-#define VIGRA_IMPEX2_FINALIZED(p) { if (p) \
+#define VIGRA_IMPEX_FINALIZED(p) { if (p) \
vigra_precondition( false, "encoder settings were already finalized" ); }
#endif // VIGRA_IMPEX_ERROR_HXX
Index: png.cxx
===================================================================
RCS file: /cvsroot/hugin/hugin/src/foreign/vigra_impex/png.cxx,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -u -d -r1.2 -r1.2.2.1
--- png.cxx 27 Oct 2004 18:12:51 -0000 1.2
+++ png.cxx 3 Mar 2006 00:31:48 -0000 1.2.2.1
@@ -4,31 +4,56 @@
/* Cognitive Systems Group, University of Hamburg, Germany */
/* */
/* This file is part of the VIGRA computer vision library. */
-/* ( Version 1.2.0, Aug 07 2003 ) */
-/* You may use, modify, and distribute this software according */
-/* to the terms stated in the LICENSE file included in */
-/* the VIGRA distribution. */
-/* */
+/* ( Version 1.4.0, Dec 21 2005 ) */
/* The VIGRA Website is */
/* http://kogs-www.informatik.uni-hamburg.de/~koethe/vigra/ */
/* Please direct questions, bug reports, and contributions to */
-/* koethe@... */
+/* koethe@... or */
+/* vigra@... */
/* */
-/* THIS SOFTWARE IS PROVIDED AS IS AND WITHOUT ANY EXPRESS OR */
-/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
-/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */
+/* Permission is hereby granted, free of charge, to any person */
+/* obtaining a copy of this software and associated documentation */
+/* files (the "Software"), to deal in the Software without */
+/* restriction, including without limitation the rights to use, */
+/* copy, modify, merge, publish, distribute, sublicense, and/or */
+/* sell copies of the Software, and to permit persons to whom the */
+/* Software is furnished to do so, subject to the following */
+/* conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the */
+/* Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES */
+/* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND */
+/* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT */
+/* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, */
+/* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING */
+/* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR */
+/* OTHER DEALINGS IN THE SOFTWARE. */
/* */
/************************************************************************/
-
-#include <config.h>
+/* Modifications by Pablo d'Angelo
+ * updated to vigra 1.4 by Douglas Wilkins
+ * as of 18 Febuary 2006:
+ * - Added UINT16 pixel types.
+ * - Added support for obtaining extra bands beyond RGB.
+ * - Added support for a position field that indicates the start of this
+ * image relative to some global origin.
+ * - Added support for x and y resolution fields.
+ */
#ifdef HasPNG
#include <stdexcept>
#include <iostream>
+#include "vigra/config.hxx"
+#include "vigra/sized_int.hxx"
#include "void_vector.hxx"
#include "auto_file.hxx"
#include "png.hxx"
+#include "byteorder.hxx"
#include "error.hxx"
extern "C"
@@ -40,7 +65,7 @@
#error "please update your libpng to at least 1.2.1"
#endif
-// TODO: per-scanline writing
+// TODO: per-scanline reading/writing
namespace vigra {
@@ -72,6 +97,12 @@
desc.fileExtensions.resize(1);
desc.fileExtensions[0] = "png";
+ desc.bandNumbers.resize(4);
+ desc.bandNumbers[0] = 1;
+ desc.bandNumbers[1] = 2;
+ desc.bandNumbers[2] = 3;
+ desc.bandNumbers[3] = 4;
+
return desc;
}
@@ -117,7 +148,7 @@
// image header fields
png_uint_32 width, height, components;
png_uint_32 extra_components;
- vigra::Diff2D position;
+ Diff2D position;
int bit_depth, color_type;
// scanline counter
@@ -145,7 +176,8 @@
};
PngDecoderImpl::PngDecoderImpl( const std::string & filename )
-#ifdef WIN32
+#ifdef VIGRA_NEED_BIN_STREAMS
+ // Returns the layer
: file( filename.c_str(), "rb" ),
#else
: file( filename.c_str(), "r" ),
@@ -204,12 +236,19 @@
png_read_info( png, info );
// pull over the header fields
- int compression_method, filter_method;
+ int interlace_method, compression_method, filter_method;
if (setjmp(png->jmpbuf))
vigra_postcondition( false, png_error_message.insert(0, "error in png_get_IHDR(): ").c_str() );
png_get_IHDR( png, info, &width, &height, &bit_depth, &color_type,
&interlace_method, &compression_method, &filter_method );
+ // check whether byteorder must be swapped (png files are big-endian)
+ byteorder bo;
+ if(bit_depth == 16 && bo.get_host_byteorder() == "little endian")
+ {
+ png_set_swap(png);
+ }
+
// transform palette to rgb
if ( color_type == PNG_COLOR_TYPE_PALETTE) {
if (setjmp(png->jmpbuf))
@@ -227,20 +266,7 @@
bit_depth = 8;
}
- // swap bytes if we are on a little endian system.
- // 16 bit png's are stored in big endian byte order
- if (bit_depth == 16) {
- unsigned char swapTest[2] = { 1, 0 };
- if( *(short *) swapTest == 1 ) {
- // little endian, swap
- // expand gray values to at least one byte size
- if (setjmp(png->jmpbuf))
- vigra_postcondition( false,png_error_message.insert(0, "error in png_set_swap(): ").c_str());
- png_set_swap(png);
- }
- }
- // dangelo: keep the alpha channel
#if 0
// strip alpha channel
if ( color_type & PNG_COLOR_MASK_ALPHA ) {
@@ -249,7 +275,8 @@
png_set_strip_alpha(png);
color_type ^= PNG_COLOR_MASK_ALPHA;
}
-#endif
+#endif /* #if 0 */
+
// find out the number of components
switch (color_type) {
@@ -306,7 +333,6 @@
vigra_postcondition( false,png_error_message.insert(0, "error in png_set_interlace_handling(): ").c_str());
n_interlace_passes = png_set_interlace_handling(png);
-
// update png library state to reflect any changes that were made
if (setjmp(png->jmpbuf))
vigra_postcondition( false, png_error_message.insert(0, "error in png_read_update_info(): ").c_str() );
@@ -379,7 +405,7 @@
return pimpl->y_resolution;
}
- vigra::Diff2D PngDecoder::getPosition() const
+ Diff2D PngDecoder::getPosition() const
{
return pimpl->position;
}
@@ -445,7 +471,6 @@
png_uint_32 extra_components;
int bit_depth, color_type;
-
// scanline counter
int scanline;
@@ -453,7 +478,7 @@
bool finalized;
// image layer position
- vigra::Diff2D position;
+ Diff2D position;
// resolution
float x_resolution, y_resolution;
@@ -468,7 +493,7 @@
};
PngEncoderImpl::PngEncoderImpl( const std::string & filename )
-#ifdef WIN32
+#ifdef VIGRA_NEED_BIN_STREAMS
: file( filename.c_str(), "wb" ),
#else
: file( filename.c_str(), "w" ),
@@ -556,6 +581,14 @@
row_pointers[i] = mover;
mover += row_stride;
}
+
+ // check whether byteorder must be swapped (png files must be big-endian)
+ byteorder bo;
+ if(bit_depth == 16 && bo.get_host_byteorder() == "little endian")
+ {
+ png_set_swap(png);
+ }
+
// write the whole image
if (setjmp(png->jmpbuf))
vigra_postcondition( false, png_error_message.insert(0, "error in png_write_image(): ").c_str() );
@@ -582,19 +615,19 @@
void PngEncoder::setWidth( unsigned int width )
{
- VIGRA_IMPEX2_FINALIZED(pimpl->finalized);
+ VIGRA_IMPEX_FINALIZED(pimpl->finalized);
pimpl->width = width;
}
void PngEncoder::setHeight( unsigned int height )
{
- VIGRA_IMPEX2_FINALIZED(pimpl->finalized);
+ VIGRA_IMPEX_FINALIZED(pimpl->finalized);
pimpl->height = height;
}
void PngEncoder::setNumBands( unsigned int bands )
{
- VIGRA_IMPEX2_FINALIZED(pimpl->finalized);
+ VIGRA_IMPEX_FINALIZED(pimpl->finalized);
if ( bands == 1 )
pimpl->color_type = PNG_COLOR_TYPE_GRAY;
else if ( bands == 2 )
@@ -608,35 +641,33 @@
pimpl->components = bands;
}
-
-
void PngEncoder::setCompressionType( const std::string & comp,
int quality )
{
// nothing is settable => do nothing
}
- void PngEncoder::setPosition( const vigra::Diff2D & pos )
+ void PngEncoder::setPosition( const Diff2D & pos )
{
- VIGRA_IMPEX2_FINALIZED(pimpl->finalized);
+ VIGRA_IMPEX_FINALIZED(pimpl->finalized);
pimpl->position = pos;
}
void PngEncoder::setXResolution( float xres )
{
- VIGRA_IMPEX2_FINALIZED(pimpl->finalized);
+ VIGRA_IMPEX_FINALIZED(pimpl->finalized);
pimpl->x_resolution = xres;
}
void PngEncoder::setYResolution( float yres )
{
- VIGRA_IMPEX2_FINALIZED(pimpl->finalized);
+ VIGRA_IMPEX_FINALIZED(pimpl->finalized);
pimpl->y_resolution = yres;
}
void PngEncoder::setPixelType( const std::string & pixelType )
{
- VIGRA_IMPEX2_FINALIZED(pimpl->finalized);
+ VIGRA_IMPEX_FINALIZED(pimpl->finalized);
if ( pixelType == "UINT8" )
pimpl->bit_depth = 8;
else if ( pixelType == "UINT16" )
@@ -652,7 +683,7 @@
void PngEncoder::finalizeSettings()
{
- VIGRA_IMPEX2_FINALIZED(pimpl->finalized);
+ VIGRA_IMPEX_FINALIZED(pimpl->finalized);
pimpl->finalize();
}
@@ -663,14 +694,14 @@
switch (pimpl->bit_depth) {
case 8:
{
- typedef void_vector< unsigned char > bands_type;
+ typedef void_vector< UInt8 > bands_type;
bands_type & bands
= static_cast< bands_type & >(pimpl->bands);
return bands.data() + index;
}
case 16:
{
- typedef void_vector<short> bands_type;
+ typedef void_vector<Int16> bands_type;
bands_type & bands
= static_cast< bands_type & >(pimpl->bands);
return bands.data() + index;
Index: viff.hxx
===================================================================
RCS file: /cvsroot/hugin/hugin/src/foreign/vigra_impex/viff.hxx,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -u -d -r1.1 -r1.1.2.1
--- viff.hxx 3 Jul 2004 09:55:16 -0000 1.1
+++ viff.hxx 3 Mar 2006 00:31:48 -0000 1.1.2.1
@@ -4,24 +4,39 @@
/* Cognitive Systems Group, University of Hamburg, Germany */
/* */
/* This file is part of the VIGRA computer vision library. */
-/* ( Version 1.2.0, Aug 07 2003 ) */
-/* You may use, modify, and distribute this software according */
-/* to the terms stated in the LICENSE file included in */
-/* the VIGRA distribution. */
-/* */
+/* ( Version 1.4.0, Dec 21 2005 ) */
/* The VIGRA Website is */
/* http://kogs-www.informatik.uni-hamburg.de/~koethe/vigra/ */
/* Please direct questions, bug reports, and contributions to */
-/* koethe@... */
+/* koethe@... or */
+/* vigra@... */
/* */
-/* THIS SOFTWARE IS PROVIDED AS IS AND WITHOUT ANY EXPRESS OR */
-/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
-/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */
+/* Permission is hereby granted, free of charge, to any person */
+/* obtaining a copy of this software and associated documentation */
+/* files (the "Software"), to deal in the Software without */
+/* restriction, including without limitation the rights to use, */
+/* copy, modify, merge, publish, distribute, sublicense, and/or */
+/* sell copies of the Software, and to permit persons to whom the */
+/* Software is furnished to do so, subject to the following */
+/* conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the */
+/* Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES */
+/* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND */
+/* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT */
+/* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, */
+/* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING */
+/* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR */
+/* OTHER DEALINGS IN THE SOFTWARE. */
/* */
/************************************************************************/
-#ifndef VIGRA_IMPEX2_VIFF_HXX
-#define VIGRA_IMPEX2_VIFF_HXX
+#ifndef VIGRA_IMPEX_VIFF_HXX
+#define VIGRA_IMPEX_VIFF_HXX
#include "vigra/codec.hxx"
Index: gif.cxx
===================================================================
RCS file: /cvsroot/hugin/hugin/src/foreign/vigra_impex/gif.cxx,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -u -d -r1.2 -r1.2.2.1
--- gif.cxx 27 Oct 2004 18:12:51 -0000 1.2
+++ gif.cxx 3 Mar 2006 00:31:48 -0000 1.2.2.1
@@ -4,27 +4,43 @@
/* Cognitive Systems Group, University of Hamburg, Germany */
/* */
/* This file is part of the VIGRA computer vision library. */
-/* ( Version 1.2.0, Aug 07 2003 ) */
-/* You may use, modify, and distribute this software according */
-/* to the terms stated in the LICENSE file included in */
-/* the VIGRA distribution. */
-/* */
+/* ( Version 1.4.0, Dec 21 2005 ) */
/* The VIGRA Website is */
/* http://kogs-www.informatik.uni-hamburg.de/~koethe/vigra/ */
/* Please direct questions, bug reports, and contributions to */
-/* koethe@... */
+/* koethe@... or */
+/* vigra@... */
/* */
-/* THIS SOFTWARE IS PROVIDED AS IS AND WITHOUT ANY EXPRESS OR */
-/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
-/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */
+/* Permission is hereby granted, free of charge, to any person */
+/* obtaining a copy of this software and associated documentation */
+/* files (the "Software"), to deal in the Software without */
+/* restriction, including without limitation the rights to use, */
+/* copy, modify, merge, publish, distribute, sublicense, and/or */
+/* sell copies of the Software, and to permit persons to whom the */
+/* Software is furnished to do so, subject to the following */
+/* conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the */
+/* Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES */
+/* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND */
+/* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT */
+/* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, */
+/* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING */
+/* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR */
+/* OTHER DEALINGS IN THE SOFTWARE. */
/* */
/************************************************************************/
-#include <config.h>
#include <fstream>
#include <stdexcept>
#include <vector>
#include <algorithm>
+#include "vigra/config.hxx"
+#include "vigra/sized_int.hxx"
#include "error.hxx"
#include "byteorder.hxx"
#include "void_vector.hxx"
@@ -36,9 +52,9 @@
namespace {
- int read_data_block(std::ifstream & stream, void_vector<unsigned char> & data)
+ int read_data_block(std::ifstream & stream, void_vector<UInt8> & data)
{
- unsigned char count;
+ int count;
count = stream.get();
if(!stream.good())
@@ -54,11 +70,11 @@
struct ColorCluster
{
- unsigned char cmin[3], cmax[3];
- std::vector<unsigned char *> entries;
+ UInt8 cmin[3], cmax[3];
+ std::vector<UInt8 *> entries;
mutable int largest_dim, largest_diff;
- typedef unsigned char rgb[3];
+ typedef UInt8 rgb[3];
struct ColorSorter
{
@@ -68,7 +84,7 @@
: dim(d)
{}
- bool operator()(unsigned char * l, unsigned char * r) const
+ bool operator()(UInt8 * l, UInt8 * r) const
{
return l[dim] < r[dim];
}
@@ -80,7 +96,7 @@
reset_minmax();
}
- void add(unsigned char * entry)
+ void add(UInt8 * entry)
{
entries.push_back(entry);
@@ -98,7 +114,7 @@
largest_dim = -1;
}
- void update_minmax(unsigned char * entry)
+ void update_minmax(UInt8 * entry)
{
for(int i=0; i<3; ++i)
{
@@ -140,11 +156,11 @@
update_largest();
std::sort(entries.begin(), entries.end(), ColorSorter(largest_dim));
- std::vector<unsigned char *> old_list;
+ std::vector<UInt8 *> old_list;
old_list.swap(entries);
reset_minmax();
- unsigned int i = 0;
+ UInt32 i = 0;
for(; i<old_list.size()/2; ++i)
{
add(old_list[i]);
@@ -155,35 +171,41 @@
}
}
- void average(unsigned char * color) const
+ void average(UInt8 * color) const
{
- int r = 0, g = 0, b = 0;
+ UInt32 r = 0, g = 0, b = 0;
- for(unsigned int i=0; i<entries.size(); ++i)
+ for(UInt32 i=0; i<entries.size(); ++i)
{
r += entries[i][0];
g += entries[i][1];
b += entries[i][2];
}
- color[0] = r / entries.size();
- color[1] = g / entries.size();
- color[2] = b / entries.size();
+ //
+ // r/g/b is the sum of all the uchar entries. entries.size
+ // is the count; we compute the average here and can safely
+ // cast this back to uchar
+ //
+
+ color[0] = (UInt8)(r / entries.size());
+ color[1] = (UInt8)(g / entries.size());
+ color[2] = (UInt8)(b / entries.size());
}
- int size() const
+ size_t size() const
{
return entries.size();
}
};
- void find_color_clusters(void_vector<unsigned char> & data,
- std::vector<ColorCluster> & clusters, void_vector<unsigned char> & colors)
+ void find_color_clusters(void_vector<UInt8> & data,
+ std::vector<ColorCluster> & clusters, void_vector<UInt8> & colors)
{
- int count = clusters.size();
- int size = data.size() / 3;
- int i, current;
+ size_t count = clusters.size();
+ size_t size = data.size() / 3;
+ size_t i, current;
for(i=0; i<size; ++i)
{
clusters[0].add(data.begin()+3*i);
@@ -191,7 +213,7 @@
for(current = 1; current < count; ++current)
{
- int largest_index = 0;
+ size_t largest_index = 0;
for(i=1; i<current; ++i)
{
if(clusters[largest_index] < clusters[i])
@@ -217,14 +239,13 @@
}
}
- void find_color_indices(void_vector<unsigned char> & data,
- std::vector<ColorCluster> & clusters, void_vector<unsigned char> & indices)
+ void find_color_indices(void_vector<UInt8> & data,
+ std::vector<ColorCluster> & clusters, void_vector<UInt8> & indices)
{
- int count = clusters.size();
- unsigned char * base = data.begin();
+ int count = (int)clusters.size();
+ UInt8 * base = data.begin();
- int i;
- for(i=0; i<count; ++i)
+ for(int i=0; i<count; ++i)
{
for(int j=0; j<clusters[i].size(); ++j)
{
@@ -261,6 +282,10 @@
desc.fileExtensions.resize(1);
desc.fileExtensions[0] = "gif";
+ desc.bandNumbers.resize(2);
+ desc.bandNumbers[0] = 1;
+ desc.bandNumbers[1] = 3;
+
return desc;
}
@@ -278,8 +303,8 @@
{
// attributes
- unsigned short width, height, maplength;
- unsigned char bits_per_pixel;
+ UInt16 width, height, maplength;
+ UInt8 bits_per_pixel;
bool global_colormap, interlace;
// methods
@@ -292,7 +317,7 @@
void GIFHeader::global_from_stream( std::ifstream & stream, const byteorder & bo )
{
- unsigned char flag, c, background;
+ UInt8 flag, c, background;
read_field( stream, bo, width );
read_field( stream, bo, height );
read_field( stream, bo, flag );
@@ -310,14 +335,14 @@
{
write_field( stream, bo, width );
write_field( stream, bo, height );
- write_field( stream, bo, (unsigned char)0xf7 );
- write_field( stream, bo, (unsigned char)0 ); // background
- write_field( stream, bo, (unsigned char)0 ); // must be zero
+ write_field( stream, bo, (UInt8)0xf7 );
+ write_field( stream, bo, (UInt8)0 ); // background
+ write_field( stream, bo, (UInt8)0 ); // must be zero
}
bool GIFHeader::local_from_stream( std::ifstream & stream, const byteorder & bo )
{
- unsigned char c, flag;
+ UInt8 c, flag;
for ( ; ; )
{
c = stream.get();
@@ -325,7 +350,7 @@
return false;
if(c == '!')
{
- void_vector<unsigned char> extensions;
+ void_vector<UInt8> extensions;
// read and ignore extension data
read_field( stream, bo, c );
@@ -335,7 +360,7 @@
break;
}
- unsigned short x,y;
+ UInt16 x,y;
read_field( stream, bo, x );
read_field( stream, bo, y );
@@ -355,11 +380,11 @@
void GIFHeader::local_to_stream( std::ofstream & stream, const byteorder & bo )
{
write_field( stream, bo, ',' );
- write_field( stream, bo, (unsigned short)0 ); // x
- write_field( stream, bo, (unsigned short)0 ); // y
+ write_field( stream, bo, (UInt16)0 ); // x
+ write_field( stream, bo, (UInt16)0 ); // y
write_field( stream, bo, width );
write_field( stream, bo, height );
- write_field( stream, bo, (unsigned char)0); // use global colormap, no interlace
+ write_field( stream, bo, (UInt8)0); // use global colormap, no interlace
}
struct GIFDecoderImpl
@@ -369,9 +394,9 @@
GIFHeader header;
std::ifstream stream;
byteorder bo;
- void_vector< unsigned char > maps, bands;
- unsigned int components;
- unsigned char * scanline;
+ void_vector< UInt8 > maps, bands;
+ UInt32 components;
+ UInt8 * scanline;
// methods
@@ -383,7 +408,7 @@
};
GIFDecoderImpl::GIFDecoderImpl( const std::string & filename )
-#ifdef WIN32
+#ifdef VIGRA_NEED_BIN_STREAMS
: stream( filename.c_str(), std::ios::binary ),
#else
: stream( filename.c_str() ),
@@ -469,19 +494,19 @@
code,
count;
- register unsigned int
+ register unsigned long
datum;
- void_vector<short> prefix(MaxStackSize);
- void_vector<unsigned char> suffix(MaxStackSize);
- void_vector<unsigned char> pixel_stack(MaxStackSize+1);
- void_vector<unsigned char> packet(256);
- void_vector<unsigned short> indices(header.width*header.height);
+ void_vector<Int16> prefix(MaxStackSize);
+ void_vector<UInt8> suffix(MaxStackSize);
+ void_vector<UInt8> pixel_stack(MaxStackSize+1);
+ void_vector<UInt8> packet(256);
+ void_vector<UInt16> indices(header.width*header.height);
- register unsigned char *c;
- register unsigned short *p = indices.begin();
+ register UInt8 *c;
+ register UInt16 *p = indices.begin();
- unsigned char
+ UInt8
data_size,
first,
*top_stack;
@@ -596,17 +621,17 @@
Pop a pixel off the pixel stack.
*/
top_stack--;
- *p++ =(unsigned short) *top_stack;
+ *p++ =(UInt16) *top_stack;
}
// decode intelaced image
if (header.interlace)
{
- void_vector<unsigned short> non_interlaced(header.width*header.height);
+ void_vector<UInt16> non_interlaced(header.width*header.height);
int pass, x, y;
- register unsigned short *q;
+ register UInt16 *q;
static int
interlace_rate[4] = { 8, 8, 4, 2 },
@@ -716,11 +741,11 @@
GIFHeader header;
std::ofstream stream;
byteorder bo;
- void_vector< unsigned char > bands;
- void_vector< unsigned char > maps;
- void_vector< unsigned char > indices;
- unsigned int components;
- unsigned char *scanline;
+ void_vector< UInt8 > bands;
+ void_vector< UInt8 > maps;
+ void_vector< UInt8 > indices;
+ UInt32 components;
+ UInt8 *scanline;
bool finalized;
// methods
@@ -730,7 +755,7 @@
void writeColormap();
void writeImageData();
void reduceTo256Colors();
- void outputEncodedData(void_vector< unsigned char > &);
+ void outputEncodedData(void_vector< UInt8 > &);
// ctor
@@ -738,7 +763,7 @@
};
GIFEncoderImpl::GIFEncoderImpl( const std::string & filename )
-#ifdef WIN32
+#ifdef VIGRA_NEED_BIN_STREAMS
: stream( filename.c_str(), std::ios::binary ),
#else
: stream( filename.c_str() ),
@@ -818,7 +843,7 @@
}
}
- void GIFEncoderImpl::outputEncodedData(void_vector<unsigned char> & indices)
+ void GIFEncoderImpl::outputEncodedData(void_vector<UInt8> & indices)
{
#define MaxCode(number_bits) ((1 << (number_bits))-1)
#define MaxHashTable 5003
@@ -843,7 +868,7 @@
/* \
Add a character to current packet. \
*/ \
- packet[byte_count++]=(unsigned char) (datum & 0xff); \
+ packet[byte_count++]=(UInt8) (datum & 0xff); \
if (byte_count >= 254) \
{ \
stream.put(byte_count); \
@@ -868,20 +893,20 @@
byte_count,
number_bits,
data_size = header.bits_per_pixel;
- unsigned int i;
+ UInt32 i;
long
datum;
register int k;
- register unsigned char *p;
+ register UInt8 *p;
- void_vector<short> hash_code(MaxHashTable);
- void_vector<short> hash_prefix(MaxHashTable);
- void_vector<short> hash_suffix(MaxHashTable);
+ void_vector<Int16> hash_code(MaxHashTable);
+ void_vector<Int16> hash_prefix(MaxHashTable);
+ void_vector<Int16> hash_suffix(MaxHashTable);
- short
+ Int16
clear_code,
end_of_information_code,
free_code,
@@ -889,14 +914,14 @@
max_code,
waiting_code;
- void_vector<unsigned char> packet(256);
+ void_vector<UInt8> packet(256);
/*
Initialize GIF encoder.
*/
number_bits=data_size+1;
max_code=MaxCode(number_bits);
- clear_code=((short) 1 << data_size);
+ clear_code=((Int16) 1 << data_size);
end_of_information_code=clear_code+1;
free_code=clear_code+2;
byte_count=0;
@@ -957,7 +982,7 @@
/*
Add a character to current packet.
*/
- packet[byte_count++]=(unsigned char) (datum & 0xff);
+ packet[byte_count++]=(UInt8) (datum & 0xff);
if (byte_count >= 254)
{
stream.put(byte_count);
@@ -992,31 +1017,31 @@
void GIFEncoder::setWidth( unsigned int width )
{
- VIGRA_IMPEX2_FINALIZED(pimpl->finalized);
+ VIGRA_IMPEX_FINALIZED(pimpl->finalized);
pimpl->header.width = width;
}
void GIFEncoder::setHeight( unsigned int height )
{
- VIGRA_IMPEX2_FINALIZED(pimpl->finalized);
+ VIGRA_IMPEX_FINALIZED(pimpl->finalized);
pimpl->header.height = height;
}
void GIFEncoder::setNumBands( unsigned int numBands )
{
- VIGRA_IMPEX2_FINALIZED(pimpl->finalized);
+ VIGRA_IMPEX_FINALIZED(pimpl->finalized);
pimpl->components = numBands;
}
void GIFEncoder::setCompressionType( const std::string & comp,
int quality )
{
- VIGRA_IMPEX2_FINALIZED(pimpl->finalized);
+ VIGRA_IMPEX_FINALIZED(pimpl->finalized);
}
void GIFEncoder::setPixelType( const std::string & pixeltype )
{
- VIGRA_IMPEX2_FINALIZED(pimpl->finalized);
+ VIGRA_IMPEX_FINALIZED(pimpl->finalized);
vigra_precondition( pixeltype == "UINT8",
"GIFEncoder::setPixelType(): "
"GIF raster supports only the UINT8 pixeltype" );
Index: pnm.hxx
===================================================================
RCS file: /cvsroot/hugin/hugin/src/foreign/vigra_impex/pnm.hxx,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -u -d -r1.1 -r1.1.2.1
--- pnm.hxx 3 Jul 2004 09:55:16 -0000 1.1
+++ pnm.hxx 3 Mar 2006 00:31:48 -0000 1.1.2.1
@@ -4,24 +4,39 @@
/* Cognitive Systems Group, University of Hamburg, Germany */
/* */
/* This file is part of the VIGRA computer vision library. */
-/* ( Version 1.2.0, Aug 07 2003 ) */
-/* You may use, modify, and distribute this software according */
-/* to the terms stated in the LICENSE file included in */
-/* the VIGRA distribution. */
-/* */
+/* ( Version 1.4.0, Dec 21 2005 ) */
/* The VIGRA Website is */
/* http://kogs-www.informatik.uni-hamburg.de/~koethe/vigra/ */
/* Please direct questions, bug reports, and contributions to */
-/* koethe@... */
+/* koethe@... or */
+/* vigra@... */
/* */
-/* THIS SOFTWARE IS PROVIDED AS IS AND WITHOUT ANY EXPRESS OR */
-/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
-/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */
+/* Permission is hereby granted, free of charge, to any person */
+/* obtaining a copy of this software and associated documentation */
+/* files (the "Software"), to deal in the Software without */
+/* restriction, including without limitation the rights to use, */
+/* copy, modify, merge, publish, distribute, sublicense, and/or */
+/* sell copies of the Software, and to permit persons to whom the */
+/* Software is furnished to do so, subject to the following */
+/* conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the */
+/* Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES */
+/* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND */
+/* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT */
+/* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, */
+/* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING */
+/* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR */
+/* OTHER DEALINGS IN THE SOFTWARE. */
/* */
/************************************************************************/
-#ifndef VIGRA_IMPEX2_PNM_HXX
-#define VIGRA_IMPEX2_PNM_HXX
+#ifndef VIGRA_IMPEX_PNM_HXX
+#define VIGRA_IMPEX_PNM_HXX
#include "vigra/codec.hxx"
Index: sun.cxx
===================================================================
RCS file: /cvsroot/hugin/hugin/src/foreign/vigra_impex/sun.cxx,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -u -d -r1.2 -r1.2.2.1
--- sun.cxx 27 Oct 2004 18:12:51 -0000 1.2
+++ sun.cxx 3 Mar 2006 00:31:48 -0000 1.2.2.1
@@ -4,25 +4,41 @@
/* Cognitive Systems Group, University of Hamburg, Germany */
/* */
/* This file is part of the VIGRA computer vision library. */
-/* ( Version 1.2.0, Aug 07 2003 ) */
-/* You may use, modify, and distribute this software according */
-/* to the terms stated in the LICENSE file included in */
-/* the VIGRA distribution. */
-/* */
+/* ( Version 1.4.0, Dec 21 2005 ) */
/* The VIGRA Website is */
/* http://kogs-www.informatik.uni-hamburg.de/~koethe/vigra/ */
/* Please direct questions, bug reports, and contributions to */
-/* koethe@... */
+/* koethe@... or */
+/* vigra@... */
/* */
-/* THIS SOFTWARE IS PROVIDED AS IS AND WITHOUT ANY EXPRESS OR */
-/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
-/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */
+/* Permission is hereby granted, free of charge, to any person */
+/* obtaining a copy of this software and associated documentation */
+/* files (the "Software"), to deal in the Software without */
+/* restriction, including without limitation the rights to use, */
+/* copy, modify, merge, publish, distribute, sublicense, and/or */
+/* sell copies of the Software, and to permit persons to whom the */
+/* Software is furnished to do so, subject to the following */
+/* conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the */
+/* Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES */
+/* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND */
+/* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT */
+/* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, */
+/* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING */
+/* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR */
+/* OTHER DEALINGS IN THE SOFTWARE. */
/* */
/************************************************************************/
-#include <config.h>
#include <fstream>
#include <stdexcept>
+#include "vigra/config.hxx"
+#include "vigra/sized_int.hxx"
#include "error.hxx"
#include "byteorder.hxx"
#include "void_vector.hxx"
@@ -71,6 +87,10 @@
desc.fileExtensions.resize(1);
desc.fileExtensions[0] = "ras";
+ desc.bandNumbers.resize(2);
+ desc.bandNumbers[0] = 1;
+ desc.bandNumbers[1] = 3;
+
return desc;
}
@@ -86,7 +106,7 @@
struct SunHeader
{
- typedef unsigned long field_type;
+ typedef UInt32 field_type;
// attributes
@@ -127,8 +147,8 @@
SunHeader header;
std::ifstream stream;
byteorder bo;
- void_vector< unsigned char > maps, bands;
- unsigned int components, row_stride;
+ void_vector< UInt8 > maps, bands;
+ UInt32 components, row_stride;
bool recode;
// methods
@@ -141,7 +161,7 @@
};
SunDecoderImpl::SunDecoderImpl( const std::string & filename )
-#ifdef WIN32
+#ifdef VIGRA_NEED_BIN_STREAMS
: stream( filename.c_str(), std::ios::binary ),
#else
: stream( filename.c_str() ),
@@ -219,16 +239,16 @@
// recode if necessary
if (recode) {
- void_vector <unsigned char> recode_bands;
+ void_vector <UInt8> recode_bands;
if (header.depth == 1) {
- // expand to unsigned char.
+ // expand to UInt8.
recode_bands.resize (header.width);
for (unsigned int i = 0; i < header.width; ++i) {
// there are eight pixels in each byte.
- const unsigned char b = bands [i/8];
+ const UInt8 b = bands [i/8];
recode_bands [i] = b >> i%8 & 0x01;
}
@@ -239,13 +259,13 @@
// color map the scanline.
if (header.maptype == RMT_EQUAL_RGB) {
- // map from unsigned char to rgb
+ // map from UInt8 to rgb
recode_bands.resize (3*header.width);
const unsigned int mapstride = header.maplength/3;
- unsigned char *recode_mover = recode_bands.data ();
+ UInt8 *recode_mover = recode_bands.data ();
for (unsigned int i = 0; i < header.width; ++i) {
// find out the pointer to the red color
- unsigned char *map_mover = maps.data () + bands [i];
+ UInt8 *map_mover = maps.data () + bands [i];
// red
*recode_mover++ = *map_mover;
map_mover += mapstride;
@@ -258,7 +278,7 @@
} else if (header.maptype == RMT_RAW) {
- // map from unsigned char to unsigned char
+ // map from UInt8 to UInt8
recode_bands.resize (header.width);
for (unsigned int i = 0; i < header.width; ++i)
recode_bands [i] = maps [bands [i]];
@@ -273,7 +293,7 @@
if (header.type == RT_STANDARD && header.maptype != RMT_EQUAL_RGB
&& components == 3) {
- void_vector <unsigned char> recode_bands (3*header.width);
+ void_vector <UInt8> recode_bands (3*header.width);
for (unsigned int i = 0; i < header.width; ++i) {
recode_bands [3*i] = bands [3*i+2];
recode_bands [3*i+1] = bands [3*i+1];
@@ -345,8 +365,8 @@
SunHeader header;
std::ofstream stream;
byteorder bo;
- void_vector< unsigned char > bands;
- unsigned int components, row_stride;
+ void_vector< UInt8 > bands;
+ UInt32 components, row_stride;
bool finalized;
// methods
@@ -360,7 +380,7 @@
};
SunEncoderImpl::SunEncoderImpl( const std::string & filename )
-#ifdef WIN32
+#ifdef VIGRA_NEED_BIN_STREAMS
: stream( filename.c_str(), std::ios::binary ),
#else
: stream( filename.c_str() ),
@@ -415,7 +435,7 @@
{
if ( components == 3 ) {
// rgb -> bgr
- void_vector< unsigned char > recode_bands(bands.size());
+ void_vector< UInt8 > recode_bands(bands.size());
for ( unsigned int i = 0; i < header.width; ++i ) {
recode_bands[ 3 * i ] = bands[ 3 * i + 2 ];
recode_bands[ 3 * i + 1 ] = bands[ 3 * i + 1 ];
@@ -443,31 +463,31 @@
void SunEncoder::setWidth( unsigned int width )
{
- VIGRA_IMPEX2_FINALIZED(pimpl->finalized);
+ VIGRA_IMPEX_FINALIZED(pimpl->finalized);
pimpl->header.width = width;
}
void SunEncoder::setHeight( unsigned int height )
{
- VIGRA_IMPEX2_FINALIZED(pimpl->finalized);
+ VIGRA_IMPEX_FINALIZED(pimpl->finalized);
pimpl->header.height = height;
}
void SunEncoder::setNumBands( unsigned int numBands )
{
- VIGRA_IMPEX2_FINALIZED(pimpl->finalized);
+ VIGRA_IMPEX_FINALIZED(pimpl->finalized);
pimpl->components = numBands;
}
void SunEncoder::setCompressionType( const std::string & comp,
int quality )
{
- VIGRA_IMPEX2_FINALIZED(pimpl->finalized);
+ VIGRA_IMPEX_FINALIZED(pimpl->finalized);
}
void SunEncoder::setPixelType( const std::string & pixeltype )
{
- VIGRA_IMPEX2_FINALIZED(pimpl->finalized);
+ VIGRA_IMPEX_FINALIZED(pimpl->finalized);
vigra_precondition( pixeltype == "UINT8",
"SunEncoder::setPixelType(): "
"SUN raster supports only the UINT8 pixeltype" );
Index: tiff.cxx
===================================================================
RCS file: /cvsroot/hugin/hugin/src/foreign/vigra_impex/tiff.cxx,v
retrieving revision 1.5
retrieving revision 1.5.2.1
diff -u -d -r1.5 -r1.5.2.1
--- tiff.cxx 28 Oct 2005 16:54:12 -0000 1.5
+++ tiff.cxx 3 Mar 2006 00:31:48 -0000 1.5.2.1
@@ -4,29 +4,64 @@
/* Cognitive Systems Group, University of Hamburg, Germany */
/* */
/* This file is part of the VIGRA computer vision library. */
-/* ( Version 1.2.0, Aug 07 2003 ) */
-/* You may use, modify, and distribute this software according */
-/* to the terms stated in the LICENSE file included in */
-/* the VIGRA distribution. */
-/* */
+/* ( Version 1.4.0, Dec 21 2005 ) */
/* The VIGRA Website is */
/* http://kogs-www.informatik.uni-hamburg.de/~koethe/vigra/ */
/* Please direct questions, bug reports, and contributions to */
-/* koethe@... */
+/* koethe@... or */
+/* vigra@... */
/* */
-/* THIS SOFTWARE IS PROVIDED AS IS AND WITHOUT ANY EXPRESS OR */
-/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
-/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */
+/* Permission is hereby granted, free of charge, to any person */
+/* obtaining a copy of this software and associated documentation */
+/* files (the "Software"), to deal in the Software without */
+/* restriction, including without limitation the rights to use, */
+/* copy, modify, merge, publish, distribute, sublicense, and/or */
+/* sell copies of the Software, and to permit persons to whom the */
+/* Software is furnished to do so, subject to the following */
+/* conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the */
+/* Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES */
+/* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND */
+/* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT */
+/* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, */
+/* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING */
+/* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR */
+/* OTHER DEALINGS IN THE SOFTWARE. */
/* */
/************************************************************************/
-
-#include <config.h>
+/* Modifications by Pablo d'Angelo
+ * updated to vigra 1.4 by Douglas Wilkins
+ * as of 18 Febuary 2006:
+ * - Added UINT16 and UINT32 pixel types.
+ * - Added support for obtaining extra bands beyond RGB.
+ * - Added support for a position field that indicates the start of this
+ * image relative to some global origin.
+ * - Added support for x and y resolution fields.
+ *
+ * Modification by Andrew Mihal, 27 October 2004:
+ * updated to vigra 1.4 by Douglas Wilkins
+ * as of 18 Febuary 2006:
+ * - Modified encoder to better estimate the number of rows per strip.
+ * - Modified decoder to use the scanline interface - the strip-based
+ * interface hogs memory when the rows/strip value is large.
+ * - Added support for ICC profiles
+ * Andrew Mihal's modifications are covered by the VIGRA license.
+ */
#ifdef HasTIFF
+// NB (jbeda): tiffio.h is going to include this anyway. Let's include
+// it now so that we can control how it comes in. Namely, we want
+// to get our version that doesn't set the evil min/max macros.
+#include "vigra/windows.h"
+#include "vigra/sized_int.hxx"
#include "error.hxx"
#include "tiff.hxx"
-
#include <iostream>
#include <iomanip>
#include <sstream>
@@ -47,16 +82,16 @@
desc.fileType = "TIFF";
// init pixel types
- desc.pixelTypes.resize(8);
+ desc.pixelTypes.resize(9);
desc.pixelTypes[0] = "BILEVEL";
desc.pixelTypes[1] = "UINT8";
- desc.pixelTypes[1] = "INT8";
- desc.pixelTypes[2] = "UINT16";
- desc.pixelTypes[3] = "INT16";
- desc.pixelTypes[4] = "UINT32";
- desc.pixelTypes[5] = "INT32";
- desc.pixelTypes[6] = "FLOAT";
- desc.pixelTypes[7] = "DOUBLE";
+ desc.pixelTypes[2] = "INT8";
+ desc.pixelTypes[3] = "UINT16";
+ desc.pixelTypes[4] = "INT16";
+ desc.pixelTypes[5] = "UINT32";
+ desc.pixelTypes[6] = "INT32";
+ desc.pixelTypes[7] = "FLOAT";
+ desc.pixelTypes[8] = "DOUBLE";
// init compression types
desc.compressionTypes.resize(5);
@@ -84,6 +119,12 @@
desc.fileExtensions[0] = "tif";
desc.fileExtensions[1] = "tiff";
+ desc.bandNumbers.resize(4);
+ desc.bandNumbers[0] = 1;
+ desc.bandNumbers[1] = 2;
+ desc.bandNumbers[2] = 3;
+ desc.bandNumbers[3] = 4;
+
return desc;
}
@@ -107,13 +148,18 @@
TIFF * tiff;
tdata_t * stripbuffer;
tstrip_t strip;
+ // mihal 27-10-2004: use scanline interface
+ unsigned int scanline;
uint32 stripindex, stripheight;
uint32 width, height;
uint16 samples_per_pixel, bits_per_sample,
photometric, planarconfig, fillorder, extra_samples_per_pixel;
float x_resolution, y_resolution;
- vigra::Diff2D position;
+ Diff2D position;
+
+ UInt32 iccProfileLength;
+ const unsigned char *iccProfilePtr;
public:
@@ -127,10 +173,15 @@
tiff = 0;
stripbuffer = 0;
strip = 0;
+ // mihal 27-10-2004: use scanline interface
+ scanline = 0;
stripindex = 0;
- x_resolution = 150;
- y_resolution = 150;
+ planarconfig = PLANARCONFIG_CONTIG;
+ x_resolution = 0;
+ y_resolution = 0;
extra_samples_per_pixel = 0;
+ iccProfileLength = 0;
+ iccProfilePtr = NULL;
}
TIFFCodecImpl::~TIFFCodecImpl()
@@ -149,6 +200,7 @@
delete[] stripbuffer;
}
}
+
if ( tiff != 0 )
TIFFClose(tiff);
}
@@ -199,10 +251,9 @@
return "UINT16";
case 32:
return "UINT32";
- default:
- vigra_fail("unknown sample format");
}
break;
+
case SAMPLEFORMAT_INT:
switch (bits_per_sample) {
case 8:
@@ -211,8 +262,6 @@
return "INT16";
case 32:
return "INT32";
- default:
- vigra_fail("unknown sample format");
}
break;
@@ -222,13 +271,10 @@
return "FLOAT";
case 64:
return "DOUBLE";
- default:
- vigra_fail("unknown sample format");
}
break;
}
}
-
return "undefined";
}
@@ -268,8 +314,10 @@
TIFFGetField( tiff, TIFFTAG_IMAGELENGTH, &height );
// find out strip heights
- if ( !TIFFGetField( tiff, TIFFTAG_ROWSPERSTRIP, &stripheight ) )
- stripheight = height;
+ // mihal 27-10-2004: use scanline interface instead of strip interface
+ //if ( !TIFFGetField( tiff, TIFFTAG_ROWSPERSTRIP, &stripheight ) )
+ // stripheight = height;
+ stripheight = 1;
// get samples_per_pixel
samples_per_pixel = 0;
@@ -335,8 +383,10 @@
// get bits per pixel
if ( !TIFFGetField( tiff, TIFFTAG_BITSPERSAMPLE, &bits_per_sample ) )
+ {
+ std::cerr << "Warning: no TIFFTAG_BITSPERSAMPLE, using 8 bits per sample.\n";
bits_per_sample = 8;
-
+ }
// get pixeltype
if ( bits_per_sample != 1 ) {
@@ -352,7 +402,8 @@
// ERROR: no useable pixeltype found..
// imagemagick can write files without it..
// try to guess a suitable one here.
- switch (bits_per_sample) {
+ switch(bits_per_sample)
+ {
case 8:
pixeltype = "UINT8";
break;
@@ -360,17 +411,20 @@
pixeltype = "UINT16";
break;
case 32:
- pixeltype = "UINT32";
+ pixeltype = "UINT32"; // prefer int over float
break;
case 64:
pixeltype = "DOUBLE";
break;
default:
vigra_fail( "TIFFDecoderImpl::init(): Sampleformat or Datatype tag undefined and guessing sampletype from Bits per Sample failed." );
-
+ break;
}
+ std::cerr << "Warning: no TIFFTAG_SAMPLEFORMAT or TIFFTAG_DATATYPE, "
+ "guessing pixeltype '" << pixeltype << "'.\n";
}
}
+
} else {
// if each sample is 1 bit long
@@ -381,35 +435,6 @@
fillorder = FILLORDER_MSB2LSB;
}
-/*
- // read some properties of interest
- // 1. text fields
- struct TextTag{ int tag; const char * name;};
-
- // load the baseline fields.
- TextTag baselineTextTags[] =
- {
- {TIFFTAG_ARTIST, "Artist"},
- {TIFFTAG_COPYRIGHT, "Copyright"},
- {TIFFTAG_DATETIME, "DateTime"},
- {TIFFTAG_HOSTCOMPUTER, "HostComputer"},
- {TIFFTAG_IMAGEDESCRIPTION, "Description"},
- {TIFFTAG_MAKE, "Make"},
- {TIFFTAG_MODEL, "Model"},
- {TIFFTAG_SOFTWARE, "Software"},
- {0, NULL},
-
- };
-
- TextTag * cTag = baselineTextTags;
- while (cTag->name) {
- char * value;
- if ( !TIFFGetField( tiff, cTag->tag, &value )) {
- properties.insert(make_pair(std::string(cTag->name),
- ImageProperty(value)));
- }
- }
-*/
// other fields
uint16 u16value;
float unitLength = 1;
@@ -449,18 +474,29 @@
position.y = (int)floor(fvalue + 0.5);
}
+ // ICC Profile
+ TIFFGetField(tiff, TIFFTAG_ICCPROFILE, &iccProfileLength, &iccProfilePtr);
+
// allocate data buffers
- const unsigned int stripsize = TIFFStripSize(tiff);
+ // mihal 27-10-2004: use scanline interface instead of strip interface
+ //const unsigned int stripsize = TIFFStripSize(tiff);
+ const unsigned int stripsize = TIFFScanlineSize(tiff);
if ( planarconfig == PLANARCONFIG_SEPARATE ) {
stripbuffer = new tdata_t[samples_per_pixel];
for( unsigned int i = 0; i < samples_per_pixel; ++i ) {
stripbuffer[i] = 0;
+ }
+ for( unsigned int i = 0; i < samples_per_pixel; ++i ) {
stripbuffer[i] = _TIFFmalloc(stripsize);
+ if(stripbuffer[i] == 0)
+ throw std::bad_alloc();
}
} else {
stripbuffer = new tdata_t[1];
stripbuffer[0] = 0;
stripbuffer[0] = _TIFFmalloc(stripsize);
+ if(stripbuffer[0] == 0)
+ throw std::bad_alloc();
}
// let the codec read a new strip
@@ -471,18 +507,18 @@
TIFFDecoderImpl::currentScanlineOfBand( unsigned int band ) const
{
if ( bits_per_sample == 1 ) {
- unsigned char * const buf
- = static_cast< unsigned char * >(stripbuffer[0]);
+ UInt8 * const buf
+ = static_cast< UInt8 * >(stripbuffer[0]);
// XXX probably wrong
return buf + ( stripindex * width ) / 8;
} else {
if ( planarconfig == PLANARCONFIG_SEPARATE ) {
- unsigned char * const buf
- = static_cast< unsigned char * >(stripbuffer[band]);
+ UInt8 * const buf
+ = static_cast< UInt8 * >(stripbuffer[band]);
return buf + ( stripindex * width ) * ( bits_per_sample / 8 );
} else {
- unsigned char * const buf
- = static_cast< unsigned char * >(stripbuffer[0]);
+ UInt8 * const buf
+ = static_cast< UInt8 * >(stripbuffer[0]);
return buf + ( band + stripindex * width * samples_per_pixel )
* ( bits_per_sample / 8 );
}
@@ -496,13 +532,21 @@
stripindex = 0;
if ( planarconfig == PLANARCONFIG_SEPARATE ) {
- const tsize_t size = TIFFStripSize(tiff);
+ // mihal 27-10-2004: modified to use scanline interface
+ //const tsize_t size = TIFFStripSize(tiff);
+ const tsize_t size = TIFFScanlineSize(tiff);
for( unsigned int i = 0; i < samples_per_pixel; ++i )
- TIFFReadEncodedStrip( tiff, strip++, stripbuffer[i],
- size );
+ // mihal 27-10-2004: use scanline interface
+ //TIFFReadEncodedStrip( tiff, strip++, stripbuffer[i],
+ // size );
+ TIFFReadScanline(tiff, stripbuffer[i], scanline++, size);
} else {
- const tsize_t size = TIFFStripSize(tiff);
- TIFFReadEncodedStrip( tiff, strip++, stripbuffer[0], size );
+ // mihal 27-10-2004: modified to use scanline interface
+ //const tsize_t size = TIFFStripSize(tiff);
+ const tsize_t size = TIFFScanlineSize(tiff);
+ // mihal 27-10-2004: modified to use scanline interface
+ //TIFFReadEncodedStrip( tiff, strip++, stripbuffer[0], size );
+ TIFFReadScanline( tiff, stripbuffer[0], scanline++, size);
}
// XXX handle bilevel images
@@ -511,9 +555,11 @@
if ( samples_per_pixel == 1 && pixeltype == "UINT8" &&
photometric == PHOTOMETRIC_MINISWHITE ) {
- unsigned char * buf = static_cast< unsigned char * >
+ UInt8 * buf = static_cast< UInt8 * >
(stripbuffer[0]);
- const unsigned int n = TIFFStripSize(tiff);
+ // mihal 27-10-2004: modified to use scanline interface
+ //const unsigned int n = TIFFStripSize(tiff);
+ const unsigned int n = TIFFScanlineSize(tiff);
// invert every pixel
for ( unsigned int i = 0; i < n; ++i ) {
@@ -590,6 +636,15 @@
void TIFFDecoder::close() {}
void TIFFDecoder::abort() {}
+ UInt32 TIFFDecoder::getICCProfileLength() const
+ {
+ return pimpl->iccProfileLength;
+ }
+
+ const unsigned char *TIFFDecoder::getICCProfile() const
+ {
+ return pimpl->iccProfilePtr;
+ }
// this encoder always writes interleaved tiff files
class TIFFEncoderImpl : public TIFFCodecImpl
@@ -628,7 +683,7 @@
void * currentScanlineOfBand( unsigned int band ) const
{
const unsigned int atomicbytes = bits_per_sample >> 3;
- unsigned char * buf = ( unsigned char * ) stripbuffer[0];
+ UInt8 * buf = ( UInt8 * ) stripbuffer[0];
return buf + atomicbytes *
( width * samples_per_pixel * stripindex + band );
}
@@ -644,8 +699,15 @@
// write next strip
stripindex = 0;
- TIFFWriteEncodedStrip( tiff, strip++, stripbuffer[0],
+ int success = TIFFWriteEncodedStrip( tiff, strip++, stripbuffer[0],
TIFFVStripSize( tiff, rows ) );
+ if(success == -1 && tiffcomp == COMPRESSION_LZW)
+ {
+ throw Encoder::TIFFNoLZWException(); // retry without compression
+ }
+
+ vigra_postcondition(success != -1,
+ "exportImage(): Unable to write TIFF data.");
}
}
};
@@ -681,12 +743,15 @@
TIFFSetField( tiff, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG );
TIFFSetField( tiff, TIFFTAG_IMAGEWIDTH, width );
TIFFSetField( tiff, TIFFTAG_IMAGELENGTH, height );
+ //FIXME TIFFDefaultStripSize tries for 8kb strips! Laughable!
+ // This will do a 1MB strip for 8-bit images,
+ // 2MB strip for 16-bit, and so forth.
+ unsigned int estimate = std::max(1UL, static_cast<unsigned long>((1<<20) / (width * samples_per_pixel)));
TIFFSetField( tiff, TIFFTAG_ROWSPERSTRIP,
- stripheight = TIFFDefaultStripSize( tiff, 10 ) );
+ stripheight = TIFFDefaultStripSize( tiff, estimate ) );
+ TIFFSetField( tiff, TIFFTAG_SAMPLESPERPIXEL, samples_per_pixel );
TIFFSetField( tiff, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT );
-
TIFFSetField( tiff, TIFFTAG_COMPRESSION, tiffcomp );
- TIFFSetField( tiff, TIFFTAG_SAMPLESPERPIXEL, samples_per_pixel );
// subfile descriptor
TIFFSetField( tiff, TIFFTAG_SUBFILETYPE, 0);
@@ -747,17 +812,24 @@
}
// save position, if available
- if (position.x > 0 && position.y > 0 &&
+ if (position.x >= 0 && position.y >= 0 &&
x_resolution > 0 && y_resolution > 0)
{
TIFFSetField( tiff, TIFFTAG_XPOSITION, position.x / x_resolution);
TIFFSetField( tiff, TIFFTAG_YPOSITION, position.y / y_resolution);
}
+ // Set ICC profile, if available.
+ if (iccProfileLength > 0) {
+ TIFFSetField(tiff, TIFFTAG_ICCPROFILE, iccProfileLength, iccProfilePtr);
+ }
+
// alloc memory
stripbuffer = new tdata_t[1];
stripbuffer[0] = 0;
stripbuffer[0] = _TIFFmalloc( TIFFStripSize(tiff) );
+ if(stripbuffer[0] == 0)
+ throw std::bad_alloc();
finalized = true;
}
@@ -779,50 +851,50 @@
void TIFFEncoder::setWidth( unsigned int width )
{
- VIGRA_IMPEX2_FINALIZED(pimpl->finalized);
+ VIGRA_IMPEX_FINALIZED(pimpl->finalized);
pimpl->width = width;
}
void TIFFEncoder::setHeight( unsigned int height )
{
- VIGRA_IMPEX2_FINALIZED(pimpl->finalized);
+ VIGRA_IMPEX_FINALIZED(pimpl->finalized);
pimpl->height = height;
}
void TIFFEncoder::setNumBands( unsigned int bands )
{
- VIGRA_IMPEX2_FINALIZED(pimpl->finalized);
+ VIGRA_IMPEX_FINALIZED(pimpl->finalized);
pimpl->samples_per_pixel = bands;
}
void TIFFEncoder::setCompressionType( const std::string & comp,
int quality )
{
- VIGRA_IMPEX2_FINALIZED(pimpl->finalized);
+ VIGRA_IMPEX_FINALIZED(pimpl->finalized);
pimpl->setCompressionType( comp, quality );
}
void TIFFEncoder::setPixelType( const std::string & pixeltype )
{
- VIGRA_IMPEX2_FINALIZED(pimpl->finalized);
+ VIGRA_IMPEX_FINALIZED(pimpl->finalized);
pimpl->pixeltype = pixeltype;
}
void TIFFEncoder::setPosition( const vigra::Diff2D & pos )
{
- VIGRA_IMPEX2_FINALIZED(pimpl->finalized);
+ VIGRA_IMPEX_FINALIZED(pimpl->finalized);
pimpl->position = pos;
}
void TIFFEncoder::setXResolution( float xres )
{
- VIGRA_IMPEX2_FINALIZED(pimpl->finalized);
+ VIGRA_IMPEX_FINALIZED(pimpl->finalized);
pimpl->x_resolution = xres;
}
void TIFFEncoder::setYResolution( float yres )
{
- VIGRA_IMPEX2_FINALIZED(pimpl->finalized);
+ VIGRA_IMPEX_FINALIZED(pimpl->finalized);
pimpl->y_resolution = yres;
}
@@ -833,7 +905,7 @@
void TIFFEncoder::finalizeSettings()
{
- VIGRA_IMPEX2_FINALIZED(pimpl->finalized);
+ VIGRA_IMPEX_FINALIZED(pimpl->finalized);
pimpl->finalizeSettings();
}
@@ -847,6 +919,12 @@
pimpl->nextScanline();
}
+ void TIFFEncoder::setICCProfile(const UInt32 length, const unsigned char * const buf)
+ {
+ pimpl->iccProfileLength = length;
+ pimpl->iccProfilePtr = buf;
+ }
+
void TIFFEncoder::close() {}
void TIFFEncoder::abort() {}
}
Index: byteorder.hxx
===================================================================
RCS file: /cvsroot/hugin/hugin/src/foreign/vigra_impex/byteorder.hxx,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -u -d -r1.2 -r1.2.2.1
--- byteorder.hxx 20 Jan 2005 19:20:45 -0000 1.2
+++ byteorder.hxx 3 Mar 2006 00:31:48 -0000 1.2.2.1
@@ -4,30 +4,46 @@
/* Cognitive Systems Group, University of Hamburg, Germany */
/* */
/* This file is part of the VIGRA computer vision library. */
-/* ( Version 1.2.0, Aug 07 2003 ) */
-/* You may use, modify, and distribute this software according */
-/* to the terms stated in the LICENSE file included in */
-/* the VIGRA distribution. */
-/* */
+/* ( Version 1.4.0, Dec 21 2005 ) */
/* The VIGRA Website is */
/* http://kogs-www.informatik.uni-hamburg.de/~koethe/vigra/ */
/* Please direct questions, bug reports, and contributions to */
-/* koethe@... */
+/* koethe@... or */
+/* vigra@... */
/* */
-/* THIS SOFTWARE IS PROVIDED AS IS AND WITHOUT ANY EXPRESS OR */
-/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
-/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */
+/* Permission is hereby granted, free of charge, to any person */
+/* obtaining a copy of this software and associated documentation */
+/* files (the "Software"), to deal in the Software without */
+/* restriction, including without limitation the rights to use, */
+/* copy, modify, merge, publish, distribute, sublicense, and/or */
+/* sell copies of the Software, and to permit persons to whom the */
+/* Software is furnished to do so, subject to the following */
+/* conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the */
+/* Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES */
+/* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND */
+/* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT */
+/* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, */
+/* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING */
+/* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR */
+/* OTHER DEALINGS IN THE SOFTWARE. */
/* */
/************************************************************************/
-#ifndef VIGRA_BYTEORDER2_HXX
-#define VIGRA_BYTEORDER2_HXX
+#ifndef VIGRA_BYTEORDER_HXX
+#define VIGRA_BYTEORDER_HXX
#include <vector>
#include <memory>
#include <string>
#include <fstream>
#include <algorithm>
+#include "vigra/sized_int.hxx"
namespace vigra
{
@@ -63,8 +79,8 @@
void reversebytes( T & x ) const
{
const unsigned int n = sizeof(T);
- unsigned char t[n];
- unsigned char * c = reinterpret_cast< unsigned char * >(&x);
+ UInt8 t[n];
+ UInt8 * c = reinterpret_cast< UInt8 * >(&x);
unsigned int i;
for( i = 0; i < n; ++i )
t[i] = c[ n - 1 - i ];
@@ -116,20 +132,20 @@
}
void convert_to_host( char & x ) const {}
- void convert_to_host( signed char & x ) const {}
- void convert_to_host( unsigned char & x ) const {}
+ void convert_to_host( Int8 & x ) const {}
+ void convert_to_host( UInt8 & x ) const {}
void convert_to_host( char * x , unsigned int) const {}
- void convert_to_host( signed char * x, unsigned int) const {}
- void convert_to_host( unsigned char * x, unsigned int) const {}
+ void convert_to_host( Int8 * x, unsigned int) const {}
+ void convert_to_host( UInt8 * x, unsigned int) const {}
void convert_from_host( char & x ) const {}
- void convert_from_host( signed char & x ) const {}
- void convert_from_host( unsigned char & x ) const {}
+ void convert_from_host( Int8 & x ) const {}
+ void convert_from_host( UInt8 & x ) const {}
void convert_from_host( char * x , unsigned int) const {}
- void convert_from_host( signed char * x, unsigned int) const {}
- void convert_from_host( unsigned char * x, unsigned int) const {}
+ void convert_from_host( Int8 * x, unsigned int) const {}
+ void convert_from_host( UInt8 * x, unsigned int) const {}
};
template< class T >
Index: auto_file.hxx
===================================================================
RCS file: /cvsroot/hugin/hugin/src/foreign/vigra_impex/auto_file.hxx,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -u -d -r1.1 -r1.1.2.1
--- auto_file.hxx 3 Jul 2004 09:55:17 -0000 1.1
+++ auto_file.hxx 3 Mar 2006 00:31:48 -0000 1.1.2.1
@@ -4,28 +4,43 @@
/* Cognitive Systems Group, University of Hamburg, Germany */
/* */
/* This file is part of the VIGRA computer vision library. */
-/* ( Version 1.2.0, Aug 07 2003 ) */
-/* You may use, modify, and distribute this software according */
-/* to the terms stated in the LICENSE file included in */
-/* the VIGRA distribution. */
-/* */
+/* ( Version 1.4.0, Dec 21 2005 ) */
/* The VIGRA Website is */
/* http://kogs-www.informatik.uni-hamburg.de/~koethe/vigra/ */
/* Please direct questions, bug reports, and contributions to */
-/* koethe@... */
+/* koethe@... or */
+/* vigra@... */
/* */
-/* THIS SOFTWARE IS PROVIDED AS IS AND WITHOUT ANY EXPRESS OR */
-/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
-/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */
+/* Permission is hereby granted, free of charge, to any person */
+/* obtaining a copy of this software and associated documentation */
+/* files (the "Software"), to deal in the Software without */
+/* restriction, including without limitation the rights to use, */
+/* copy, modify, merge, publish, distribute, sublicense, and/or */
+/* sell copies of the Software, and to permit persons to whom the */
+/* Software is furnished to do so, subject to the following */
+/* conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the */
+/* Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES */
+/* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND */
+/* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT */
+/* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, */
+/* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING */
+/* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR */
+/* OTHER DEALINGS IN THE SOFTWARE. */
/* */
/************************************************************************/
-#ifndef VIGRA_IMPEX2_AUTO_FILE_HXX
-#define VIGRA_IMPEX2_AUTO_FILE_HXX
+#ifndef VIGRA_IMPEX_AUTO_FILE_HXX
+#define VIGRA_IMPEX_AUTO_FILE_HXX
#include <string>
#include <cstdio>
-#include "error.hxx"
+#include "vigra/error.hxx"
namespace vigra
{
Index: imageinfo.cxx
===================================================================
RCS file: /cvsroot/hugin/hugin/src/foreign/vigra_impex/imageinfo.cxx,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -u -d -r1.3 -r1.3.2.1
--- imageinfo.cxx 20 Jan 2005 19:20:45 -0000 1.3
+++ imageinfo.cxx 3 Mar 2006 00:31:48 -0000 1.3.2.1
@@ -4,23 +4,47 @@
/* Cognitive Systems Group, University of Hamburg, Germany */
/* */
/* This file is part of the VIGRA computer vision library. */
-/* ( Version 1.2.0, Aug 07 2003 ) */
-/* You may use, modify, and distribute this software according */
-/* to the terms stated in the LICENSE file included in */
-/* the VIGRA distribution. */
-/* */
+/* ( Version 1.4.0, Dec 21 2005 ) */
/* The VIGRA Website is */
/* http://kogs-www.informatik.uni-hamburg.de/~koethe/vigra/ */
/* Please direct questions, bug reports, and contributions to */
-/* koethe@... */
+/* koethe@... or */
+/* vigra@... */
/* */
-/* THIS SOFTWARE IS PROVIDED AS IS AND WITHOUT ANY EXPRESS OR */
-/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
-/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */
+/* Permission is hereby granted, free of charge, to any person */
+/* obtaining a copy of this software and associated documentation */
+/* files (the "Software"), to deal in the Software without */
+/* restriction, including without limitation the rights to use, */
+/* copy, modify, merge, publish, distribute, sublicense, and/or */
+/* sell copies of the Software, and to permit persons to whom the */
+/* Software is furnished to do so, subject to the following */
+/* conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the */
+/* Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES */
+/* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND */
+/* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT */
+/* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, */
+/* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING */
+/* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR */
+/* OTHER DEALINGS IN THE SOFTWARE. */
/* */
/************************************************************************/
+/* Modifications by Pablo d'Angelo
+ * updated to vigra 1.4 by Douglas Wilkins
+ * as of 18 Febuary 2006:
+ * - Added UINT16 and UINT32 pixel types.
+ * - Added support for obtaining extra bands beyond RGB.
+ * - Added support for a position field that indicates the start of this
+ * image relative to some global origin.
+ * - Added support for x and y resolution fields.
+ * - Added support for ICC profiles
+ */
-#include <config.h>
#include <iostream>
#include <algorithm>
#include <iterator>
@@ -37,7 +61,7 @@
#include "codecmanager.hxx"
#if defined(_WIN32)
-# include <windows.h>
+# include "vigra/windows.h"
#else
# include <dirent.h>
#endif
@@ -72,7 +96,10 @@
WIN32_FIND_DATA FileData;
std::string base, path;
- int split = name_base.rfind('/');
+
+ // on Windows, both '/' and '\' are valid path separators
+ // note: std::basic_string.rfind() may return unsigned int, so exlicitely use std::max<int>()
+ size_t split = std::max<int>(name_base.rfind('/'), name_base.rfind('\\'));
if(split == -1)
{
path = ".";
@@ -80,7 +107,7 @@
}
else
{
- for(int i=0; i<split; ++i)
+ for(size_t i=0; i<split; ++i)
{
if(name_base[i] == '/')
path += '\\';
@@ -247,9 +274,15 @@
ImageExportInfo::ImageExportInfo( const char * filename )
: m_filename(filename),
- m_x_res(0), m_y_res(0)
+ m_x_res(0), m_y_res(0),
+ m_profile_length(0), m_profile_ptr(NULL)
{}
+ImageExportInfo::~ImageExportInfo()
+{
+ delete[] m_profile_ptr;
+}
+
ImageExportInfo & ImageExportInfo::setFileType( const char * filetype )
{
m_filetype = filetype;
@@ -321,6 +354,25 @@
return m_pos;
}
+UInt32 ImageExportInfo::getICCProfileLength() const
+{
+ return m_profile_length;
+}
+
+const unsigned char *ImageExportInfo::getICCProfile() const
+{
+ return m_profile_ptr;
+}
+
+void ImageExportInfo::setICCProfile(const UInt32 length, const unsigned char * const buf)
+{
+ // Delete existing profile.
+ delete[] m_profile_ptr;
+ m_profile_length = length;
+ m_profile_ptr = new unsigned char[m_profile_length];
+ VIGRA_CSTD::memcpy(m_profile_ptr, buf, m_profile_length);
+}
+
// return an encoder for a given ImageExportInfo object
std::auto_ptr<Encoder> encoder( const ImageExportInfo & info )
{
@@ -356,6 +408,13 @@
std::string pixel_type = info.getPixelType();
if ( pixel_type != "" ) {
+ if(!isPixelTypeSupported( enc->getFileType(), pixel_type ))
+ {
+ std::string msg("exportImage(): file type ");
+ msg += enc->getFileType() + " does not support requested pixel type "
+ + pixel_type + ".";
+ vigra_precondition(false, msg.c_str());
+ }
enc->setPixelType(pixel_type);
}
@@ -364,6 +423,11 @@
enc->setYResolution(info.getYResolution());
enc->setPosition(info.getPosition());
+ if (info.getICCProfileLength() > 0) {
+ enc->setICCProfile(info.getICCProfileLength(),
+ info.getICCProfile());
+ }
+
return enc;
}
@@ -382,9 +446,22 @@
m_num_extra_bands = decoder->getNumExtraBands();
m_pos = decoder->getPosition();
+ m_profile_length = decoder->getICCProfileLength();
+ if (m_profile_length > 0) {
+ m_profile_ptr = new unsigned char[m_profile_length];
+ VIGRA_CSTD::memcpy(m_profile_ptr, decoder->getICCProfile(), m_profile_length);
+ }
+ else {
+ m_profile_ptr = NULL;
+ }
+
decoder->abort(); // there probably is no better way than this
}
+ImageImportInfo::~ImageImportInfo() {
+ delete[] m_profile_ptr;
+}
+
const char * ImageImportInfo::getFileName() const
{
return m_filename.c_str();
@@ -437,9 +514,9 @@
return m_num_extra_bands;
}
-vigra::Size2D ImageImportInfo::size() const
+Size2D ImageImportInfo::size() const
{
- return vigra::Size2D( m_width, m_height );
+ return Size2D( m_width, m_height );
}
bool ImageImportInfo::isGrayscale() const
@@ -449,7 +526,7 @@
bool ImageImportInfo::isColor() const
{
- return m_num_bands == 3;
+ return (m_num_bands - m_num_extra_bands) == 3;
}
bool ImageImportInfo::isByte() const
@@ -457,7 +534,7 @@
return m_pixeltype == "UINT8";
}
-vigra::Diff2D ImageImportInfo::getPosition() const
+Diff2D ImageImportInfo::getPosition() const
{
return m_pos;
}
@@ -472,6 +549,16 @@
return m_y_res;
}
+UInt32 ImageImportInfo::getICCProfileLength() const
+{
+ return m_profile_length;
+}
+
+const unsigned char *ImageImportInfo::getICCProfile() const
+{
+ return m_profile_ptr;
+}
+
// return a decoder for a given ImageImportInfo object
std::auto_ptr<Decoder> decoder( const ImageImportInfo & info )
{
Index: codecmanager.cxx
===================================================================
RCS file: /cvsroot/hugin/hugin/src/foreign/vigra_impex/codecmanager.cxx,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -u -d -r1.2 -r1.2.2.1
--- codecmanager.cxx 27 Oct 2004 18:12:51 -0000 1.2
+++ codecmanager.cxx 3 Mar 2006 00:31:48 -0000 1.2.2.1
@@ -4,26 +4,41 @@
/* Cognitive Systems Group, University of Hamburg, Germany */
/* */
/* This file is part of the VIGRA computer vision library. */
-/* ( Version 1.2.0, Aug 07 2003 ) */
-/* You may use, modify, and distribute this software according */
-/* to the terms stated in the LICENSE file included in */
-/* the VIGRA distribution. */
-/* */
+/* ( Version 1.4.0, Dec 21 2005 ) */
/* The VIGRA Website is */
/* http://kogs-www.informatik.uni-hamburg.de/~koethe/vigra/ */
/* Please direct questions, bug reports, and contributions to */
-/* koethe@... */
+/* koethe@... or */
+/* vigra@... */
/* */
-/* THIS SOFTWARE IS PROVIDED AS IS AND WITHOUT ANY EXPRESS OR */
-/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
-/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */
+/* Permission is hereby granted, free of charge, to any person */
+/* obtaining a copy of this software and associated documentation */
+/* files (the "Software"), to deal in the Software without */
+/* restriction, including without limitation the rights to use, */
+/* copy, modify, merge, publish, distribute, sublicense, and/or */
+/* sell copies of the Software, and to permit persons to whom the */
+/* Software is furnished to do so, subject to the following */
+/* conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the */
+/* Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES */
+/* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND */
+/* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT */
+/* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, */
+/* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING */
+/* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR */
+/* OTHER DEALINGS IN THE SOFTWARE. */
/* */
/************************************************************************/
-#include <config.h>
#include <fstream>
#include <algorithm>
#include <cctype> // std::tolower
+#include "vigra/config.hxx"
#include "vigra/error.hxx"
#include "codecmanager.hxx"
@@ -37,8 +52,6 @@
#include "bmp.hxx"
#include "gif.hxx"
-using namespace vigra;
-
namespace vigra
{
// singleton pattern
@@ -66,6 +79,19 @@
import( new GIFCodecFactory() );
}
+ CodecManager::~CodecManager() {
+ // release previously allocated codecs
+ // (use erase ideom similar to
+ // S. Meyers' "Effective STL", Item 9)
+ for (std::map< std::string, CodecFactory * >::iterator i
+ = factoryMap.begin();
+ i != factoryMap.end();
+ /* nothing */ ) {
+ delete (*i).second;
+ factoryMap.erase(i++);
+ }
+ }
+
// add an encoder to the stores
void CodecManager::import( CodecFactory * cf )
{
@@ -97,6 +123,18 @@
return result->second->getCodecDesc().pixelTypes;
}
+ // find out which pixel types a given codec supports
+ std::vector<int>
+ CodecManager::queryCodecBandNumbers( const std::string & filetype ) const
+ {
+ std::map< std::string, CodecFactory * >::const_iterator result
+ = factoryMap.find( filetype );
+ vigra_precondition( result != factoryMap.end(),
+ "the codec that was queried for its pixeltype does not exist" );
+
+ return result->second->getCodecDesc().bandNumbers;
+ }
+
// find out if a given file type is supported
bool CodecManager::fileTypeSupported( const std::string & fileType )
{
@@ -143,7 +181,7 @@
// get the magic string
const unsigned int magiclen = 4;
char fmagic[magiclen];
-#ifdef WIN32
+#ifdef VIGRA_NEED_BIN_STREAMS
std::ifstream stream(filename.c_str(), std::ios::binary);
#else
std::ifstream stream(filename.c_str());
@@ -256,6 +294,51 @@
return codecManager().queryCodecPixelTypes(codecname);
}
+
+ // return true if downcasting is required, false otherwise
+ bool negotiatePixelType( std::string const & codecname,
+ std::string const & srcPixeltype, std::string & destPixeltype )
+ {
+ std::vector<std::string> ptypes
+ = codecManager().queryCodecPixelTypes(codecname);
+
+ std::vector<std::string>::iterator pend;
+ if(destPixeltype != "")
+ {
+ pend = std::find(ptypes.begin(), ptypes.end(), destPixeltype);
+ if(pend == ptypes.end())
+ {
+ std::string msg("exportImage(): file type ");
+ msg += codecname + " does not support requested pixel type "
+ + destPixeltype + ".";
+ vigra_precondition(false, msg.c_str());
+ }
+ ++pend;
+ }
+ else
+ {
+ pend = ptypes.end();
+ }
+
+ std::vector<std::string>::const_iterator result
+ = std::find( ptypes.begin(), pend, srcPixeltype );
+
+ if( result == pend)
+ {
+ if(destPixeltype == "")
+ destPixeltype = "UINT8";
+ // must always downcast
+ return true;
+ }
+ else
+ {
+ if(destPixeltype == "")
+ destPixeltype = srcPixeltype;
+ // don't downcast
+ return false;
+ }
+ }
+
bool isPixelTypeSupported( const std::string & codecname,
const std::string & pixeltype )
{
@@ -266,4 +349,16 @@
return ( result != ptypes.end() );
}
+ bool isBandNumberSupported( const std::string & codecname,
+ int bands )
+ {
+ std::vector<int> bandNumbers
+ = codecManager().queryCodecBandNumbers(codecname);
+ if(bandNumbers[0] == 0)
+ return true; // any band number supported
+ std::vector<int>::const_iterator result
+ = std::find( bandNumbers.begin(), bandNumbers.end(), bands );
+ return ( result != bandNumbers.end() );
+ }
+
} // namespace vigra
Index: gif.hxx
===================================================================
RCS file: /cvsroot/hugin/hugin/src/foreign/vigra_impex/gif.hxx,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -u -d -r1.1 -r1.1.2.1
--- gif.hxx 3 Jul 2004 09:55:16 -0000 1.1
+++ gif.hxx 3 Mar 2006 00:31:48 -0000 1.1.2.1
@@ -4,24 +4,39 @@
/* Cognitive Systems Group, University of Hamburg, Germany */
/* */
/* This file is part of the VIGRA computer vision library. */
-/* ( Version 1.2.0, Aug 07 2003 ) */
-/* You may use, modify, and distribute this software according */
-/* to the terms stated in the LICENSE file included in */
-/* the VIGRA distribution. */
-/* */
+/* ( Version 1.4.0, Dec 21 2005 ) */
/* The VIGRA Website is */
/* http://kogs-www.informatik.uni-hamburg.de/~koethe/vigra/ */
/* Please direct questions, bug reports, and contributions to */
-/* koethe@... */
+/* koethe@... or */
+/* vigra@... */
/* */
-/* THIS SOFTWARE IS PROVIDED AS IS AND WITHOUT ANY EXPRESS OR */
-/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
-/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */
+/* Permission is hereby granted, free of charge, to any person */
+/* obtaining a copy of this software and associated documentation */
+/* files (the "Software"), to deal in the Software without */
+/* restriction, including without limitation the rights to use, */
+/* copy, modify, merge, publish, distribute, sublicense, and/or */
+/* sell copies of the Software, and to permit persons to whom the */
+/* Software is furnished to do so, subject to the following */
+/* conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the */
+/* Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES */
+/* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND */
+/* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT */
+/* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, */
+/* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING */
+/* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR */
+/* OTHER DEALINGS IN THE SOFTWARE. */
/* */
/************************************************************************/
-#ifndef VIGRA_IMPEX2_GIF_HXX
-#define VIGRA_IMPEX2_GIF_HXX
+#ifndef VIGRA_IMPEX_GIF_HXX
+#define VIGRA_IMPEX_GIF_HXX
#include "vigra/codec.hxx"
Index: void_vector.hxx
===================================================================
RCS file: /cvsroot/hugin/hugin/src/foreign/vigra_impex/void_vector.hxx,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -u -d -r1.2 -r1.2.2.1
--- void_vector.hxx 20 Jan 2005 19:20:45 -0000 1.2
+++ void_vector.hxx 3 Mar 2006 00:31:48 -0000 1.2.2.1
@@ -4,22 +4,38 @@
/* Cognitive Systems Group, University of Hamburg, Germany */
/* */
/* This file is part of the VIGRA computer vision library. */
-/* ( Version 1.2.0, Aug 07 2003 ) */
-/* You may use, modify, and distribute this software according */
-/* to the terms stated in the LICENSE file included in */
-/* the VIGRA distribution. */
-/* */
+/* ( Version 1.4.0, Dec 21 2005 ) */
/* The VIGRA Website is */
/* http://kogs-www.informatik.uni-hamburg.de/~koethe/vigra/ */
/* Please direct questions, bug reports, and contributions to */
-/* koethe@... */
+/* koethe@... or */
+/* vigra@... */
/* */
-/* THIS SOFTWARE IS PROVIDED AS IS AND WITHOUT ANY EXPRESS OR */
-/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
-/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */
+/* Permission is hereby granted, free of charge, to any person */
+/* obtaining a copy of this software and associated documentation */
+/* files (the "Software"), to deal in the Software without */
+/* restriction, including without limitation the rights to use, */
+/* copy, modify, merge, publish, distribute, sublicense, and/or */
+/* sell copies of the Software, and to permit persons to whom the */
+/* Software is furnished to do so, subject to the following */
+/* conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the */
+/* Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES */
+/* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND */
+/* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT */
+/* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, */
+/* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING */
+/* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR */
+/* OTHER DEALINGS IN THE SOFTWARE. */
/* */
/************************************************************************/
+
#ifndef VIGRA_IMPEX_VOIDVECTOR
#define VIGRA_IMPEX_VOIDVECTOR
Index: pnm.cxx
===================================================================
RCS file: /cvsroot/hugin/hugin/src/foreign/vigra_impex/pnm.cxx,v
retrieving revision 1.4
retrieving revision 1.4.2.1
diff -u -d -r1.4 -r1.4.2.1
--- pnm.cxx 12 Dec 2005 18:34:14 -0000 1.4
+++ pnm.cxx 3 Mar 2006 00:31:48 -0000 1.4.2.1
@@ -1,29 +1,45 @@
/************************************************************************/
/* */
-/* Copyright 2002 by Gunnar Kedenburg */
+/* Copyright 2002-2004 by Gunnar Kedenburg */
/* Cognitive Systems Group, University of Hamburg, Germany */
/* */
/* This file is part of the VIGRA computer vision library. */
-/* ( Version 1.2.0, Aug 07 2003 ) */
-/* You may use, modify, and distribute this software according */
-/* to the terms stated in the LICENSE file included in */
-/* the VIGRA distribution. */
-/* */
+/* ( Version 1.4.0, Dec 21 2005 ) */
/* The VIGRA Website is */
/* http://kogs-www.informatik.uni-hamburg.de/~koethe/vigra/ */
/* Please direct questions, bug reports, and contributions to */
-/* koethe@... */
+/* koethe@... or */
+/* vigra@... */
/* */
-/* THIS SOFTWARE IS PROVIDED AS IS AND WITHOUT ANY EXPRESS OR */
-/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
-/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */
+/* Permission is hereby granted, free of charge, to any person */
+/* obtaining a copy of this software and associated documentation */
+/* files (the "Software"), to deal in the Software without */
+/* restriction, including without limitation the rights to use, */
+/* copy, modify, merge, publish, distribute, sublicense, and/or */
+/* sell copies of the Software, and to permit persons to whom the */
+/* Software is furnished to do so, subject to the following */
+/* conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the */
+/* Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES */
+/* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND */
+/* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT */
+/* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, */
+/* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING */
+/* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR */
+/* OTHER DEALINGS IN THE SOFTWARE. */
/* */
/************************************************************************/
-#include <config.h>
#include <cmath>
#include <iostream>
#include <fstream>
+#include "vigra/config.hxx"
+#include "vigra/sized_int.hxx"
#include "error.hxx"
#include "void_vector.hxx"
#include "pnm.hxx"
@@ -31,9 +47,6 @@
namespace vigra {
- typedef unsigned short uint16_t;
- typedef unsigned int uint32_t;
-
CodecDesc PnmCodecFactory::getCodecDesc() const
{
CodecDesc desc;
@@ -81,6 +94,10 @@
desc.fileExtensions[2] = "pgm";
desc.fileExtensions[3] = "ppm";
+ desc.bandNumbers.resize(2);
+ desc.bandNumbers[0] = 1;
+ desc.bandNumbers[1] = 3;
+
return desc;
}
@@ -155,7 +172,7 @@
void PnmDecoderImpl::read_bilevel_ascii_scanline()
{
// cast the bands to the correct type
- typedef void_vector< unsigned char > vector_type;
+ typedef void_vector< UInt8 > vector_type;
vector_type & cbands = static_cast< vector_type & >(bands);
// read and store
@@ -170,7 +187,7 @@
// XXX implement this also for other pixel types than unsigned char
// cast the bands to the correct type
- typedef void_vector< unsigned char > vector_type;
+ typedef void_vector< UInt8 > vector_type;
vector_type & cbands = static_cast< vector_type & >(bands);
// read and store
@@ -185,11 +202,11 @@
void PnmDecoderImpl::read_bilevel_raw_scanline()
{
// cast the bands to the correct type
- typedef void_vector< unsigned char > vector_type;
+ typedef void_vector< UInt8 > vector_type;
vector_type & cbands = static_cast< vector_type & >(bands);
// read and store
- unsigned char buf = 0;
+ UInt8 buf = 0;
const unsigned int size = width / 8; // XXX wrong assumption
for( unsigned int i = 0; i < size; ++i ) {
stream.read( reinterpret_cast< char * >(&buf), 1 );
@@ -213,10 +230,8 @@
void PnmDecoderImpl::read_raw_scanline_uchar()
{
- // XXX implement this also for other pixel types than unsigned char
-
// cast the bands to the correct type
- typedef void_vector< unsigned char > vector_type;
+ typedef void_vector< UInt8 > vector_type;
vector_type & cbands = reinterpret_cast< vector_type & >(bands);
// read and store
@@ -226,51 +241,30 @@
void PnmDecoderImpl::read_raw_scanline_ushort()
{
- // XXX implement this also for other pixel types than unsigned char
-
// cast the bands to the correct type
- typedef void_vector< unsigned short > vector_type;
+ typedef void_vector< UInt16 > vector_type;
vector_type & cbands = reinterpret_cast< vector_type & >(bands);
// read and store, need to swap bytes.
byteorder bo( "big endian" );
- read_array( stream, bo, reinterpret_cast< uint16_t * >(cbands.data()),
+ read_array( stream, bo, reinterpret_cast< UInt16 * >(cbands.data()),
width * components );
- /*
- uint16_t * ptr = reinterpret_cast< uint16_t * >(cbands.data());
- uint16_t tmp;
- for (int i=0; i < width * components; i++) {
- stream.read(reinterpret_cast< char * >(&tmp), 2);
- *ptr = ntohs(tmp);
- ptr++;
- }
-*/
-// stream.read( reinterpret_cast< char * >(cbands.data()),
-// width * components * 2 );
}
void PnmDecoderImpl::read_raw_scanline_uint()
{
- // XXX implement this also for other pixel types than unsigned char
-
// cast the bands to the correct type
- typedef void_vector< unsigned int > vector_type;
+ typedef void_vector< UInt32 > vector_type;
vector_type & cbands = reinterpret_cast< vector_type & >(bands);
-
byteorder bo( "big endian" );
- read_array( stream, bo, reinterpret_cast< uint32_t * >(cbands.data()),
+ read_array( stream, bo, reinterpret_cast< UInt32 * >(cbands.data()),
width * components );
-
- // read and store
-// stream.read( reinterpret_cast< char * >(cbands.data()),
-// width * components * 4 );
}
-
// reads the header.
PnmDecoderImpl::PnmDecoderImpl( const std::string & filename )
-#ifdef WIN32
+#ifdef VIGRA_NEED_BIN_STREAMS
: stream( filename.c_str(), std::ios::binary )
#else
: stream( filename.c_str() )
@@ -343,7 +337,6 @@
stream >> height;
// bitmaps implicitly have maxval 1
-
if ( type != '1' && type != '4' ) {
skip();
stream >> maxval;
@@ -384,7 +377,27 @@
#endif
// advance to the beginning of the "data section"
+ if (raw == false)
skip();
+ else
+ {
+#if defined(__GNUC__) && __GNUC__ == 2
+ typedef streamoff streamOffset;
+#else
+ typedef std::ifstream::off_type streamOffset;
+#endif
+ {
+ UInt32 seekOffset = width * height * components;
+ if ( pixeltype == "UINT8" )
+ seekOffset *= 1;
+ else if ( pixeltype == "UINT16" )
+ seekOffset *= 2;
+ else if ( pixeltype == "UINT32" )
+ seekOffset *= 4;
+
+ stream.seekg( -static_cast<streamOffset>(seekOffset), std::ios::end );
+ }
+ }
}
void PnmDecoder::init( const std::string & filename )
@@ -430,17 +443,17 @@
const void * PnmDecoder::currentScanlineOfBand( unsigned int band ) const
{
if ( pimpl->pixeltype == "UINT8" ) {
- typedef void_vector< unsigned char > bands_type;
+ typedef void_vector< UInt8 > bands_type;
const bands_type & bands
= static_cast< const bands_type & >(pimpl->bands);
return bands.data() + band;
} else if ( pimpl->pixeltype == "UINT16" ) {
- typedef void_vector<uint16_t> bands_type;
+ typedef void_vector<UInt16> bands_type;
const bands_type & bands
= static_cast< const bands_type & >(pimpl->bands);
return bands.data() + band;
} else if ( pimpl->pixeltype == "UINT32" ) {
- typedef void_vector<uint32_t> bands_type;
+ typedef void_vector<UInt32> bands_type;
const bands_type & bands
= static_cast< const bands_type & >(pimpl->bands);
return bands.data() + band;
@@ -501,7 +514,7 @@
};
PnmEncoderImpl::PnmEncoderImpl( const std::string & filename )
-#ifdef WIN32
+#ifdef VIGRA_NEED_BIN_STREAMS
: stream( filename.c_str(), std::ios::binary ),
#else
: stream( filename.c_str() ),
@@ -534,26 +547,26 @@
void PnmEncoder::setWidth( unsigned int width )
{
- VIGRA_IMPEX2_FINALIZED(pimpl->finalized);
+ VIGRA_IMPEX_FINALIZED(pimpl->finalized);
pimpl->width = width;
}
void PnmEncoder::setHeight( unsigned int height )
{
- VIGRA_IMPEX2_FINALIZED(pimpl->finalized);
+ VIGRA_IMPEX_FINALIZED(pimpl->finalized);
pimpl->height = height;
}
void PnmEncoder::setNumBands( unsigned int bands )
{
- VIGRA_IMPEX2_FINALIZED(pimpl->finalized);
+ VIGRA_IMPEX_FINALIZED(pimpl->finalized);
pimpl->components = bands;
}
void PnmEncoder::setCompressionType( const std::string & comp,
int quality )
{
- VIGRA_IMPEX2_FINALIZED(pimpl->finalized);
+ VIGRA_IMPEX_FINALIZED(pimpl->finalized);
if ( comp == "ASCII" )
pimpl->raw = false;
else if ( comp == "RAW" )
@@ -564,7 +577,7 @@
void PnmEncoder::setPixelType( const std::string & pixelType )
{
- VIGRA_IMPEX2_FINALIZED(pimpl->finalized);
+ VIGRA_IMPEX_FINALIZED(pimpl->finalized);
pimpl->pixeltype = pixelType;
}
@@ -575,10 +588,10 @@
void PnmEncoder::finalizeSettings()
{
- VIGRA_IMPEX2_FINALIZED(pimpl->finalized);
+ VIGRA_IMPEX_FINALIZED(pimpl->finalized);
pimpl->finalized = true;
- if ( pimpl->pixeltype == "UINT32" )
+ if ( pimpl->pixeltype == "INT32" )
pimpl->raw = false;
// write magic number
@@ -620,17 +633,17 @@
{
const unsigned int row_stride = pimpl->width * pimpl->components;
if ( pimpl->pixeltype == "UINT8" ) {
- typedef void_vector< unsigned char > bands_type;
+ typedef void_vector< UInt8 > bands_type;
bands_type & bands
= static_cast< bands_type & >(pimpl->bands);
return bands.data() + pimpl->scanline * row_stride + band;
} else if ( pimpl->pixeltype == "UINT16" ) {
- typedef void_vector<uint16_t> bands_type;
+ typedef void_vector<UInt16> bands_type;
bands_type & bands
= static_cast< bands_type & >(pimpl->bands);
return bands.data() + pimpl->scanline * row_stride + band;
} else if ( pimpl->pixeltype == "UINT32" ) {
- typedef void_vector<uint32_t> bands_type;
+ typedef void_vector<UInt32> bands_type;
bands_type & bands
= static_cast< bands_type & >(pimpl->bands);
return bands.data() + pimpl->scanline * row_stride + band;
@@ -642,11 +655,11 @@
void PnmEncoderImpl::write_bilevel_ascii()
{
// cast the bands to the correct type
- typedef void_vector< unsigned char > vector_type;
+ typedef void_vector< UInt8 > vector_type;
vector_type & cbands = static_cast< vector_type & >(bands);
// write and store
- unsigned char * iter = cbands.data();
+ UInt8 * iter = cbands.data();
for( unsigned int i = 0; i < height; ++i ) {
for ( unsigned int j = 0; j < width; ++j ) {
for ( unsigned int k = 0; k < components; ++k ) {
@@ -664,9 +677,9 @@
{
if ( pixeltype == "UINT8" ) {
- typedef void_vector< unsigned char > vector_type;
+ typedef void_vector< UInt8 > vector_type;
vector_type & cbands = static_cast< vector_type & >(bands);
- unsigned char * iter = cbands.data();
+ UInt8 * iter = cbands.data();
for( unsigned int i = 0; i < height; ++i ) {
for ( unsigned int j = 0; j < width; ++j ) {
for ( unsigned int k = 0; k < components; ++k ) {
@@ -681,9 +694,9 @@
} else if ( pixeltype == "UINT16" ) {
- typedef void_vector<uint16_t> vector_type;
+ typedef void_vector<UInt16> vector_type;
vector_type & cbands = static_cast< vector_type & >(bands);
- uint16_t * iter = cbands.data();
+ UInt16 * iter = cbands.data();
for( unsigned int i = 0; i < height; ++i ) {
for ( unsigned int j = 0; j < width; ++j ) {
for ( unsigned int k = 0; k < components; ++k ) {
@@ -698,9 +711,9 @@
} else if ( pixeltype == "UINT32" ) {
- typedef void_vector<uint32_t> vector_type;
+ typedef void_vector<UInt32> vector_type;
vector_type & cbands = static_cast< vector_type & >(bands);
- uint32_t * iter = cbands.data();
+ UInt32 * iter = cbands.data();
for( unsigned int i = 0; i < height; ++i ) {
for ( unsigned int j = 0; j < width; ++j ) {
for ( unsigned int k = 0; k < components; ++k ) {
@@ -716,7 +729,7 @@
}
// cast the bands to the correct type
- typedef void_vector< unsigned char > vector_type;
+ typedef void_vector< UInt8 > vector_type;
vector_type & cbands = static_cast< vector_type & >(bands);
// write and store
@@ -730,7 +743,7 @@
void PnmEncoderImpl::write_bilevel_raw()
{
// cast the bands to the correct type
- typedef void_vector< unsigned char > vector_type;
+ typedef void_vector< UInt8 > vector_type;
//vector_type & cbands = static_cast< vector_type & >(bands);
// XXX
@@ -741,7 +754,7 @@
if ( pixeltype == "UINT8" ) {
// cast the bands to the correct type
- typedef void_vector< unsigned char > vector_type;
+ typedef void_vector< UInt8 > vector_type;
vector_type & cbands = static_cast< vector_type & >(bands);
// write and store
@@ -751,7 +764,7 @@
} else if ( pixeltype == "UINT16" ) {
// cast the bands to the correct type
- typedef void_vector<uint16_t> vector_type;
+ typedef void_vector<UInt16> vector_type;
vector_type & cbands = static_cast< vector_type & >(bands);
// write and store
@@ -776,16 +789,22 @@
// find out maxval and print it into the stream
int maxval = 0;
if ( pimpl->pixeltype == "UINT8" ) {
- void_vector< unsigned char > & cbands
- = static_cast< void_vector< unsigned char > & >
+ void_vector< UInt8 > & cbands
+ = static_cast< void_vector< UInt8 > & >
(pimpl->bands);
- for( unsigned char * iter = cbands.begin();
+ for( UInt8 * iter = cbands.begin();
iter < cbands.end(); ++iter )
if ( *iter > maxval ) maxval = *iter;
} else if ( pimpl->pixeltype == "UINT16" ) {
- void_vector<uint16_t> & cbands
- = static_cast< void_vector<uint16_t> & >(pimpl->bands);
- for( uint16_t * iter = cbands.begin();
+ void_vector<UInt16> & cbands
+ = static_cast< void_vector<UInt16> & >(pimpl->bands);
+ for( UInt16 * iter = cbands.begin();
+ iter < cbands.end(); ++iter )
+ if ( *iter > maxval ) maxval = *iter;
+ } else if ( pimpl->pixeltype == "UINT32" ) {
+ void_vector<UInt32> & cbands
+ = static_cast< void_vector<UInt32> & >(pimpl->bands);
+ for( UInt32 * iter = cbands.begin();
iter < cbands.end(); ++iter )
if ( *iter > maxval ) maxval = *iter;
}
Index: png.hxx
===================================================================
RCS file: /cvsroot/hugin/hugin/src/foreign/vigra_impex/png.hxx,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -u -d -r1.1 -r1.1.2.1
--- png.hxx 3 Jul 2004 09:55:16 -0000 1.1
+++ png.hxx 3 Mar 2006 00:31:48 -0000 1.1.2.1
@@ -4,24 +4,48 @@
/* Cognitive Systems Group, University of Hamburg, Germany */
/* */
/* This file is part of the VIGRA computer vision library. */
-/* ( Version 1.2.0, Aug 07 2003 ) */
-/* You may use, modify, and distribute this software according */
-/* to the terms stated in the LICENSE file included in */
-/* the VIGRA distribution. */
-/* */
+/* ( Version 1.4.0, Dec 21 2005 ) */
/* The VIGRA Website is */
/* http://kogs-www.informatik.uni-hamburg.de/~koethe/vigra/ */
/* Please direct questions, bug reports, and contributions to */
-/* koethe@... */
+/* koethe@... or */
+/* vigra@... */
/* */
-/* THIS SOFTWARE IS PROVIDED AS IS AND WITHOUT ANY EXPRESS OR */
-/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
-/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */
+/* Permission is hereby granted, free of charge, to any person */
+/* obtaining a copy of this software and associated documentation */
+/* files (the "Software"), to deal in the Software without */
+/* restriction, including without limitation the rights to use, */
+/* copy, modify, merge, publish, distribute, sublicense, and/or */
+/* sell copies of the Software, and to permit persons to whom the */
+/* Software is furnished to do so, subject to the following */
+/* conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the */
+/* Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES */
+/* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND */
+/* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT */
+/* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, */
+/* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING */
+/* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR */
+/* OTHER DEALINGS IN THE SOFTWARE. */
/* */
/************************************************************************/
+/* Modifications by Pablo d'Angelo
+ * updated to vigra 1.4 by Douglas Wilkins
+ * as of 18 Febuary 2006:
+ * - Added UINT16 pixel types.
+ * - Added support for obtaining extra bands beyond RGB.
+ * - Added support for a position field that indicates the start of this
+ * image relative to some global origin.
+ * - Added support for x and y resolution fields.
+ */
-#ifndef VIGRA_IMPEX2_PNG_HXX
-#define VIGRA_IMPEX2_PNG_HXX
+#ifndef VIGRA_IMPEX_PNG_HXX
+#define VIGRA_IMPEX_PNG_HXX
#include "vigra/codec.hxx"
@@ -62,7 +86,7 @@
unsigned int getNumExtraBands() const;
float getXResolution() const;
float getYResolution() const;
- vigra::Diff2D getPosition() const;
+ Diff2D getPosition() const;
unsigned int getOffset() const;
@@ -93,7 +117,7 @@
void setCompressionType( const std::string &, int = -1 );
void setPixelType( const std::string & );
- void setPosition( const vigra::Diff2D & pos );
+ void setPosition( const Diff2D & pos );
void setXResolution( float xres );
void setYResolution( float yres );
Index: sun.hxx
===================================================================
RCS file: /cvsroot/hugin/hugin/src/foreign/vigra_impex/sun.hxx,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -u -d -r1.1 -r1.1.2.1
--- sun.hxx 3 Jul 2004 09:55:16 -0000 1.1
+++ sun.hxx 3 Mar 2006 00:31:48 -0000 1.1.2.1
@@ -4,24 +4,39 @@
/* Cognitive Systems Group, University of Hamburg, Germany */
/* */
/* This file is part of the VIGRA computer vision library. */
-/* ( Version 1.2.0, Aug 07 2003 ) */
-/* You may use, modify, and distribute this software according */
-/* to the terms stated in the LICENSE file included in */
-/* the VIGRA distribution. */
-/* */
+/* ( Version 1.4.0, Dec 21 2005 ) */
/* The VIGRA Website is */
/* http://kogs-www.informatik.uni-hamburg.de/~koethe/vigra/ */
/* Please direct questions, bug reports, and contributions to */
-/* koethe@... */
+/* koethe@... or */
+/* vigra@... */
/* */
-/* THIS SOFTWARE IS PROVIDED AS IS AND WITHOUT ANY EXPRESS OR */
-/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
-/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */
+/* Permission is hereby granted, free of charge, to any person */
+/* obtaining a copy of this software and associated documentation */
+/* files (the "Software"), to deal in the Software without */
+/* restriction, including without limitation the rights to use, */
+/* copy, modify, merge, publish, distribute, sublicense, and/or */
+/* sell copies of the Software, and to permit persons to whom the */
+/* Software is furnished to do so, subject to the following */
+/* conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the */
+/* Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES */
+/* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND */
+/* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT */
+/* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, */
+/* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING */
+/* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR */
+/* OTHER DEALINGS IN THE SOFTWARE. */
/* */
/************************************************************************/
-#ifndef VIGRA_IMPEX2_SUN_HXX
-#define VIGRA_IMPEX2_SUN_HXX
+#ifndef VIGRA_IMPEX_SUN_HXX
+#define VIGRA_IMPEX_SUN_HXX
#include "vigra/codec.hxx"
Index: bmp.hxx
===================================================================
RCS file: /cvsroot/hugin/hugin/src/foreign/vigra_impex/bmp.hxx,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -u -d -r1.1 -r1.1.2.1
--- bmp.hxx 3 Jul 2004 09:55:16 -0000 1.1
+++ bmp.hxx 3 Mar 2006 00:31:48 -0000 1.1.2.1
@@ -4,24 +4,39 @@
/* Cognitive Systems Group, University of Hamburg, Germany */
/* */
/* This file is part of the VIGRA computer vision library. */
-/* ( Version 1.2.0, Aug 07 2003 ) */
-/* You may use, modify, and distribute this software according */
-/* to the terms stated in the LICENSE file included in */
-/* the VIGRA distribution. */
-/* */
+/* ( Version 1.4.0, Dec 21 2005 ) */
/* The VIGRA Website is */
/* http://kogs-www.informatik.uni-hamburg.de/~koethe/vigra/ */
/* Please direct questions, bug reports, and contributions to */
-/* koethe@... */
+/* koethe@... or */
+/* vigra@... */
/* */
-/* THIS SOFTWARE IS PROVIDED AS IS AND WITHOUT ANY EXPRESS OR */
-/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
-/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */
+/* Permission is hereby granted, free of charge, to any person */
+/* obtaining a copy of this software and associated documentation */
+/* files (the "Software"), to deal in the Software without */
+/* restriction, including without limitation the rights to use, */
+/* copy, modify, merge, publish, distribute, sublicense, and/or */
+/* sell copies of the Software, and to permit persons to whom the */
+/* Software is furnished to do so, subject to the following */
+/* conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the */
+/* Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES */
+/* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND */
+/* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT */
+/* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, */
+/* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING */
+/* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR */
+/* OTHER DEALINGS IN THE SOFTWARE. */
/* */
/************************************************************************/
-#ifndef VIGRA_IMPEX2_BMP_HXX
-#define VIGRA_IMPEX2_BMP_HXX
+#ifndef VIGRA_IMPEX_BMP_HXX
+#define VIGRA_IMPEX_BMP_HXX
#include "vigra/codec.hxx"
Index: void_vector.cxx
===================================================================
RCS file: /cvsroot/hugin/hugin/src/foreign/vigra_impex/void_vector.cxx,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -u -d -r1.2 -r1.2.2.1
--- void_vector.cxx 27 Oct 2004 18:12:51 -0000 1.2
+++ void_vector.cxx 3 Mar 2006 00:31:48 -0000 1.2.2.1
@@ -4,27 +4,39 @@
/* Cognitive Systems Group, University of Hamburg, Germany */
/* */
/* This file is part of the VIGRA computer vision library. */
-/* ( Version 1.2.0, Aug 07 2003 ) */
-/* You may use, modify, and distribute this software according */
-/* to the terms stated in the LICENSE file included in */
-/* the VIGRA distribution. */
-/* */
+/* ( Version 1.4.0, Dec 21 2005 ) */
/* The VIGRA Website is */
/* http://kogs-www.informatik.uni-hamburg.de/~koethe/vigra/ */
/* Please direct questions, bug reports, and contributions to */
-/* koethe@... */
+/* koethe@... or */
+/* vigra@... */
/* */
-/* THIS SOFTWARE IS PROVIDED AS IS AND WITHOUT ANY EXPRESS OR */
-/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
-/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */
+/* Permission is hereby granted, free of charge, to any person */
+/* obtaining a copy of this software and associated documentation */
+/* files (the "Software"), to deal in the Software without */
+/* restriction, including without limitation the rights to use, */
+/* copy, modify, merge, publish, distribute, sublicense, and/or */
+/* sell copies of the Software, and to permit persons to whom the */
+/* Software is furnished to do so, subject to the following */
+/* conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the */
+/* Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES */
+/* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND */
+/* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT */
+/* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, */
+/* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING */
+/* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR */
+/* OTHER DEALINGS IN THE SOFTWARE. */
/* */
/************************************************************************/
-#include <config.h>
-
#include "void_vector.hxx"
-
namespace vigra
{
void swap_void_vector( void_vector_base & left, void_vector_base & right )
Index: tiff.hxx
===================================================================
RCS file: /cvsroot/hugin/hugin/src/foreign/vigra_impex/tiff.hxx,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -u -d -r1.1 -r1.1.2.1
--- tiff.hxx 3 Jul 2004 09:55:16 -0000 1.1
+++ tiff.hxx 3 Mar 2006 00:31:48 -0000 1.1.2.1
@@ -4,26 +4,53 @@
/* Cognitive Systems Group, University of Hamburg, Germany */
/* */
/* This file is part of the VIGRA computer vision library. */
-/* ( Version 1.2.0, Aug 07 2003 ) */
-/* You may use, modify, and distribute this software according */
-/* to the terms stated in the LICENSE file included in */
-/* the VIGRA distribution. */
-/* */
+/* ( Version 1.4.0, Dec 21 2005 ) */
/* The VIGRA Website is */
/* http://kogs-www.informatik.uni-hamburg.de/~koethe/vigra/ */
/* Please direct questions, bug reports, and contributions to */
-/* koethe@... */
+/* koethe@... or */
+/* vigra@... */
/* */
-/* THIS SOFTWARE IS PROVIDED AS IS AND WITHOUT ANY EXPRESS OR */
-/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
-/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */
+/* Permission is hereby granted, free of charge, to any person */
+/* obtaining a copy of this software and associated documentation */
+/* files (the "Software"), to deal in the Software without */
+/* restriction, including without limitation the rights to use, */
+/* copy, modify, merge, publish, distribute, sublicense, and/or */
+/* sell copies of the Software, and to permit persons to whom the */
+/* Software is furnished to do so, subject to the following */
+/* conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the */
+/* Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES */
+/* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND */
+/* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT */
+/* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, */
+/* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING */
+/* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR */
+/* OTHER DEALINGS IN THE SOFTWARE. */
/* */
/************************************************************************/
+/* Modifications by Pablo d'Angelo
+ * updated to vigra 1.4 by Douglas Wilkins
+ * as of 18 Febuary 2006:
+ * - Added support for obtaining extra bands beyond RGB.
+ * - Added support for a position field that indicates the start of this
+ * image relative to some global origin.
+ * - Added support for x and y resolution fields.
+ * Modifications by Andrew Mihal, as of 16 October 2004
+ * - Added include for vigra/diff2d.hxx
+ * - Added support for ICC profiles
+ */
-#ifndef VIGRA_IMPEX2_TIFF_HXX
-#define VIGRA_IMPEX2_TIFF_HXX
+#ifndef VIGRA_IMPEX_TIFF_HXX
+#define VIGRA_IMPEX_TIFF_HXX
#include <vector>
+#include "vigra/diff2d.hxx"
#include "vigra/codec.hxx"
namespace vigra {
@@ -54,7 +81,7 @@
unsigned int getNumBands() const;
unsigned int getNumExtraBands() const;
- vigra::Diff2D getPosition() const;
+ Diff2D getPosition() const;
const void * currentScanlineOfBand( unsigned int ) const;
void nextScanline();
@@ -62,6 +89,9 @@
std::string getPixelType() const;
unsigned int getOffset() const;
+ UInt32 getICCProfileLength() const;
+ const unsigned char *getICCProfile() const;
+
void init( const std::string & );
void close();
void abort();
@@ -96,6 +126,8 @@
void * currentScanlineOfBand( unsigned int );
void nextScanline();
+ void setICCProfile(const UInt32 length, const unsigned char * const buf);
+
void init( const std::string & );
void close();
void abort();
Index: codecmanager.hxx
===================================================================
RCS file: /cvsroot/hugin/hugin/src/foreign/vigra_impex/codecmanager.hxx,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -u -d -r1.1 -r1.1.2.1
--- codecmanager.hxx 3 Jul 2004 09:55:16 -0000 1.1
+++ codecmanager.hxx 3 Mar 2006 00:31:48 -0000 1.1.2.1
@@ -4,24 +4,39 @@
/* Cognitive Systems Group, University of Hamburg, Germany */
/* */
/* This file is part of the VIGRA computer vision library. */
-/* ( Version 1.2.0, Aug 07 2003 ) */
-/* You may use, modify, and distribute this software according */
-/* to the terms stated in the LICENSE file included in */
-/* the VIGRA distribution. */
-/* */
+/* ( Version 1.4.0, Dec 21 2005 ) */
/* The VIGRA Website is */
/* http://kogs-www.informatik.uni-hamburg.de/~koethe/vigra/ */
/* Please direct questions, bug reports, and contributions to */
-/* koethe@... */
+/* koethe@... or */
+/* vigra@... */
/* */
-/* THIS SOFTWARE IS PROVIDED AS IS AND WITHOUT ANY EXPRESS OR */
-/* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
-/* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */
+/* Permission is hereby granted, free of charge, to any person */
+/* obtaining a copy of this software and associated documentation */
+/* files (the "Software"), to deal in the Software without */
+/* restriction, including without limitation the rights to use, */
+/* copy, modify, merge, publish, distribute, sublicense, and/or */
+/* sell copies of the Software, and to permit persons to whom the */
+/* Software is furnished to do so, subject to the following */
+/* conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the */
+/* Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES */
+/* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND */
+/* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT */
+/* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, */
+/* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING */
+/* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR */
+/* OTHER DEALINGS IN THE SOFTWARE. */
/* */
/************************************************************************/
-#ifndef VIGRA_IMPEX_CODECMANAGER2_HXX
-#define VIGRA_IMPEX_CODECMANAGER2_HXX
+#ifndef VIGRA_IMPEX_CODECMANAGER_HXX
+#define VIGRA_IMPEX_CODECMANAGER_HXX
#include <map>
#include <memory>
@@ -53,6 +68,9 @@
std::vector<std::string>
queryCodecPixelTypes( const std::string & codecName ) const;
+ std::vector<int>
+ queryCodecBandNumbers( const std::string & codecName ) const;
+
// find out which file types are supported
std::vector<std::string> supportedFileTypes();
@@ -77,6 +95,8 @@
// this will only be called by the singleton pattern
CodecManager();
+ ~CodecManager();
+
}; // class CodecManager
// singleton pattern
|