[opengtl-commits] [474] add a function to apply a program on an image ( only works with BufferImage atm)

[ Thread Index | Date Index | More lists.tuxfamily.org/opengtl-commits Archives ]


Revision: 474
Author:   cyrille
Date:     2008-11-10 13:05:53 +0100 (Mon, 10 Nov 2008)

Log Message:
-----------
add a function to apply a program on an image (only works with BufferImage atm)

Modified Paths:
--------------
    trunk/OpenGTL/OpenCTL/OpenCTL/Program.cpp
    trunk/OpenGTL/OpenCTL/OpenCTL/Program.h
    trunk/OpenGTL/OpenGTL/GTLCore/BufferImage.cpp
    trunk/OpenGTL/OpenGTL/GTLCore/BufferImage.h


Modified: trunk/OpenGTL/OpenCTL/OpenCTL/Program.cpp
===================================================================
--- trunk/OpenGTL/OpenCTL/OpenCTL/Program.cpp	2008-11-10 10:59:39 UTC (rev 473)
+++ trunk/OpenGTL/OpenCTL/OpenCTL/Program.cpp	2008-11-10 12:05:53 UTC (rev 474)
@@ -33,6 +33,7 @@
 #include "GTLCore/Type_p.h"
 #include "GTLCore/Value.h"
 #include "GTLCore/VariableNG_p.h"
+#include "GTLCore/BufferImage.h"
 
 // OpenCTL
 #include "Module.h"
@@ -402,6 +403,16 @@
   OCTL_DEBUG("Applied");
 }
 
+void Program::apply(const GTLCore::AbstractImage& input, GTLCore::AbstractImage& output) const
+{
+  const GTLCore::BufferImage* inputBI = dynamic_cast<const GTLCore::BufferImage*>( &input );
+  GTLCore::BufferImage* outputBI = dynamic_cast<GTLCore::BufferImage*>( &output );
+  GTL_ASSERT( inputBI );
+  GTL_ASSERT( outputBI );
+  apply( *inputBI->buffer(), *outputBI->buffer() );
+}
+
+
 void Program::setVarying( const GTLCore::String& _name, const GTLCore::Value& _value )
 {
   std::map< GTLCore::String, void*>::iterator it = d->varyingsPtr.find( _name );

Modified: trunk/OpenGTL/OpenCTL/OpenCTL/Program.h
===================================================================
--- trunk/OpenGTL/OpenCTL/OpenCTL/Program.h	2008-11-10 10:59:39 UTC (rev 473)
+++ trunk/OpenGTL/OpenCTL/OpenCTL/Program.h	2008-11-10 12:05:53 UTC (rev 474)
@@ -28,6 +28,7 @@
   class PixelDescription;
   class String;
   class Value;
+  class AbstractImage;
 }
 
 namespace OpenCTL {
@@ -84,6 +85,7 @@
        */
       bool initialised() const;
       void apply(const GTLCore::Buffer& input, GTLCore::Buffer& output) const;
+      void apply(const GTLCore::AbstractImage& input, GTLCore::AbstractImage& output) const;
       /**
        * Set a variying argument of the function used by the program.
        * For instance the following CTL code gives access to exposure as a <em>variying</em>

Modified: trunk/OpenGTL/OpenGTL/GTLCore/BufferImage.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/BufferImage.cpp	2008-11-10 10:59:39 UTC (rev 473)
+++ trunk/OpenGTL/OpenGTL/GTLCore/BufferImage.cpp	2008-11-10 12:05:53 UTC (rev 474)
@@ -94,3 +94,8 @@
 {
   return d->buffer;
 }
+
+GTLCore::Buffer* BufferImage::buffer()
+{
+  return d->buffer;
+}

Modified: trunk/OpenGTL/OpenGTL/GTLCore/BufferImage.h
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/BufferImage.h	2008-11-10 10:59:39 UTC (rev 473)
+++ trunk/OpenGTL/OpenGTL/GTLCore/BufferImage.h	2008-11-10 12:05:53 UTC (rev 474)
@@ -22,6 +22,10 @@
 
 #include <GTLCore/AbstractImage.h>
 
+namespace OpenCTL {
+  class Program;
+}
+
 namespace GTLCore {
   class Buffer;
   /**
@@ -30,6 +34,7 @@
    * @ingroup GTLCore
    */
   class BufferImage : public AbstractImage {
+    friend class OpenCTL::Program;
     public:
       /**
        * @param _width width of the image
@@ -57,6 +62,8 @@
       int lineWidth() const;
       const GTLCore::Buffer* buffer() const;
     private:
+      GTLCore::Buffer* buffer();
+    private:
       struct Private;
       Private* const d;
   };


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/