[opengtl-commits] [286] add a constant function for reading image content |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/opengtl-commits Archives
]
Revision: 286
Author: cyrille
Date: 2008-07-02 00:17:46 +0200 (Wed, 02 Jul 2008)
Log Message:
-----------
add a constant function for reading image content
Modified Paths:
--------------
trunk/OpenGTL/OpenGTL/GTLCore/BufferImage.cpp
trunk/OpenGTL/OpenGTL/GTLCore/BufferImage.h
Modified: trunk/OpenGTL/OpenGTL/GTLCore/BufferImage.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/BufferImage.cpp 2008-07-01 22:17:27 UTC (rev 285)
+++ trunk/OpenGTL/OpenGTL/GTLCore/BufferImage.cpp 2008-07-01 22:17:46 UTC (rev 286)
@@ -63,6 +63,16 @@
}
}
+const char* BufferImage::data( int _x, int _y ) const
+{
+ if( _x >= 0 and _y >= 0 and _x < d->width and _y < d->height )
+ {
+ return d->buffer->rawData() + (_x * pixelSize() + _y * lineWidth());
+ } else {
+ return d->defaultPixel;
+ }
+}
+
int BufferImage::lineWidth() const
{
return d->lineWidth;
Modified: trunk/OpenGTL/OpenGTL/GTLCore/BufferImage.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/BufferImage.h 2008-07-01 22:17:27 UTC (rev 285)
+++ trunk/OpenGTL/OpenGTL/GTLCore/BufferImage.h 2008-07-01 22:17:46 UTC (rev 286)
@@ -44,6 +44,7 @@
~BufferImage();
public:
virtual char* data( int _x, int _y );
+ virtual const char* data( int _x, int _y ) const;
/**
* @return the width of the image
*/