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

Go to the documentation of this file.
00001 /*
00002 Copyright 2010 Pierre SCHWARTZ
00003 
00004 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 
00005 documentation files (the "Software"), to deal in the Software without restriction, including without 
00006 limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 
00007 of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following 
00008 conditions: The above copyright notice and this permission notice shall be included in all copies or 
00009 substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
00010 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 
00011 PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 
00012 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 
00013 OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
00014 */
00015 
00024 #ifndef H__ImageCalculator_H
00025 #define H__ImageCalculator_H
00026 
00027 #include <QtGui/QImage>
00028 #include <QtCore/QVector>
00029 #include <QtGui>
00030 
00031 #include "fractale.h"
00032 #include "imagetiler.h"
00033 #include "networkimagetiler.h"
00034 
00041 class ImageCalculator : public QThread
00042 {
00043         Q_OBJECT
00044  
00045         public :
00046                 ImageCalculator(int nb, QImage *d, QRectF w, QSize r, fractale &f, bool type, long nbr, bool anim, QStringList &networkList);
00047                 ~ImageCalculator();
00048 
00049                 void run();
00050                 long maxValue;
00051 
00052                 long inline getMaxValue(){
00053                         return maxValue;
00054                 }
00055 
00059                 static long inline RGBAToInt(QRgb r){
00060                         int red = qRed(r);
00061                         int green = qGreen(r);
00062                         int blue = qBlue(r);
00063                         int alpha = 0;//255-qAlpha(r);
00064                         return (alpha << 24) + (red<<16) + (green<<8) + blue;
00065                 }
00066                 
00070                 static QRgb inline intToRGBA(long r){
00071                         int alpha = r >> 24;
00072                         r -= (alpha << 24);
00073                         int red = r >> 16;
00074                         r -= (red << 16);
00075                         int green = r >> 8;
00076                         r -= (green << 8);
00077                         int blue = r;
00078                         
00079                         return QColor(red, green, blue, 255-alpha).rgb();
00080                 }
00081 
00082                 signals:
00083                         void progress(int x);
00084                         void render();          
00085 
00086                 public slots :
00087                         void s_processing();
00088         private:
00089                 int nbThreads;
00090                 QImage *destination;
00091                 QRectF window;
00092                 QSize size;
00093                 fractale &frac;
00094                 bool animate;
00095                 bool shortcuts;
00096                 bool useRandomCalculation;
00097                 long nbRandom;
00098                 int lastProgression;
00099 
00100                 long nbProcessedRows;           // un simple compteur d'avancement
00101 
00102                 QMutex mutex;
00103                 QVector<QVector<long> > result;
00104                 QStringList &networkAdresses;
00105                 void sumImagesIntoDestination();
00106 
00107                 QVector<ImageTiler*> tilers;
00108                 QVector<NetworkImageTiler*> networkTilers;
00109 };
00110 
00111 #endif

Generated on Fri Feb 26 21:07:52 2010 for BuddhaBrot by  doxygen 1.4.6-NO