[opengtl-commits] [697] add knowledge of the alpha channel to PixelDescription |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/opengtl-commits Archives
]
Revision: 697
Author: cyrille
Date: 2009-03-26 13:27:32 +0100 (Thu, 26 Mar 2009)
Log Message:
-----------
add knowledge of the alpha channel to PixelDescription
Modified Paths:
--------------
trunk/OpenGTL/OpenGTL/GTLCore/PixelDescription.cpp
trunk/OpenGTL/OpenGTL/GTLCore/PixelDescription.h
Modified: trunk/OpenGTL/OpenGTL/GTLCore/PixelDescription.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/PixelDescription.cpp 2009-03-26 12:08:14 UTC (rev 696)
+++ trunk/OpenGTL/OpenGTL/GTLCore/PixelDescription.cpp 2009-03-26 12:27:32 UTC (rev 697)
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008 Cyrille Berger <cberger@xxxxxxxxxxx>
+ * Copyright (c) 2008-2009 Cyrille Berger <cberger@xxxxxxxxxxx>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -30,6 +30,7 @@
std::vector< std::size_t > channelPositions;
int bitsSize;
void initChannelPositions();
+ int alphaPos;
};
void PixelDescription::Private::initChannelPositions()
@@ -52,8 +53,23 @@
d->channelsType.push_back( channelType_ );
}
d->initChannelPositions();
+ d->alphaPos = -1;
}
+PixelDescription::PixelDescription( const Type* channelType_, int channels_, int alphaPos_) : d(new Private)
+{
+ GTL_ASSERT( channels_ > 0);
+ GTL_ASSERT( channelType_->bitsSize() > 0 );
+ d->bitsSize = channels_ * channelType_->bitsSize();
+ d->channelsType.reserve(channels_);
+ for(int i = 0; i< channels_; ++i)
+ {
+ d->channelsType.push_back( channelType_ );
+ }
+ d->initChannelPositions();
+ d->alphaPos = alphaPos_;
+}
+
PixelDescription::PixelDescription( const std::vector<const Type* >& channelsType_) : d(new Private)
{
GTL_ASSERT( channelsType_.size() > 0);
@@ -66,8 +82,24 @@
d->bitsSize += (*it)->bitsSize();
}
d->initChannelPositions();
+ d->alphaPos = -1;
}
+PixelDescription::PixelDescription( const std::vector<const Type* >& channelsType_, int _alphaPos) : d(new Private)
+{
+ GTL_ASSERT( channelsType_.size() > 0);
+ d->channelsType = channelsType_;
+ d->bitsSize = 0;
+ for( std::vector<const Type*>::iterator it = d->channelsType.begin();
+ it != d->channelsType.end(); ++it)
+ {
+ GTL_ASSERT( (*it)->bitsSize() > 0 );
+ d->bitsSize += (*it)->bitsSize();
+ }
+ d->initChannelPositions();
+ d->alphaPos = _alphaPos;
+}
+
PixelDescription::PixelDescription( const PixelDescription& rhs) : d(new Private(*rhs.d))
{
}
@@ -168,3 +200,8 @@
GTL_ASSERT( _positions.size() == channels() );
d->channelPositions = _positions;
}
+
+int PixelDescription::alphaPos() const
+{
+ return d->alphaPos;
+}
Modified: trunk/OpenGTL/OpenGTL/GTLCore/PixelDescription.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/PixelDescription.h 2009-03-26 12:08:14 UTC (rev 696)
+++ trunk/OpenGTL/OpenGTL/GTLCore/PixelDescription.h 2009-03-26 12:27:32 UTC (rev 697)
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008 Cyrille Berger <cberger@xxxxxxxxxxx>
+ * Copyright (c) 2008-2009 Cyrille Berger <cberger@xxxxxxxxxxx>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -37,11 +37,13 @@
* @param _channels the number of channels
*/
PixelDescription( const Type* _channelType, int _channels);
+ PixelDescription( const Type* _channelType, int _channels, int _alphaPos); // TODO BIC merge with previous constructor and _alphaPos = -1
/**
* Create a PixelDescription with multiple channels of different types.
* @param _channelsType a vector with the list of channels types
*/
PixelDescription( const std::vector<const Type* >& _channelsType);
+ PixelDescription( const std::vector<const Type* >& _channelsType, int _alphaPos); // TODO BIC merge with previous constructor and _alphaPos = -1
PixelDescription( const PixelDescription& pixelDescription);
PixelDescription& operator=(const PixelDescription& rhs);
~PixelDescription();
@@ -70,6 +72,10 @@
* @return the size of a pixel in bits
*/
int bitsSize() const;
+ /**
+ * @return the position of the alpha channel, or -1 if no alpha channel
+ */
+ int alphaPos() const;
bool operator<( const PixelDescription& _rhs ) const;
bool operator==( const PixelDescription& _rhs ) const;
bool operator!=( const PixelDescription& _rhs ) const;