[Kst] extragear/graphics/kst/kst/datasources/qimagesource

Barth Netterfield netterfield at astro.utoronto.ca
Tue Aug 23 00:57:19 CEST 2005


SVN commit 452287 by netterfield:

Fix change starting sample for fields and starting pixel for matrixes...



 M  +22 -25    qimagesource.cpp  


--- trunk/extragear/graphics/kst/kst/datasources/qimagesource/qimagesource.cpp #452286:452287
@@ -104,23 +104,9 @@
 
   y0 = yStart;
   y1 = yStart+yNumSteps;
-//   if ( y1>=_image.width() ) {
-//     y1 = _image.width()-1;
-//   }
-//   if ( y0<0 ) {
-//     y0 = 0;
-//   }
-//   if ( y0>=y1 ) return 0;
 
-  x0 = yStart;
+  x0 = xStart;
   x1 = xStart+xNumSteps;
-//   if ( x1>=_image.width() ) {
-//     x1 = _image.width();
-//   }
-//   if ( x0<0 ) {
-//     x0 = 0;
-//   }
-//   if ( x0>=x1 ) return 0;
 
   i=0;
 
@@ -166,35 +152,38 @@
 
 int QimagesourceSource::readField(double *v, const QString& field, int s, int n) {
   int i=0, px,  py;
+
+  printf( "entering readField...\n" );
   if ( field=="INDEX" ) {
     for ( i=0; i<n; i++ ) {
       v[i] = i+s;
     }
   } else if ( field=="GRAY" ) {
-    for ( i=0; i<n; i++ ) {
+    for ( i=s; i<s+n; i++ ) {
       px = i%_image.width();
       py = i/_image.width();
-      v[i] = qGray( _image.pixel( px, py ) );
+      v[i-s] = qGray( _image.pixel( px, py ) );
     }
   } else if ( field=="RED" ) {
-    for ( i=0; i<n; i++ ) {
+    for ( i=s; i<s+n; i++ ) {
       px = i%_image.width();
       py = i/_image.width();
-      v[i] = qRed( _image.pixel( px, py ) );
+      v[i-s] = qRed( _image.pixel( px, py ) );
     }
   } else if ( field=="GREEN" ) {
-    for ( i=0; i<n; i++ ) {
+    for ( i=s; i<s+n; i++ ) {
       px = i%_image.width();
       py = i/_image.width();
-      v[i] = qGreen( _image.pixel( px, py ) );
+      v[i-s] = qGreen( _image.pixel( px, py ) );
     }
   } else if ( field=="BLUE" ) {
-    for ( i=0; i<n; i++ ) {
+    for ( i=s; i<s+n; i++ ) {
       px = i%_image.width();
       py = i/_image.width();
-      v[i] = qBlue( _image.pixel( px, py ) );
+      v[i-s] = qBlue( _image.pixel( px, py ) );
     }
   }
+  printf( "leaving readField...\n" );
   return( i );
 }
 
@@ -248,8 +237,16 @@
 
 int understands_qimagesource(KConfig*, const QString& filename) {
 
-  if ( QImage::imageFormat( filename ) ) return 90;
-  else return 0;
+  QString ftype( QImage::imageFormat( filename ) );
+
+  if ( ftype.isEmpty() ) return 0;
+
+  if ( ftype == "TIFF" ) {
+    if ( ftype.find( ".tif",  -5, false )<0 ) return 0;
+  }
+
+  return 90;
+
 }
 
 


More information about the Kst mailing list