MCPcopy Create free account
hub / github.com/OpenOrienteering/mapper / BWMapper

Class BWMapper

3rd-party/cove/libvectorizer/Vectorizer.cpp:481–506  ·  view source on GitHub ↗

! 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. */

Source from the content-addressed store, hash-verified

479 \param[in] progressObserver Progress observer.
480 */
481class BWMapper
482{
483 const std::vector<bool>& selectedColors;
484
485public:
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};
507Q_STATIC_ASSERT((Concurrency::supported<BWMapper>::value));
508
509QImage Vectorizer::getBWImage(std::vector<bool> selectedColors,

Callers 1

getBWImageMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected