266{
268
269 quint8 *buf[3];
270 quint8 **density;
271 quint8 **transition;
272
274
276
277 for (qint32 i = 0; i < 3; i++)
279
280 quint8* transition =
new quint8[
rect.width()];
281
284 if (
rect.height() > 1)
286 else
288
291
292 for (qint32 y = 1;
y <
rect.height();
y++) {
294 if (y + 1 <
rect.height())
296 else
300 }
301
302 for (qint32 i = 0; i < 3; i++)
304 delete[] transition;
305 return;
306 }
307
312
313 for (qint32 i = 0; i < 3; i++)
314 buf[i] =
new quint8[
rect.width()];
315
317 for (qint32 i = 0; i <
m_yRadius + 1; i++) {
321 }
322 quint8* out =
new quint8[
rect.width()];
323 density =
new quint8*[2 *
m_xRadius + 1];
325
329 density[-
x] = density[
x];
330 }
331
332
336 const qreal minRadius = maxRadius - 1.0;
337
339 double dist;
340 quint8 a;
341
343
345
346 if (dist > maxRadius) {
347 a = 0;
348 } else if (dist > minRadius) {
349 a = qRound((1.0 - dist + minRadius) * 255.0);
350 } else {
351 a = 255;
352 }
353
358 }
359 }
360
361 } else {
363 double tmpx, tmpy, dist;
364 quint8 a;
365
366 tmpx =
x > 0.0 ?
x - 0.5 : 0.0;
367
369 tmpy =
y > 0.0 ?
y - 0.5 : 0.0;
370
373
374 a = dist <= 1.0 ? 255 : 0;
375
380 }
381 }
382 }
383
385 memcpy(buf[1], buf[0],
rect.width());
386 if (
rect.height() > 1)
388 else
389 memcpy(buf[2], buf[1],
rect.width());
391
396 }
397 for (qint32 x = 0;
x <
rect.width();
x++) {
399 for (qint32 j = 1; j <
m_yRadius + 1; j++)
400 if (transition[j][x]) {
402 break;
403 }
404 }
405 for (qint32 y = 0;
y <
rect.height();
y++) {
411 } else
413
414 for (qint32 x = 0;
x <
rect.width();
x++) {
415 if (max[x] < 1) {
419 else
421 } else if (transition[-max[x]][x])
423 else if (transition[-max[x] + 1][x])
425 else
427 } else
431 }
432 quint8 last_max =
max[0][density[-1]];
433 qint32 last_index = 1;
434 for (qint32 x = 0 ;
x <
rect.width();
x++) {
435 last_index--;
436 if (last_index >= 0) {
437 last_max = 0;
439 if (max[x + i] <=
m_yRadius && max[x + i] >= -
m_yRadius && density[i][max[x+i]] > last_max) {
440 last_max = density[i][
max[
x + i]];
441 last_index = i;
442 }
444 } else {
445 last_max = 0;
447 if (max[x + i] <=
m_yRadius && max[x + i] >= -
m_yRadius && density[i][max[x + i]] > last_max) {
448 last_max = density[i][
max[
x + i]];
449 last_index = i;
450 }
452 }
453 if (last_max == 0) {
454 qint32 i;
455 for (i = x + 1; i <
rect.width(); i++) {
457 break;
458 }
461 out[x] = 0;
463 }
465 }
466 }
468 }
469 delete [] out;
470
471 for (qint32 i = 0; i < 3; i++)
472 delete[] buf[i];
473
476
477 for (qint32 i = 0; i <
m_yRadius + 1; i++) {
479 delete transition[i];
480 }
481 delete[] transition;
482
483 for (qint32 i = 0; i <
m_xRadius + 1 ; i++) {
485 delete density[i];
486 }
488 delete[] density;
489}
KisMagneticGraph::vertex_descriptor source(typename KisMagneticGraph::edge_descriptor e, KisMagneticGraph g)
void readBytes(quint8 *data, qint32 x, qint32 y, qint32 w, qint32 h) const
void writeBytes(const quint8 *data, qint32 x, qint32 y, qint32 w, qint32 h)
void rotatePointers(quint8 **p, quint32 n)
void computeTransition(quint8 *transition, quint8 **buf, qint32 width)
#define KIS_SAFE_ASSERT_RECOVER_NOOP(cond)
constexpr std::enable_if< sizeof...(values)==0, size_t >::type max()