当前位置: 首页>>代码示例>>C++>>正文


C++ ImageAttributes::GetLastLineY方法代码示例

本文整理汇总了C++中ImageAttributes::GetLastLineY方法的典型用法代码示例。如果您正苦于以下问题:C++ ImageAttributes::GetLastLineY方法的具体用法?C++ ImageAttributes::GetLastLineY怎么用?C++ ImageAttributes::GetLastLineY使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ImageAttributes的用法示例。


在下文中一共展示了ImageAttributes::GetLastLineY方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ReadLineFromBottom

QString ImageReader::ReadLineFromBottom(const QImage& image, const ImageAttributes& imageAttributes, int lineCount, int lineIndex)
{
#ifdef CHARACTERGRID_DEBUG
    if (m_CharacterGrid.GetImage().size() != image.size() || lineIndex == 0)
    {
        m_CharacterGrid.GetImage() = QImage(image.size(), image.format());
    }
#endif // CHARACTERGRID_DEBUG

    const int lastLineY = imageAttributes.GetLastLineY() - lineIndex * imageAttributes.GetLineDistance() + imageAttributes.GetLineYOffset();
    if (lastLineY < 0 || lastLineY >= image.height())
    {
        // line position invalid, return
        return "";
    }

    Q_ASSERT(lineIndex >= 0 && lineIndex < lineCount);

    QString numbers;
    QRgb rgb = QColor(Qt::black).rgb();
    m_CharacterGrid.SetLowerRgbLimit(CHARACTERGRID_LOWER_RGB_LIMIT);
    int lastValidX = INT_MAX;
    int lastValidCharX = IMAGEATTRIBUTES_LINE_X_START;
    const int lineWidth = IMAGEATTRIBUTES_MAX_WIDTH;
    for (int x = IMAGEATTRIBUTES_LINE_X_START, y = lastLineY; x < lineWidth; ++x)
    {
        const int minValidX = x - imageAttributes.GetCharacterWidth() * 3;
        if (lastValidX < minValidX || lastValidCharX < minValidX)
        {
            // Line numbers all found, break
            break;
        }

        if (!CharacterGrid::IsDeviationTooLarge(image, rgb, x, y))
        {
            continue;
        }

        if (m_CharacterGrid.IsPartOfCharacter(image.pixel(x, y)))
        {
            lastValidCharX = x;
        }

        if (!m_CharacterGrid.IsPartOfNumber(image.pixel(x, y)))
        {
            continue;
        }

        m_CharacterGrid.FindNumber(image, x, y, imageAttributes);
        int offsetAdd = 0;
        if (m_CharacterGrid.GetXOffset() <= x - imageAttributes.GetCharacterWidth())
        {
            // Read more numbers at once, set offset to begin of last completely read number
            offsetAdd = (x - m_CharacterGrid.GetXOffset()) / imageAttributes.GetCharacterWidth() * imageAttributes.GetCharacterWidth();
        }

        const QString number = m_Pattern.ConvertCharGridToCharacter(m_CharacterGrid, imageAttributes, offsetAdd);
        if (number != "")
        {
            lastValidX = x;
            numbers += number;
            QRgb lastRgb = image.pixel(x, y);
            int lred = qRed(lastRgb);
            int lgreen = qGreen(lastRgb);
            int lblue = qBlue(lastRgb);

            // R238, G51, B51 (Krit)
            // R224, G129, B3 (Normal)
            // R208, G82, B209 (Condi)
            // R51, G204, B17 (Healing)

            if ((lred>150)&& (lgreen<60) && (lblue<60)) LastColor=1;
            if ((lred>100)&& (lgreen>70) && (lblue<40)) LastColor=2;
            if ((lred>100)&& (lgreen<80) && (lblue>100)) LastColor=3;
            if (((lred>90) && (lred<140)) && ((lgreen>90) && (lgreen<140)) && ((lblue>90) && (lblue<140))) LastColor=4;  //timestamp color
            if ((lred<60)&&(lred>40) && (lgreen>110) && (lblue>10) && (lblue<40)) LastColor=5;
            x = qMax(x, m_CharacterGrid.GetXOffset() + offsetAdd + imageAttributes.GetCharacterWidth() - 1);
        }
    }

#ifdef CHARACTERGRID_DEBUG
    m_CharacterGrid.GetImage().save("../Images/debugImage.png");
#endif // CHARACTERGRID_DEBUG

    return numbers;
}
开发者ID:Tyrox92,项目名称:Gw2SPECS,代码行数:86,代码来源:imagereader.cpp


注:本文中的ImageAttributes::GetLastLineY方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。