Login  Register

Re: Referencing Image from a PlugIn

Posted by perepujal on Oct 04, 2021; 10:23pm
URL: https://forum.librecad.org/Referencing-Image-from-a-PlugIn-tp5721100p5721107.html

Just an snippet from an old, unfinished and abandoned plugin I started long time ago.
HTH

void LC_ImageVec::execComm(Document_Interface *doc,
                             QWidget *parent, QString cmd)
{
    Q_UNUSED(cmd);
    Q_UNUSED(parent);
    QPointF base1;
    Plug_Entity *img = doc->getEnt("Select an image");
    if (img == NULL) return;
    QHash<int, QVariant> imgData;
    img->getData(&imgData);
    if (imgData.value(DPI::ETYPE) != DPI::IMAGE) return;
    QPointF bottomLeft, dir;
    bottomLeft.setX(imgData.value(DPI::STARTX).toDouble());
    bottomLeft.setY(imgData.value(DPI::STARTY).toDouble());
    pixelSize.setX(imgData.value(DPI::SIZEU).toDouble());
    pixelSize.setY(imgData.value(DPI::SIZEV).toDouble());
    dir.setX(imgData.value(DPI::ENDX).toDouble());
    dir.setY(imgData.value(DPI::ENDY).toDouble());
    QString name = imgData.value(DPI::BLKNAME).toString();

    QImage image;
    if ( !image.load (name) ) return;