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