Changeset View
Changeset View
Standalone View
Standalone View
imagelib/effects/blitz.cpp
Context not available. | |||||
65 | #include "blitz.h" | 65 | #include "blitz.h" | ||
---|---|---|---|---|---|
66 | 66 | | |||
67 | #include <QColor> | 67 | #include <QColor> | ||
68 | #include <QtGlobal> | ||||
68 | #include <cmath> | 69 | #include <cmath> | ||
69 | 70 | | |||
71 | #if defined(Q_CC_CLANG) | ||||
72 | #define IGNORE_ALIGN(body) QT_WARNING_PUSH QT_WARNING_DISABLE_CLANG("-Wcast-align") body QT_WARNING_POP | ||||
73 | #else | ||||
74 | #define IGNORE_ALIGN(body) QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Wcast-align") body QT_WARNING_POP | ||||
75 | #endif | ||||
76 | | ||||
70 | #define M_SQ2PI 2.50662827463100024161235523934010416269302368164062 | 77 | #define M_SQ2PI 2.50662827463100024161235523934010416269302368164062 | ||
71 | #define M_EPSILON 1.0e-6 | 78 | #define M_EPSILON 1.0e-6 | ||
72 | 79 | | |||
Context not available. | |||||
149 | 156 | | |||
150 | // form histogram | 157 | // form histogram | ||
151 | memset(histogram, 0, 256*sizeof(HistogramListItem)); | 158 | memset(histogram, 0, 256*sizeof(HistogramListItem)); | ||
152 | dest = (QRgb *)img.bits(); | 159 | IGNORE_ALIGN(dest = (QRgb *)img.bits();) | ||
153 | 160 | | |||
154 | if(img.format() == QImage::Format_ARGB32_Premultiplied){ | 161 | if(img.format() == QImage::Format_ARGB32_Premultiplied){ | ||
155 | for(i=0; i < count; ++i, ++dest){ | 162 | for(i=0; i < count; ++i, ++dest){ | ||
Context not available. | |||||
198 | } | 205 | } | ||
199 | 206 | | |||
200 | // stretch the histogram and write | 207 | // stretch the histogram and write | ||
201 | dest = (QRgb *)img.bits(); | 208 | IGNORE_ALIGN(dest = (QRgb *)img.bits();) | ||
209 | | ||||
202 | if(img.format() == QImage::Format_ARGB32_Premultiplied){ | 210 | if(img.format() == QImage::Format_ARGB32_Premultiplied){ | ||
203 | for(i=0; i < count; ++i, ++dest){ | 211 | for(i=0; i < count; ++i, ++dest){ | ||
204 | pixel = convertFromPremult(*dest); | 212 | pixel = convertFromPremult(*dest); | ||
Context not available. | |||||
280 | mh = height - my; | 288 | mh = height - my; | ||
281 | } | 289 | } | ||
282 | 290 | | |||
283 | p1 = (QRgb*)buffer.scanLine(y); | 291 | IGNORE_ALIGN(p1 = (QRgb*)buffer.scanLine(y);) | ||
284 | 292 | | |||
285 | memset(as, 0, static_cast<unsigned int>(width) * sizeof(int)); | 293 | memset(as, 0, static_cast<unsigned int>(width) * sizeof(int)); | ||
286 | memset(rs, 0, static_cast<unsigned int>(width) * sizeof(int)); | 294 | memset(rs, 0, static_cast<unsigned int>(width) * sizeof(int)); | ||
Context not available. | |||||
292 | case QImage::Format_ARGB32_Premultiplied: { | 300 | case QImage::Format_ARGB32_Premultiplied: { | ||
293 | QRgb pixel; | 301 | QRgb pixel; | ||
294 | for (auto i = 0; i < mh; i++) { | 302 | for (auto i = 0; i < mh; i++) { | ||
295 | p2 = (QRgb *)img.scanLine(i + my); | 303 | IGNORE_ALIGN(p2 = (QRgb *)img.scanLine(i + my);) | ||
296 | for (auto j = 0; j < width; ++j) { | 304 | for (auto j = 0; j < width; ++j) { | ||
297 | p2++; | 305 | p2++; | ||
298 | pixel = convertFromPremult(*p2); | 306 | pixel = convertFromPremult(*p2); | ||
Context not available. | |||||
324 | 332 | | |||
325 | default: { | 333 | default: { | ||
326 | for (auto i = 0; i < mh; ++i) { | 334 | for (auto i = 0; i < mh; ++i) { | ||
327 | p2 = (QRgb *)img.scanLine(i + my); | 335 | IGNORE_ALIGN(p2 = (QRgb *)img.scanLine(i + my);) | ||
328 | for (auto j = 0; j < width; j++) { | 336 | for (auto j = 0; j < width; j++) { | ||
329 | p2++; | 337 | p2++; | ||
330 | as[j] += qAlpha(*p2); | 338 | as[j] += qAlpha(*p2); | ||
Context not available. | |||||
473 | 481 | | |||
474 | float r, g, b; | 482 | float r, g, b; | ||
475 | for(y=0; y < h; ++y){ | 483 | for(y=0; y < h; ++y){ | ||
476 | src = (QRgb *)img.scanLine(y); | 484 | IGNORE_ALIGN(src = (QRgb *)img.scanLine(y);) | ||
477 | dest = (QRgb *)buffer.scanLine(y); | 485 | IGNORE_ALIGN(dest = (QRgb *)buffer.scanLine(y);) | ||
478 | // Read in scanlines to pixel neighborhood. If the scanline is outside | 486 | // Read in scanlines to pixel neighborhood. If the scanline is outside | ||
479 | // the image use the top or bottom edge. | 487 | // the image use the top or bottom edge. | ||
480 | for(x=y-edge, i=0; x <= y+edge; ++i, ++x){ | 488 | for(x=y-edge, i=0; x <= y+edge; ++i, ++x){ | ||
481 | scanblock[i] = (QRgb *) | 489 | IGNORE_ALIGN(scanblock[i] = (QRgb *) | ||
482 | img.scanLine((x < 0) ? 0 : (x > h-1) ? h-1 : x); | 490 | img.scanLine((x < 0) ? 0 : (x > h-1) ? h-1 : x);) | ||
483 | } | 491 | } | ||
484 | // Now we are about to start processing scanlines. First handle the | 492 | // Now we are about to start processing scanlines. First handle the | ||
485 | // part where the pixel neighborhood extends off the left edge. | 493 | // part where the pixel neighborhood extends off the left edge. | ||
Context not available. | |||||
490 | s = scanblock[matrix_y]; | 498 | s = scanblock[matrix_y]; | ||
491 | matrix_x = -edge; | 499 | matrix_x = -edge; | ||
492 | while(x+matrix_x < 0){ | 500 | while(x+matrix_x < 0){ | ||
493 | CONVOLVE_ACC(*m, *s); | 501 | CONVOLVE_ACC(*m, *s) | ||
494 | ++matrix_x; ++m; | 502 | ++matrix_x; ++m; | ||
495 | } | 503 | } | ||
496 | while(matrix_x <= edge){ | 504 | while(matrix_x <= edge){ | ||
497 | CONVOLVE_ACC(*m, *s); | 505 | CONVOLVE_ACC(*m, *s) | ||
498 | ++matrix_x; ++m; ++s; | 506 | ++matrix_x; ++m; ++s; | ||
499 | } | 507 | } | ||
500 | } | 508 | } | ||
Context not available. | |||||
512 | for(matrix_y = 0; matrix_y < matrix_size; ++matrix_y){ | 520 | for(matrix_y = 0; matrix_y < matrix_size; ++matrix_y){ | ||
513 | s = scanblock[matrix_y] + (x-edge); | 521 | s = scanblock[matrix_y] + (x-edge); | ||
514 | for(matrix_x = -edge; matrix_x <= edge; ++matrix_x, ++m, ++s){ | 522 | for(matrix_x = -edge; matrix_x <= edge; ++matrix_x, ++m, ++s){ | ||
515 | CONVOLVE_ACC(*m, *s); | 523 | CONVOLVE_ACC(*m, *s) | ||
516 | } | 524 | } | ||
517 | } | 525 | } | ||
518 | r = r < 0.0f ? 0.0f : r > 255.0f ? 255.0f : r + 0.5f; | 526 | r = r < 0.0f ? 0.0f : r > 255.0f ? 255.0f : r + 0.5f; | ||
Context not available. | |||||
531 | s += x-edge; | 539 | s += x-edge; | ||
532 | matrix_x = -edge; | 540 | matrix_x = -edge; | ||
533 | while(x+matrix_x < w){ | 541 | while(x+matrix_x < w){ | ||
534 | CONVOLVE_ACC(*m, *s); | 542 | CONVOLVE_ACC(*m, *s) | ||
535 | ++matrix_x; | 543 | ++matrix_x; | ||
536 | ++m; | 544 | ++m; | ||
537 | ++s; | 545 | ++s; | ||
538 | } | 546 | } | ||
539 | --s; | 547 | --s; | ||
540 | while(matrix_x <= edge){ | 548 | while(matrix_x <= edge){ | ||
541 | CONVOLVE_ACC(*m, *s); | 549 | CONVOLVE_ACC(*m, *s) | ||
542 | ++matrix_x; | 550 | ++matrix_x; | ||
543 | ++m; | 551 | ++m; | ||
544 | } | 552 | } | ||
Context not available. | |||||
650 | 658 | | |||
651 | } | 659 | } | ||
652 | else{ | 660 | else{ | ||
653 | data = (unsigned int *)img.scanLine(0); | 661 | IGNORE_ALIGN(data = (unsigned int *)img.scanLine(0);) | ||
654 | end = data + (img.width()*img.height()); | 662 | end = data + (img.width()*img.height()); | ||
655 | } | 663 | } | ||
656 | 664 | | |||
Context not available. |