C:/sources/c++/buddhabrot/buddhabrot/ImageCalculator.h

00001 /*
00002 Copyright (C)2009 SCHWARTZ Pierre
00003 
00004 This program is free software; you can redistribute it and/or
00005 modify it under the terms of the GNU Lesser General Public
00006 License as published by the Free Software Foundation; either
00007 version 2.1 of the License, or (at your option) any later version.
00008 
00009 This program is distributed in the hope that it will be useful,
00010 but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00012 Lesser General Public License for more details.
00013 
00014 You should have received a copy of the GNU Lesser General Public
00015 License along with this program; if not, write to the Free Software
00016 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00017 */
00018 
00027 #ifndef H__ImageCalculator_H
00028 #define H__ImageCalculator_H
00029 
00030 #include <QtGui/QImage>
00031 #include <QtCore/QVector>
00032 #include <QtGui>
00033 
00034 #include "fractale.h"
00035 #include "ImageTiler.h"
00036 
00037 
00038 class ImageCalculator : public QObject
00039 {
00040         Q_OBJECT
00041 
00042         public :
00043                 ImageCalculator(int nb, QImage *d, QRectF w, QSize r, fractale &f, char e, bool anim);
00044                 ~ImageCalculator();
00045 
00046                 void run();
00047                 long maxValue;
00048 
00049                 long inline getMaxValue(){
00050                         return maxValue;
00051                 }
00052 
00056                 static long inline RGBAToInt(QRgb r){
00057                         int red = qRed(r);
00058                         int green = qGreen(r);
00059                         int blue = qBlue(r);
00060                         int alpha = 255-qAlpha(r);
00061                         return (alpha << 24) + (red<<16) + (green<<8) + blue;
00062                 }
00063                 
00067                 static QRgb inline intToRGBA(long r){
00068                         int alpha = r >> 24;
00069                         r -= (alpha << 24);
00070                         int red = r >> 16;
00071                         r -= (red << 16);
00072                         int green = r >> 8;
00073                         r -= (green << 8);
00074                         int blue = r;
00075                         
00076                         return QColor(red, green, blue, 255-alpha).rgb();
00077                 }
00078 
00079                 signals:
00080                         void progress(int x);
00081                         void render();
00082 
00083                 public slots :
00084                         void s_processing();
00085         private:
00086                 int nbThreads;
00087                 QImage *destination;
00088                 QRectF window;
00089                 QSize size;
00090                 fractale &frac;
00091                 char exhaustivite;
00092                 bool animate;
00093                 bool shortcuts;
00094 
00095                 int nbProcessedRows;            // un simple compteur d'avancement
00096 
00097 
00098                 QVector<QImage*> imageParts;
00099                 void sumImagesIntoDestination();
00100                 void applyGamma();
00101 };
00102 
00103 #endif

Generated on Sat Feb 6 16:30:54 2010 for BuddhaBrot by  doxygen 1.4.6-NO