Ejemplo n.º 1
0
RGBMap RGBText::rgbMap(const QSize& size, uint rgb, int step)
{
    if (animationStyle() == StaticLetters)
        return renderStaticLetters(size, rgb, step);
    else
        return renderScrollingText(size, rgb, step);
}
Ejemplo n.º 2
0
bool RGBImage::saveXML(QDomDocument* doc, QDomElement* mtx_root) const
{
    Q_ASSERT(doc != NULL);
    Q_ASSERT(mtx_root != NULL);

    QDomElement root = doc->createElement(KXMLQLCRGBAlgorithm);
    root.setAttribute(KXMLQLCRGBAlgorithmType, KXMLQLCRGBImage);
    mtx_root->appendChild(root);

    QDomElement filename = doc->createElement(KXMLQLCRGBImageFilename);
    QDomText filenameText =
       doc->createTextNode(this->doc()->normalizeComponentPath(m_filename));
    filename.appendChild(filenameText);
    root.appendChild(filename);

    QDomElement ani = doc->createElement(KXMLQLCRGBImageAnimationStyle);
    QDomText aniText = doc->createTextNode(animationStyleToString(animationStyle()));
    ani.appendChild(aniText);
    root.appendChild(ani);

    QDomElement offset = doc->createElement(KXMLQLCRGBImageOffset);
    offset.setAttribute(KXMLQLCRGBImageOffsetX, xOffset());
    offset.setAttribute(KXMLQLCRGBImageOffsetY, yOffset());
    root.appendChild(offset);

    return true;
}
Ejemplo n.º 3
0
int RGBText::rgbMapStepCount(const QSize& size)
{
    Q_UNUSED(size);
    if (animationStyle() == StaticLetters)
        return m_text.length();
    else
        return scrollingTextStepCount();
}
Ejemplo n.º 4
0
int RGBText::scrollingTextStepCount() const
{
    QFontMetrics fm(m_font);
    if (animationStyle() == Vertical)
        return m_text.length() * fm.ascent();
    else
        return fm.width(m_text);
}
Ejemplo n.º 5
0
RGBMap RGBImage::rgbMap(const QSize& size, uint rgb, int step)
{
    Q_UNUSED(rgb);

    QMutexLocker locker(&m_mutex);

    if (m_animatedSource == false && (m_image.width() == 0 || m_image.height() == 0))
        return RGBMap();

    int xOffs = xOffset();
    int yOffs = yOffset();

    switch(animationStyle()) 
    {
        default:
        case Static:
        break;
        case Horizontal:
            xOffs += step;
        break;
        case Vertical:
            yOffs += step;
        break;
        case Animation:
            xOffs += step * size.width();
        break;
    }

    if (m_animatedSource)
    {
        m_animatedPlayer.jumpToNextFrame();
        m_image = m_animatedPlayer.currentImage().scaled(size);
    }

    RGBMap map(size.height());
    for (int y = 0; y < size.height(); y++)
    {
        map[y].resize(size.width());
        for (int x = 0; x < size.width(); x++)
        {
            int x1 = (x + xOffs) % m_image.width();
            int y1 = (y + yOffs) % m_image.height();

            map[y][x] = m_image.pixel(x1,y1);
            if (qAlpha(map[y][x]) == 0)
                map[y][x] = 0;
        }
    }

    return map;
}
Ejemplo n.º 6
0
int RGBImage::rgbMapStepCount(const QSize& size)
{
    switch (animationStyle())
    {
    default:
    case Static:
        return 1;
    case Horizontal:
        return m_image.width();
    case Vertical:
        return m_image.height();
    case Animation:
        qDebug() << m_image.width() << " " << size.width() << " " << (m_image.width() / size.width());
        return MAX(1, m_image.width() / size.width());
    }
}
Ejemplo n.º 7
0
RGBMap RGBImage::rgbMap(const QSize& size, uint rgb, int step)
{
    Q_UNUSED(rgb);

    if (m_image.width() == 0 || m_image.height() == 0)
        return RGBMap();

    int xOffs = xOffset();
    int yOffs = yOffset();

    switch(animationStyle()) 
    {
    default:
    case Static:
        break;
    case Horizontal:
        xOffs += step;
        break;
    case Vertical:
        yOffs += step;
        break;
    case Animation:
        xOffs += step * size.width();
        break;
    }

    RGBMap map(size.height());
    for (int y = 0; y < size.height(); y++)
    {
        map[y].resize(size.width());
        for (int x = 0; x < size.width(); x++)
        {
            int x1 = (x + xOffs) % m_image.width();
            int y1 = (y + yOffs) % m_image.height();

            map[y][x] = m_image.pixel(x1,y1);
            if (qAlpha(map[y][x]) == 0)
                map[y][x] = 0;
        }
    }

    return map;
}
Ejemplo n.º 8
0
bool RGBImage::saveXML(QXmlStreamWriter *doc) const
{
    Q_ASSERT(doc != NULL);

    doc->writeStartElement(KXMLQLCRGBAlgorithm);
    doc->writeAttribute(KXMLQLCRGBAlgorithmType, KXMLQLCRGBImage);

    doc->writeTextElement(KXMLQLCRGBImageFilename, this->doc()->normalizeComponentPath(m_filename));

    doc->writeTextElement(KXMLQLCRGBImageAnimationStyle, animationStyleToString(animationStyle()));

    doc->writeStartElement(KXMLQLCRGBImageOffset);
    doc->writeAttribute(KXMLQLCRGBImageOffsetX, QString::number(xOffset()));
    doc->writeAttribute(KXMLQLCRGBImageOffsetY, QString::number(yOffset()));
    doc->writeEndElement();

    /* End the <Algorithm> tag */
    doc->writeEndElement();

    return true;
}