LCOV - code coverage report
Current view: top level - muse/framework/draw/internal - qimageprovider.cpp Coverage Total Hit
Test: filtered_coverage.info Lines: 20.0 % 25 5
Test Date: 2026-11-05 04:07:02

            Line data    Source code
       1              : #include "qimageprovider.h"
       2              : 
       3              : #include <QBuffer>
       4              : 
       5              : #include "qimagepainterprovider.h"
       6              : #include "types/pixmap.h"
       7              : 
       8              : #include "log.h"
       9              : 
      10              : using namespace muse::draw;
      11              : 
      12              : static const char FILE_FORMAT[] = "PNG";
      13              : 
      14           21 : std::shared_ptr<Pixmap> QImageProvider::createPixmap(const ByteArray& data) const
      15              : {
      16           21 :     QImage image;
      17           21 :     image.loadFromData(data.toQByteArrayNoCopy());
      18              : 
      19           42 :     return std::make_shared<Pixmap>(Pixmap::fromQPixmap(QPixmap::fromImage(image)));
      20           21 : }
      21              : 
      22            0 : std::shared_ptr<Pixmap> QImageProvider::createPixmap(int w, int h, int dpm, const Color& color) const
      23              : {
      24            0 :     QImage image(w, h, QImage::Format_ARGB32_Premultiplied);
      25            0 :     image.setDotsPerMeterX(dpm);
      26            0 :     image.setDotsPerMeterY(dpm);
      27            0 :     image.fill(color.toQColor());
      28              : 
      29            0 :     return std::make_shared<Pixmap>(Pixmap::fromQPixmap(QPixmap::fromImage(image)));
      30            0 : }
      31              : 
      32            0 : Pixmap QImageProvider::scaled(const Pixmap& origin, const Size& s) const
      33              : {
      34            0 :     QPixmap qtPixmap = Pixmap::toQPixmap(origin);
      35            0 :     qtPixmap = qtPixmap.scaled(s.width(), s.height());
      36              : 
      37            0 :     return Pixmap::fromQPixmap(qtPixmap);
      38            0 : }
      39              : 
      40            0 : std::shared_ptr<IPaintProvider> QImageProvider::painterForImage(std::shared_ptr<Pixmap> pixmap)
      41              : {
      42            0 :     return QImagePainterProvider::make(pixmap);
      43              : }
      44              : 
      45            0 : void QImageProvider::saveAsPng(std::shared_ptr<Pixmap> px, io::IODevice* device)
      46              : {
      47            0 :     QBuffer buf;
      48            0 :     buf.open(QIODevice::WriteOnly);
      49            0 :     Pixmap::toQPixmap(*px).save(&buf, FILE_FORMAT);
      50            0 :     device->write(buf.data());
      51            0 : }
        

Generated by: LCOV version 2.0-1