[opengtl-commits] [268] use the fact that OpenShiva now support working directly with 8bit-channels images |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/opengtl-commits Archives
]
Revision: 268
Author: cyrille
Date: 2008-06-30 21:52:47 +0200 (Mon, 30 Jun 2008)
Log Message:
-----------
use the fact that OpenShiva now support working directly with 8bit-channels images
Modified Paths:
--------------
trunk/QtShiva/MainWindow.ui
trunk/QtShiva/QtShiva.cpp
Added Paths:
-----------
trunk/QtShiva/QtGTL.h
Modified: trunk/QtShiva/MainWindow.ui
===================================================================
--- trunk/QtShiva/MainWindow.ui 2008-06-30 19:48:47 UTC (rev 267)
+++ trunk/QtShiva/MainWindow.ui 2008-06-30 19:52:47 UTC (rev 268)
@@ -30,7 +30,7 @@
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
- <widget class="QWidget" name="" >
+ <widget class="QWidget" name="layoutWidget" >
<layout class="QVBoxLayout" name="verticalLayout" >
<item>
<widget class="QListWidget" name="listImages" />
@@ -68,7 +68,7 @@
</item>
</layout>
</widget>
- <widget class="QWidget" name="" >
+ <widget class="QWidget" name="layoutWidget" >
<layout class="QVBoxLayout" name="verticalLayout_2" >
<item>
<widget class="QTextEdit" name="ctlCodeEditor" >
@@ -86,6 +86,9 @@
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:10pt;">}</p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:10pt;"></p></body></html></string>
</property>
+ <property name="acceptRichText" >
+ <bool>false</bool>
+ </property>
</widget>
</item>
<item>
@@ -128,18 +131,6 @@
</widget>
</item>
</layout>
- <zorder>imageViewer</zorder>
- <zorder>ctlCodeEditor</zorder>
- <zorder>buttonApply</zorder>
- <zorder>pushButtonReload</zorder>
- <zorder>buttonRefresh</zorder>
- <zorder>pushButtonOpen</zorder>
- <zorder>horizontalSpacer</zorder>
- <zorder>buttonAdd</zorder>
- <zorder>buttonRemove</zorder>
- <zorder>horizontalSpacer_2</zorder>
- <zorder>listImages</zorder>
- <zorder>listImages</zorder>
</widget>
<resources/>
<connections/>
Added: trunk/QtShiva/QtGTL.h
===================================================================
--- trunk/QtShiva/QtGTL.h (rev 0)
+++ trunk/QtShiva/QtGTL.h 2008-06-30 19:52:47 UTC (rev 268)
@@ -0,0 +1,45 @@
+
+#ifndef _QTGTL_H_
+#define _QTGTL_H_
+
+#include <QImage>
+#include <GTLCore/Buffer.h>
+
+class QImageBuffer : public GTLCore::Buffer {
+ public:
+ QImageBuffer(const QImage& img) : m_image(img) { }
+ ~QImageBuffer() {}
+ virtual char * rawData() { return (char*)m_image.bits(); }
+ virtual const char * rawData() const { return (const char*)m_image.bits(); }
+ virtual int size() const { return m_image.numBytes(); }
+ QImage image() const { return m_image; }
+ private:
+ QImage m_image;
+};
+
+class QImageImage : public OpenShiva::BufferImage {
+ public:
+ QImageImage(const QImage& img) : BufferImage( img.width(), img.height(), new QImageBuffer( img ), imageToPixelDescription( img ) )
+ {
+ }
+ ~QImageImage() {}
+ QImage image() const { return static_cast<const QImageBuffer*>(buffer())->image(); }
+ private:
+ GTLCore::PixelDescription imageToPixelDescription( const QImage& img )
+ {
+ switch( img.format())
+ {
+ case QImage::Format_RGB32:
+ return GTLCore::PixelDescription( GTLCore::Type::UnsignedInteger8, 4 );
+ case QImage::Format_ARGB32:
+ return GTLCore::PixelDescription( GTLCore::Type::UnsignedInteger8, 4 );
+ case QImage::Format_RGB888:
+ return GTLCore::PixelDescription( GTLCore::Type::UnsignedInteger8, 3 );
+ default:
+ qFatal("Unsupported QImage");
+ }
+ }
+};
+
+
+#endif
Property changes on: trunk/QtShiva/QtGTL.h
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: trunk/QtShiva/QtShiva.cpp
===================================================================
--- trunk/QtShiva/QtShiva.cpp 2008-06-30 19:48:47 UTC (rev 267)
+++ trunk/QtShiva/QtShiva.cpp 2008-06-30 19:52:47 UTC (rev 268)
@@ -34,6 +34,8 @@
#include <GTLCore/RegionF.h>
#include <GTLCore/Type.h>
+#include "QtGTL.h"
+
QtShiva::QtShiva()
{
m_mainWindow = new Ui_MainWindow;
@@ -81,12 +83,12 @@
void QtShiva::apply()
{
GTLCore::PixelDescription pixel( GTLCore::Type::Float, 3 );
- OpenShiva::Kernel p("", pixel);
+ OpenShiva::Kernel p("", 4);
p.setSource( m_mainWindow->ctlCodeEditor->toPlainText().toAscii ().data());
p.compile();
if(p.isCompiled())
{
- OpenShiva::Image image(1000, 1000, pixel );
+// OpenShiva::Image image(1000, 1000, pixel );
std::list<OpenShiva::AbstractImage*> inputImages;
for( int k = 0; k < m_mainWindow->listImages->count(); ++k)
{
@@ -98,22 +100,15 @@
.arg(fileName));
return;
}
- OpenShiva::Image* iImage = new OpenShiva::Image(img.width(), img.height(), pixel );
- for( int j = 0; j < img.height(); ++j )
- {
- for(int i = 0; i < img.width(); ++i )
- {
- QRgb rgb = img.pixel(i, j);
- float* ptr = (float*)iImage->data(i,j);
- ptr[0] = qRed(rgb);
- ptr[1] = qGreen(rgb);
- ptr[2] = qBlue(rgb);
- ptr[3] = qAlpha(rgb);
- }
- }
+ OpenShiva::AbstractImage* iImage = new QImageImage( img );
inputImages.push_back( iImage );
}
+ // -
+ QImageImage image( QImage( 1000, 1000, QImage::Format_RGB32) );
+ // -
p.evaluatePixeles( GTLCore::Region(0,0, 1000,1000), inputImages, &image );
+ currentImage = image.image();
+#if 0
currentImage = QImage( image.width(), image.height(), QImage::Format_RGB32);
for( int j = 0; j < image.height(); ++j )
{
@@ -125,6 +120,7 @@
currentImage.setPixel( i,j, qRgb(r,g,b) );
}
}
+#endif
for( std::list<OpenShiva::AbstractImage*>::iterator it = inputImages.begin();
it != inputImages.end(); ++it)
{