[Hdrflow-svn] SF.net SVN: hdrflow: [353] trunk/lib/openlibraries/src/openimagelib/il
Status: Pre-Alpha
Brought to you by:
glslang
|
From: <gl...@us...> - 2007-10-10 21:36:01
|
Revision: 353
http://hdrflow.svn.sourceforge.net/hdrflow/?rev=353&view=rev
Author: glslang
Date: 2007-10-10 14:22:34 -0700 (Wed, 10 Oct 2007)
Log Message:
-----------
+ makes crop underlying element size aware
Modified Paths:
--------------
trunk/lib/openlibraries/src/openimagelib/il/basic_image.hpp
trunk/lib/openlibraries/src/openimagelib/il/float_traits.hpp
trunk/lib/openlibraries/src/openimagelib/il/rgb_traits.hpp
Modified: trunk/lib/openlibraries/src/openimagelib/il/basic_image.hpp
===================================================================
--- trunk/lib/openlibraries/src/openimagelib/il/basic_image.hpp 2007-10-09 21:21:59 UTC (rev 352)
+++ trunk/lib/openlibraries/src/openimagelib/il/basic_image.hpp 2007-10-10 21:22:34 UTC (rev 353)
@@ -215,20 +215,22 @@
bool is_flipped = ( flags & flipped ) != 0;
bool is_flopped = ( flags & flopped ) != 0;
+ size_type element_size = bitdepth( ) / 8;
+
plane &p = crop[ 0 ];
p.width = w;
p.height = h;
p.linesize = w * block_size_;
if ( !is_flipped )
- p.offset = p.pitch * y;
+ p.offset = p.pitch * y * element_size;
else
- p.offset = ( ( height_ - y - h ) * p.pitch );
+ p.offset = ( ( height_ - y - h ) * p.pitch ) * element_size;
if ( !is_flopped )
- p.offset += x * block_size_;
+ p.offset += x * block_size_ * element_size;
else
- p.offset += ( width_ - w - x ) * block_size_;
+ p.offset += ( width_ - w - x ) * block_size_ * element_size;
}
// Flop scan which assumes block_size_ is known and <= 4 - associated plane is
@@ -350,7 +352,7 @@
// Obtain the number of planes and iterate through each
size_type count = structure_->plane_count( );
- size_type sfactor = structure_->bitdepth( ) / 8;
+ size_type element_size = structure_->bitdepth( ) / 8;
for ( size_type i = 0; i < count; i ++ )
{
@@ -358,7 +360,7 @@
const_pointer src = other.data( i );
size_type src_pitch = other.pitch( i );
- src_pitch *= sfactor;
+ src_pitch *= element_size;
// The destination plane, pitch and height
pointer dst = data( i );
@@ -367,8 +369,8 @@
size_type dst_scan = linesize( i );
size_type dst_height = height( i );
- dst_scan *= sfactor;
- dst_pitch *= sfactor;
+ dst_scan *= element_size;
+ dst_pitch *= element_size;
// We need to orient the dest correctly
if ( need_flip )
Modified: trunk/lib/openlibraries/src/openimagelib/il/float_traits.hpp
===================================================================
--- trunk/lib/openlibraries/src/openimagelib/il/float_traits.hpp 2007-10-09 21:21:59 UTC (rev 352)
+++ trunk/lib/openlibraries/src/openimagelib/il/float_traits.hpp 2007-10-10 21:22:34 UTC (rev 353)
@@ -91,6 +91,9 @@
virtual r16g16b16f* clone( size_type w, size_type h )
{ return new r16g16b16f( *this, w, h ); }
+
+ virtual void flop_scan_line( size_t p, pointer dst, const_pointer src, size_type w ) const
+ { flop_scan_line_( p, ( short* ) dst, ( const unsigned short* ) src, w ); }
};
template<typename T = float, class storage = default_storage<T> >
@@ -131,6 +134,9 @@
virtual b16g16r16f* clone( size_type w, size_type h )
{ return new b16g16r16f( *this, w, h ); }
+
+ virtual void flop_scan_line( size_t p, pointer dst, const_pointer src, size_type w ) const
+ { flop_scan_line_( p, ( short* ) dst, ( const unsigned short* ) src, w ); }
};
template<typename T = float, class storage = default_storage<T> >
@@ -171,6 +177,9 @@
virtual r16g16b16a16f* clone( size_type w, size_type h )
{ return new r16g16b16a16f( *this, w, h ); }
+
+ virtual void flop_scan_line( size_t p, pointer dst, const_pointer src, size_type w ) const
+ { flop_scan_line_( p, ( short* ) dst, ( const unsigned short* ) src, w ); }
};
template<typename T = float, class storage = default_storage<T> >
@@ -213,9 +222,7 @@
{ return new r32g32b32f( *this, w, h ); }
virtual void flop_scan_line( size_t p, pointer dst, const_pointer src, size_type w ) const
- {
- flop_scan_line_( p, ( float* ) dst, ( const float* ) src, w );
- }
+ { flop_scan_line_( p, ( float* ) dst, ( const float* ) src, w ); }
};
template<typename T = float, class storage = default_storage<T> >
@@ -258,9 +265,7 @@
{ return new r32g32b32a32f( *this, w, h ); }
virtual void flop_scan_line( size_t p, pointer dst, const_pointer src, size_type w ) const
- {
- flop_scan_line_( p, ( float* ) dst, ( const float* ) src, w );
- }
+ { flop_scan_line_( p, ( float* ) dst, ( const float* ) src, w ); }
};
} } }
Modified: trunk/lib/openlibraries/src/openimagelib/il/rgb_traits.hpp
===================================================================
--- trunk/lib/openlibraries/src/openimagelib/il/rgb_traits.hpp 2007-10-09 21:21:59 UTC (rev 352)
+++ trunk/lib/openlibraries/src/openimagelib/il/rgb_traits.hpp 2007-10-10 21:22:34 UTC (rev 353)
@@ -521,7 +521,7 @@
{ return bs * sizeof( unsigned short ) * detail::rgb_Allocate_size<T>( )( 1, width, height, depth ); }
virtual size_type bitdepth( ) const
- { return 12; }
+ { return 16; }
virtual l12a12p* clone( size_type w, size_type h )
{ return new l12a12p( *this, w, h ); }
@@ -684,7 +684,7 @@
{ return sizeof( unsigned short ) * detail::rgb_Allocate_size<T>( )( bs, width, height, depth ); }
virtual size_type bitdepth( ) const
- { return 10; }
+ { return 16; }
virtual r10g10b10* clone( size_type w, size_type h )
{ return new r10g10b10( *this, w, h ); }
@@ -743,7 +743,7 @@
{ return sizeof( unsigned short ) * detail::rgb_Allocate_size<T>( )( bs, width, height, depth ); }
virtual size_type bitdepth( ) const
- { return 10; }
+ { return 16; }
virtual r10g10b10a10* clone( size_type w, size_type h )
{ return new r10g10b10a10( *this, w, h ); }
@@ -803,7 +803,7 @@
{ return bs * sizeof( unsigned short ) * detail::rgb_Allocate_size<T>( )( 1, width, height, depth ); }
virtual size_type bitdepth( ) const
- { return 10; }
+ { return 16; }
virtual r10g10b10p* clone( size_type w, size_type h )
{ return new r10g10b10p( *this, w, h ); }
@@ -869,7 +869,7 @@
{ return bs * sizeof( unsigned short ) * detail::rgb_Allocate_size<T>( )( 1, width, height, depth ); }
virtual size_type bitdepth( ) const
- { return 10; }
+ { return 16; }
virtual r10g10b10a10p* clone( size_type w, size_type h )
{ return new r10g10b10a10p( *this, w, h ); }
@@ -937,7 +937,7 @@
{ return sizeof( unsigned short ) * detail::rgb_Allocate_size<T>( )( bs, width, height, depth ); }
virtual size_type bitdepth( ) const
- { return 12; }
+ { return 16; }
virtual r12g12b12* clone( size_type w, size_type h )
{ return new r12g12b12( *this, w, h ); }
@@ -996,7 +996,7 @@
{ return sizeof( unsigned short ) * detail::rgb_Allocate_size<T>( )( bs, width, height, depth ); }
virtual size_type bitdepth( ) const
- { return 12; }
+ { return 16; }
virtual r12g12b12a12* clone( size_type w, size_type h )
{ return new r12g12b12a12( *this, w, h ); }
@@ -1056,7 +1056,7 @@
{ return bs * sizeof( unsigned short ) * detail::rgb_Allocate_size<T>( )( 1, width, height, depth ); }
virtual size_type bitdepth( ) const
- { return 12; }
+ { return 16; }
virtual r12g12b12p* clone( size_type w, size_type h )
{ return new r12g12b12p( *this, w, h ); }
@@ -1122,7 +1122,7 @@
{ return bs * sizeof( unsigned short ) * detail::rgb_Allocate_size<T>( )( 1, width, height, depth ); }
virtual size_type bitdepth( ) const
- { return 12; }
+ { return 16; }
virtual r12g12b12a12p* clone( size_type w, size_type h )
{ return new r12g12b12a12p( *this, w, h ); }
@@ -1504,7 +1504,7 @@
{ return sizeof( unsigned short ) * detail::rgb_Allocate_size<T>( )( bs, width, height, depth ); }
virtual size_type bitdepth( ) const
- { return 10; }
+ { return 16; }
virtual r10g10b10log* clone( size_type w, size_type h )
{ return new r10g10b10log( *this, w, h ); }
@@ -1563,7 +1563,7 @@
{ return sizeof( unsigned short ) * detail::rgb_Allocate_size<T>( )( bs, width, height, depth ); }
virtual size_type bitdepth( ) const
- { return 12; }
+ { return 16; }
virtual r12g12b12log* clone( size_type w, size_type h )
{ return new r12g12b12log( *this, w, h ); }
@@ -1740,7 +1740,7 @@
{ return sizeof( unsigned short ) * detail::rgb_Allocate_size<T>( )( bs, width, height, depth ); }
virtual size_type bitdepth( ) const
- { return 10; }
+ { return 16; }
virtual r10g10b10a10log* clone( size_type w, size_type h )
{ return new r10g10b10a10log( *this, w, h ); }
@@ -1799,7 +1799,7 @@
{ return sizeof( unsigned short ) * detail::rgb_Allocate_size<T>( )( bs, width, height, depth ); }
virtual size_type bitdepth( ) const
- { return 12; }
+ { return 16; }
virtual r12g12b12a12log* clone( size_type w, size_type h )
{ return new r12g12b12a12log( *this, w, h ); }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|