! Creates BW image where pixels are on positions where any of the selected * colors were. Final image is also held in data member bwImage. \param[in] selectedColors Boolean array where true means color is selected and pixels of that color will be set to 1 in output image. \param[in] progressObserver Progress observer. */
| 479 | \param[in] progressObserver Progress observer. |
| 480 | */ |
| 481 | class BWMapper |
| 482 | { |
| 483 | const std::vector<bool>& selectedColors; |
| 484 | |
| 485 | public: |
| 486 | explicit BWMapper(const std::vector<bool>& sc) |
| 487 | : selectedColors(sc) |
| 488 | {} |
| 489 | |
| 490 | void operator()(const QImage& source_image, QImage& output_image, ProgressObserver& progressObserver) const |
| 491 | { |
| 492 | auto const width = source_image.width(); |
| 493 | auto const height = source_image.height(); |
| 494 | for (int y = 0; y < height; y++) |
| 495 | { |
| 496 | for (int x = 0; x < width; x++) |
| 497 | { |
| 498 | auto colorIndex = source_image.pixelIndex(x, y); |
| 499 | output_image.setPixel(x, y, selectedColors[colorIndex]); |
| 500 | } |
| 501 | progressObserver.setPercentage((100*y) / height); |
| 502 | } |
| 503 | } |
| 504 | |
| 505 | using concurrent_processing = HorizontalStripes; |
| 506 | }; |
| 507 | Q_STATIC_ASSERT((Concurrency::supported<BWMapper>::value)); |
| 508 | |
| 509 | QImage Vectorizer::getBWImage(std::vector<bool> selectedColors, |