[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdelibs/kimgio
From:       Dirk Mueller <mueller () kde ! org>
Date:       2005-04-13 20:55:12
Message-ID: 20050413205512.EE447492 () office ! kde ! org
[Download RAW message or body]

CVS commit by mueller: 

be more robust about malformed input


  M +9 -23     xview.cpp   1.15


--- kdelibs/kimgio/xview.cpp  #1.14:1.15
@@ -8,4 +8,5 @@
 #include <stdio.h>
 #include <string.h>
+#include <stdlib.h>
 #include <qimage.h>
 
@@ -16,4 +17,7 @@
 #define BUFSIZE 1024
 
+static const int b_255_3[]= {0,85,170,255},  // index*255/3
+           rg_255_7[]={0,36,72,109,145,182,218,255}; // index *255/7
+
 KDE_EXPORT void kimgio_xv_read( QImageIO *_imageio )
 {      
@@ -56,5 +60,5 @@ KDE_EXPORT void kimgio_xv_read( QImageIO
 
         // now follows a binary block of x*y bytes. 
-        char *block = new char[ blocksize ];
+        char *block = (char*) malloc(blocksize);
         if(!block)
             return;
@@ -67,6 +71,8 @@ KDE_EXPORT void kimgio_xv_read( QImageIO
         // Create the image
         QImage image( x, y, 8, maxval + 1, QImage::BigEndian );
-        if( image.isNull())
+        if( image.isNull()) {
+                free(block);
                 return;
+        }
 
         // how do the color handling? they are absolute 24bpp
@@ -76,27 +82,7 @@ KDE_EXPORT void kimgio_xv_read( QImageIO
         for ( int j = 0; j < 256; j++ )
         {
-// ----------- OLIVER EIDEN
-//      That is the old-code !
-/*              r =  ((int) ((j >> 5) & 0x07)) << 5;
-                g =  ((int) ((j >> 2) & 0x07)) << 5;
-                b =  ((int) ((j >> 0) & 0x03)) << 6;*/
-
-
-//      That is the code-how xv, decode 3-3-2 pixmaps, it is slighly different,
-//      but yields much better visuals results
-/*              r =  (((int) ((j >> 5) & 0x07)) *255) / 7;
-                g =  (((int) ((j >> 2) & 0x07)) *255) / 7;
-                b =  (((int) ((j >> 0) & 0x03)) *255) / 3;*/
-
-//      This is the same as xv, with multiplications/divisions replaced by indexing
-
-//      Look-up table to avoid multiplications and divisons
-        static int b_255_3[]= {0,85,170,255},  // index*255/3
-                   rg_255_7[]={0,36,72,109,145,182,218,255}; // index *255/7
-
                 r =  rg_255_7[((j >> 5) & 0x07)];
                 g =  rg_255_7[((j >> 2) & 0x07)];
                 b =  b_255_3[((j >> 0) & 0x03)];
-// ---------------
                 image.setColor( j, qRgb( r, g, b ) );
         }
@@ -111,5 +97,5 @@ KDE_EXPORT void kimgio_xv_read( QImageIO
         _imageio->setStatus( 0 );
 
-        delete [] block;
+        free(block);
         return;
 }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic