78 for (mapsMap::iterator m =
_maps.begin(), mend =
_maps.end(); m != mend; ++m) {
123 for (deque<StrokeLayer *>::iterator sl =
_Layers.begin(), slend =
_Layers.end(); sl != slend;
154 for (deque<StrokeLayer *>::iterator sl =
_Layers.begin(), slend =
_Layers.end(); sl != slend;
211 for (deque<StrokeLayer *>::iterator sl =
_Layers.begin(), slend =
_Layers.end(); sl != slend;
269 for (uint i = 0; i < size; ++i) {
278 for (uint i =
index; i < size; ++i) {
301 _Layers[i]->RenderBasic(iRenderer);
305void Canvas::loadMap(
const char *iFileName,
const char *iMapName, uint iNbLevels,
float iSigma)
308 if (!
_maps.empty()) {
309 mapsMap::iterator m =
_maps.find(iMapName);
310 if (m !=
_maps.end()) {
325 filePath += iFileName;
328 filePath = iFileName;
333 QImage newMap(filePath.c_str());
334 if (newMap.isNull()) {
335 cerr <<
"Could not load image file " << filePath << endl;
343 if (qimg ==
nullptr) {
344 cerr <<
"Could not load image file " << filePath << endl;
351 if ((newMap.width() !=
width()) || (newMap.height() !=
height())) {
352 scaledImg = newMap.scaled(
width(),
height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
357 if ((qimg->x !=
width()) || (qimg->y !=
height())) {
358 scaledImg = IMB_dupImBuf(qimg);
364 if (newMap->depth() != 8) {
365 int w = newMap->width();
366 int h = newMap->height();
367 QImage *tmp =
new QImage(
w, h, 8);
368 for (uint
y = 0;
y < h; ++
y) {
369 for (uint
x = 0;
x <
w; ++
x) {
370 int c = qGray(newMap->pixel(
x,
y));
371 tmp->setPixel(
x,
y, c);
382 int rowbytes =
w * 4;
386 uchar *qimg_byte_data = qimg->byte_data_for_write();
387 for (
y = 0;
y < h; ++
y) {
388 for (
x = 0;
x <
w; ++
x) {
389 pix = qimg_byte_data +
y * rowbytes +
x * 4;
390 float c = (pix[0] * 11 + pix[1] * 16 + pix[2] * 5) / 32;
399 for (
y = 0;
y < h; ++
y) {
400 for (
x = 0;
x <
w; ++
x) {
408 int ow = pyramid->
width(0);
409 int oh = pyramid->
height(0);
410 string base(iMapName);
423 for (
y = 0;
y < oh; ++
y) {
424 for (
x = 0;
x < ow; ++
x) {
425 int c = pyramid->
pixel(
x,
y, i);
427 pix = qtmp_byte_data +
y * rowbytes +
x * 4;
428 pix[0] = pix[1] = pix[2] = c;
432 stringstream filepath;
434 filepath << i <<
".bmp";
440 QImage *qtmp =
new QImage(
w, h, 32);
441 for (
y = 0;
y < h; ++
y) {
442 for (
x = 0;
x <
w; ++
x) {
444 qtmp->setPixel(
x,
y, qRgb(c, c, c));
451 _maps[iMapName] = pyramid;
459 cout <<
"readMapPixel warning: no map was loaded " << endl;
463 mapsMap::iterator m =
_maps.find(iMapName);
464 if (m ==
_maps.end()) {
466 cout <<
"readMapPixel warning: no map was loaded with the name " << iMapName << endl;
471 if ((
x < 0) || (
x >= pyramid->
width()) || (
y < 0) || (
y >= pyramid->
height())) {
Class to define a canvas designed to draw style modules.
Configuration definitions.
Class to perform gaussian filtering operations on an image.
Class to represent a pyramid of images.
Class to encapsulate an array of RGB or Gray level values.
Class to define a pseudo Perlin noise.
Convenient access to the steerable ViewMap to which any element of the ViewMap belongs to.
Classes to render a stroke with OpenGL.
Class representing a style module.
Class defining a singleton used as timestamp.
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
void setVisible(uint index, bool iVisible)
std::deque< StrokeLayer * > _Layers
SteerableViewMap * _steerableViewMap
void setModified(uint index, bool iMod)
void causalStyleModules(std::vector< uint > &vec, uint index=0)
void RemoveStyleModule(uint index)
void InsertStyleModule(uint index, StyleModule *iStyleModule)
void SwapStyleModules(uint i1, uint i2)
float readMapPixel(const char *iMapName, int level, int x, int y)
virtual void Render(const StrokeRenderer *iRenderer)
void PushBackStyleModule(StyleModule *iStyleModule)
virtual void RenderBasic(const StrokeRenderer *iRenderer)
void loadMap(const char *iFileName, const char *iMapName, uint iNbLevels=4, float iSigma=1.0f)
virtual int height() const =0
StyleModule * _current_sm
virtual int width() const =0
void resetModified(bool iMod=false)
std::deque< StyleModule * > _StyleModules
void ReplaceStyleModule(uint index, StyleModule *iStyleModule)
static const int NB_STEERABLE_VIEWMAP
static const char * _MapsPath
StrokeRenderer * _Renderer
static Canvas * _pInstance
float getSmoothedPixel(Map *map, int x, int y)
GaussianPyramid(float iSigma=1.0f)
void setPixel(uint x, uint y, float v)
float pixel(uint x, uint y) const
virtual float pixel(int x, int y, int level=0)
int getNumberOfLevels() const
virtual int height(int level=0)
virtual int width(int level=0)
static void init(long seed)
SteerableViewMap(uint nbOrientations=4)
static TimeStamp * instance()
ImBuf * IMB_load_image_from_filepath(const char *filepath, ImBufFlags flags, ColorManagedColorspaceSettings *colorspace_settings=nullptr)
bool IMB_scale(ImBuf *ibuf, int2 new_size, IMBScaleFilter filter, bool threaded=true)
uint8_t * byte_data_for_write()