From fd9ad582983939741a4c4fa5f2707f29365d6c09 Mon Sep 17 00:00:00 2001 From: Maxime Curioni Date: Fri, 9 May 2008 23:06:28 +0000 Subject: soc-2008-mxcurioni: towards Freestyle compilation, removing Qt's QString and QImage dependencies. Up to this commit, the following directories compile well (and without any warning): system, image, geometry, graph, winged_edge, view_map, stroke. Modified code is commented by //soc and unused variables by //soc unused --- source/blender/freestyle/intern/stroke/Canvas.cpp | 81 ++++++++++++++++------- 1 file changed, 57 insertions(+), 24 deletions(-) (limited to 'source/blender/freestyle/intern/stroke/Canvas.cpp') diff --git a/source/blender/freestyle/intern/stroke/Canvas.cpp b/source/blender/freestyle/intern/stroke/Canvas.cpp index ecb76c4a015..7e63d964cb5 100755 --- a/source/blender/freestyle/intern/stroke/Canvas.cpp +++ b/source/blender/freestyle/intern/stroke/Canvas.cpp @@ -25,14 +25,19 @@ #include "../system/TimeStamp.h" #include "../system/PseudoNoise.h" #include "Canvas.h" -#include -#include #include "../image/Image.h" #include "../image/GaussianFilter.h" #include "../image/ImagePyramid.h" #include "../view_map/SteerableViewMap.h" #include "StyleModule.h" +//soc #include +//soc #include +#include +#include "IMB_imbuf.h" +#include "IMB_imbuf_types.h" +#include "intern/IMB_bmp.h" + using namespace std; LIB_STROKE_EXPORT @@ -326,21 +331,35 @@ void Canvas::loadMap(const char *iFileName, const char *iMapName, unsigned int i }else{ filePath = iFileName; } - QImage * qimg; - QImage newMap(filePath.c_str()); - if(newMap.isNull()){ - cout << "Could not load image file " << filePath << endl; - return; - } - qimg = &newMap; - + + //soc + // QImage *qimg; + // QImage newMap(filePath.c_str()); + // if(newMap.isNull()){ + // cout << "Could not load image file " << filePath << endl; + // return; + // } + // qimg = &newMap; + ImBuf *qimg = IMB_loadiffname(filePath.c_str(), 0);; + if( qimg == 0 ){ + cout << "Could not load image file " << filePath << endl; + return; + } + + // soc //resize - QImage scaledImg; - if((newMap.width()!=width()) || (newMap.height()!=height())){ - scaledImg = newMap.scaled(width(), height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); - qimg = &scaledImg; + // QImage scaledImg; + // if((newMap.width()!=width()) || (newMap.height()!=height())){ + // scaledImg = newMap.scaled(width(), height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + // qimg = &scaledImg; + // } + ImBuf *scaledImg; + if( ( qimg->x != width() ) || ( qimg->y != height() ) ){ + scaledImg = IMB_dupImBuf(qimg); + IMB_scaleImBuf(scaledImg, width(), height()); } + // deal with color image // if(newMap->depth() != 8){ // int w = newMap->width(); @@ -356,13 +375,17 @@ void Canvas::loadMap(const char *iFileName, const char *iMapName, unsigned int i // newMap = tmp; // } - unsigned x,y; - int w = qimg->width(); - int h = qimg->height(); + int x,y; + int w = qimg->x; + int h = qimg->y; +int rowbytes = w*4; GrayImage tmp(w,h); + char *pix; + for(y=0; ypixel(x,y));// /255.f; + pix = (char*)qimg->rect + y*rowbytes + x*4; + float c = (pix[0]*11 + pix[1]*16 + pix[2]*5)/32; tmp.setPixel(x,y,c); } } @@ -380,20 +403,30 @@ void Canvas::loadMap(const char *iFileName, const char *iMapName, unsigned int i GaussianPyramid *pyramid = new GaussianPyramid(tmp, iNbLevels, iSigma); int ow = pyramid->width(0); int oh = pyramid->height(0); - QString base(iMapName); - for(unsigned i=0; igetNumberOfLevels(); ++i){ + string base(iMapName); //soc + for(int i=0; igetNumberOfLevels(); ++i){ // save each image: // w = pyramid.width(i); // h = pyramid.height(i); - QImage qtmp(ow, oh, QImage::Format_RGB32); - //int k = (1<pixel(x,y,i);//255*pyramid->pixel(x,y,i); - qtmp.setPixel(x,y,qRgb(c,c,c)); + //soc qtmp.setPixel(x,y,qRgb(c,c,c)); + pix = (char*)qtmp->rect + y*rowbytes + x*4; + pix[0] = pix [1] = pix[2] = c; } } - qtmp.save(base+QString::number(i)+".bmp", "BMP"); + //soc qtmp.save(base+QString::number(i)+".bmp", "BMP"); + stringstream filename; + filename << base; + filename << i << ".bmp"; + imb_savebmp(qtmp, const_cast(filename.str().c_str()), 0); + } // QImage *qtmp = new QImage(w, h, 32); // for(y=0;y