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


C++ qRgb函数代码示例

本文整理汇总了C++中qRgb函数的典型用法代码示例。如果您正苦于以下问题:C++ qRgb函数的具体用法?C++ qRgb怎么用?C++ qRgb使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: qRgb

void KviTalWizard::setCurrentPage(KviTalWizardPageData * pData)
{
    m_p->pCurrentPage = pData;

    bool bCancelEnabled = true;
    bool bNextEnabled = false;
    bool bBackEnabled = false;
    bool bHelpEnabled = false;
    bool bFinishEnabled = false;

    QString szTitle;
    QString szSteps;

    bool bHaveNextPage = false;
    bool bHavePrevPage = false;

    if(pData)
    {
        bHavePrevPage = m_p->findPrevEnabledPage(pData->pWidget);
        bHaveNextPage = m_p->findNextEnabledPage(pData->pWidget);

        bNextEnabled = (pData->iEnableFlags & KviTalWizardPageData::EnableNext) && bHaveNextPage;
        bBackEnabled = (pData->iEnableFlags & KviTalWizardPageData::EnableBack) && bHavePrevPage;

        bCancelEnabled = (pData->iEnableFlags & KviTalWizardPageData::EnableCancel);
        bFinishEnabled = (pData->iEnableFlags & KviTalWizardPageData::EnableFinish);

        bHelpEnabled = (pData->iEnableFlags & KviTalWizardPageData::EnableHelp);

        m_p->pWidgetStack->setCurrentWidget(pData->pWidget);

        szTitle = "<b>";
        szTitle += pData->szTitle;
        szTitle += "</b>";
        QPalette pal = m_p->pStepsLabel->palette();
        QColor clrWin = pal.color(QPalette::Normal, QPalette::Window);
        QColor clrTxt = pal.color(QPalette::Normal, QPalette::WindowText);
        QColor clrMid = qRgb(
                            (clrWin.red() + clrTxt.red()) / 2,
                            (clrWin.green() + clrTxt.green()) / 2,
                            (clrWin.blue() + clrTxt.blue()) / 2);

        szSteps = "<font color=\"";
        szSteps += clrMid.name();
        szSteps += "\"><b>[";
        szSteps += QString("Step %1 of %2").arg(pData->iVisibleIndex).arg(m_p->iEnabledPageCount);
        szSteps += "]</b></font>";
    }

    m_p->pTitleLabel->setText(szTitle);
    m_p->pStepsLabel->setText(szSteps);

    m_p->pNextButton->setEnabled(bNextEnabled);
    if(bHaveNextPage)
    {
        m_p->pNextButton->show();
        m_p->pNextSpacer->show();
        m_p->pNextButton->setDefault(true);
    }
    else
    {
        m_p->pNextButton->hide();
        m_p->pNextSpacer->hide();
        m_p->pNextButton->setDefault(false);
    }

    m_p->pBackButton->setEnabled(bBackEnabled);
    if(bHavePrevPage)
        m_p->pBackButton->show();
    else
        m_p->pBackButton->hide();

    m_p->pHelpButton->setEnabled(bHelpEnabled);
    if(bHelpEnabled)
        m_p->pHelpButton->show();
    else
        m_p->pHelpButton->hide();

    m_p->pCancelButton->setEnabled(bCancelEnabled);
    m_p->pFinishButton->setEnabled(bFinishEnabled);

    if(bFinishEnabled)
    {
        m_p->pFinishButton->show();
        m_p->pFinishSpacer->show();
        m_p->pFinishButton->setDefault(true);
    }
    else
    {
        m_p->pFinishButton->hide();
        m_p->pFinishSpacer->hide();
        m_p->pFinishButton->setDefault(false);
    }
}
开发者ID:kvirc,项目名称:KVIrc,代码行数:94,代码来源:KviTalWizard.cpp

示例2: setup_qt

static
void setup_qt(QImage& image, png_structp png_ptr, png_infop info_ptr, QSize scaledSize, bool *doScaledRead, float screen_gamma=0.0)
{
    if (screen_gamma != 0.0 && png_get_valid(png_ptr, info_ptr, PNG_INFO_gAMA)) {
        double file_gamma;
        png_get_gAMA(png_ptr, info_ptr, &file_gamma);
        png_set_gamma(png_ptr, screen_gamma, file_gamma);
    }

    png_uint_32 width;
    png_uint_32 height;
    int bit_depth;
    int color_type;
    png_bytep trans_alpha = 0;
    png_color_16p trans_color_p = 0;
    int num_trans;
    png_colorp palette = 0;
    int num_palette;
    int interlace_method;
    png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, &interlace_method, 0, 0);
    png_set_interlace_handling(png_ptr);

    if (color_type == PNG_COLOR_TYPE_GRAY) {
        // Black & White or 8-bit grayscale
        if (bit_depth == 1 && png_get_channels(png_ptr, info_ptr) == 1) {
            png_set_invert_mono(png_ptr);
            png_read_update_info(png_ptr, info_ptr);
            if (image.size() != QSize(width, height) || image.format() != QImage::Format_Mono) {
                image = QImage(width, height, QImage::Format_Mono);
                if (image.isNull())
                    return;
            }
            image.setColorCount(2);
            image.setColor(1, qRgb(0,0,0));
            image.setColor(0, qRgb(255,255,255));
        } else if (bit_depth == 16 && png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) {
            png_set_expand(png_ptr);
            png_set_strip_16(png_ptr);
            png_set_gray_to_rgb(png_ptr);
            if (image.size() != QSize(width, height) || image.format() != QImage::Format_ARGB32) {
                image = QImage(width, height, QImage::Format_ARGB32);
                if (image.isNull())
                    return;
            }
            if (QSysInfo::ByteOrder == QSysInfo::BigEndian)
                png_set_swap_alpha(png_ptr);

            png_read_update_info(png_ptr, info_ptr);
        } else {
            if (bit_depth == 16)
                png_set_strip_16(png_ptr);
            else if (bit_depth < 8)
                png_set_packing(png_ptr);
            int ncols = bit_depth < 8 ? 1 << bit_depth : 256;
            png_read_update_info(png_ptr, info_ptr);
            if (image.size() != QSize(width, height) || image.format() != QImage::Format_Indexed8) {
                image = QImage(width, height, QImage::Format_Indexed8);
                if (image.isNull())
                    return;
            }
            image.setColorCount(ncols);
            for (int i=0; i<ncols; i++) {
                int c = i*255/(ncols-1);
                image.setColor(i, qRgba(c,c,c,0xff));
            }
            if (png_get_tRNS(png_ptr, info_ptr, &trans_alpha, &num_trans, &trans_color_p) && trans_color_p) {
                const int g = trans_color_p->gray;
                if (g < ncols) {
                    image.setColor(g, 0);
                }
            }
        }
    } else if (color_type == PNG_COLOR_TYPE_PALETTE
               && png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette)
               && num_palette <= 256)
    {
        // 1-bit and 8-bit color
        if (bit_depth != 1)
            png_set_packing(png_ptr);
        png_read_update_info(png_ptr, info_ptr);
        png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, 0, 0, 0);
        QImage::Format format = bit_depth == 1 ? QImage::Format_Mono : QImage::Format_Indexed8;
        if (image.size() != QSize(width, height) || image.format() != format) {
            image = QImage(width, height, format);
            if (image.isNull())
                return;
        }
        png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette);
        image.setColorCount(num_palette);
        int i = 0;
        if (png_get_tRNS(png_ptr, info_ptr, &trans_alpha, &num_trans, &trans_color_p) && trans_alpha) {
            while (i < num_trans) {
                image.setColor(i, qRgba(
                    palette[i].red,
                    palette[i].green,
                    palette[i].blue,
                    trans_alpha[i]
                   )
               );
                i++;
//.........这里部分代码省略.........
开发者ID:ghjinlei,项目名称:qt5,代码行数:101,代码来源:qpnghandler.cpp

示例3: map

 QRgb map(QRgb pixel, QPoint) const {
     return qRgb(colorBound((int) qRed(pixel) * (m_avg[0] / m_avg[1])),
                 colorBound((int) qGreen(pixel) * (m_avg[0] / m_avg[2])),
                 colorBound((int) qBlue(pixel) * (m_avg[0] / m_avg[3])));
 }
开发者ID:govorovsky,项目名称:cmc-eye,代码行数:5,代码来源:document.cpp

示例4: arraysize

                                                             << "performer"
                                                             << "grouping"
                                                             << "lyrics"
                                                             << "originalyear";

// From http://en.wikipedia.org/wiki/8.3_filename#Directory_table
const char OrganiseFormat::kInvalidFatCharacters[] = "\"*/\\:<>?|";
const int OrganiseFormat::kInvalidFatCharactersCount =
    arraysize(OrganiseFormat::kInvalidFatCharacters) - 1;

const char OrganiseFormat::kInvalidPrefixCharacters[] = ".";
const int OrganiseFormat::kInvalidPrefixCharactersCount =
    arraysize(OrganiseFormat::kInvalidPrefixCharacters) - 1;

const QRgb OrganiseFormat::SyntaxHighlighter::kValidTagColorLight =
    qRgb(64, 64, 255);
const QRgb OrganiseFormat::SyntaxHighlighter::kInvalidTagColorLight =
    qRgb(255, 64, 64);
const QRgb OrganiseFormat::SyntaxHighlighter::kBlockColorLight =
    qRgb(230, 230, 230);

const QRgb OrganiseFormat::SyntaxHighlighter::kValidTagColorDark =
    qRgb(128, 128, 255);
const QRgb OrganiseFormat::SyntaxHighlighter::kInvalidTagColorDark =
    qRgb(255, 128, 128);
const QRgb OrganiseFormat::SyntaxHighlighter::kBlockColorDark =
    qRgb(64, 64, 64);

OrganiseFormat::OrganiseFormat(const QString& format)
    : format_(format),
      replace_non_ascii_(false),
开发者ID:Atrament666,项目名称:Clementine,代码行数:31,代码来源:organiseformat.cpp

示例5: qRgb

#include "qicnshandler_p.h"

#include <QtCore/qmath.h>
#include <QtCore/qendian.h>
#include <QtCore/qregularexpression.h>
#include <QtCore/qbuffer.h>
#include <QtGui/qimage.h>

#ifndef QT_NO_DATASTREAM

QT_BEGIN_NAMESPACE

static const quint8 ICNSBlockHeaderSize = 8;

static const QRgb ICNSColorTableMono[] = {
    qRgb(0xFF, 0xFF, 0xFF),
    qRgb(0x00, 0x00, 0x00)
};
Q_STATIC_ASSERT(sizeof(ICNSColorTableMono) / sizeof(ICNSColorTableMono[0]) == (1 << ICNSEntry::DepthMono));

static const QRgb ICNSColorTable4bit[] = {
    qRgb(0xFF, 0xFF, 0xFF),
    qRgb(0xFC, 0xF3, 0x05),
    qRgb(0xFF, 0x64, 0x02),
    qRgb(0xDD, 0x08, 0x06),
    qRgb(0xF2, 0x08, 0x84),
    qRgb(0x46, 0x00, 0xA5),
    qRgb(0x00, 0x00, 0xD4),
    qRgb(0x02, 0xAB, 0xEA),
    qRgb(0x1F, 0xB7, 0x14),
    qRgb(0x00, 0x64, 0x11),
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:31,代码来源:qicnshandler.cpp

示例6: QImage

void Image::resizeImage(const int rate) {
	float r = rate / 100.;
	float w = tempImg->width() * r;
	float h = tempImg->height() * r;
	float x, y;
	float ax, ay, bx, by, cx, cy, dx, dy;
	float ar, ag, ab, br, bg, bb, cr, cg, cb, dr, dg, db;
	float er, eg, eb, fr, fg, fb;
	QRgb rgb;

	QImage* newImage = new QImage(w, h, tempImg->format());
	for (int i = 0; i < (int)w; ++i)
		for (int j = 0; j < (int)h; ++j) {
			x = (float)i / r;
			y = (float)j / r;

			// to avoid that x and y excceed the range of the 
			// two-dimension vector.
			if ((float)tempImg->width() - x < 2)
				x = tempImg->width() - 2;
			if ((float)tempImg->height() - y < 2)
				y = tempImg->height() - 2;

			ax = x, ay = y;
			bx = x + 1; by = y;
			cx = x, cy = y + 1;
			dx = x + 1, dy = y + 1;
			
			rgb = tempImg->pixel(ax, ay);
			ar = qRed(rgb);	
			ag = qGreen(rgb);	
			ab = qBlue(rgb);	
	
			rgb = tempImg->pixel(bx, by);
			br = qRed(rgb);	  	
			bg = qGreen(rgb);	 	
			bb = qBlue(rgb);	 	

			rgb = tempImg->pixel(cx, cy);
			cr = qRed(rgb);	  	
			cg = qGreen(rgb);	 	
			cb = qBlue(rgb);	 	
	
			rgb = tempImg->pixel(dx, dy);
			dr = qRed(rgb);	  	
			dg = qGreen(rgb);	 	
			db = qBlue(rgb);	 	

			er = ar + (br - ar) * (x - ax);
			fr = cr + (dr - cr) * (x - cx);
			int R = (int)(er + (fr - er) * (y - ay));

			eg = ag + (bg - ag) * (x - ax);
			fg = cg + (dg - cg) * (x - cx);
			int G = (int)(eg + (fg - eg) * (y - ay));

			eb = ab + (bb - ab) * (x - ax);
			fb = cb + (db - cb) * (x - cx);
			int B = (int)(eb + (fb - eb) * (y - ay));

			newImage->setPixel(i, j, qRgb(R, G, B));
		}
	img = newImage;
	getHistogram();
	update();
}
开发者ID:Aquietzero,项目名称:Graphic-Processor,代码行数:66,代码来源:resize.cpp

示例7: qRgba

void tst_QColor::setRgb()
{
    QColor color;

    for (int A = 0; A <= USHRT_MAX; ++A) {
        {
            // 0-255
            int a = A >> 8;
            QRgb rgb = qRgba(0, 0, 0, a);

            color.setRgb(0, 0, 0, a);
            QCOMPARE(color.alpha(), a);
            QCOMPARE(color.rgb(),  qRgb(0, 0, 0));

            color.setRgb(rgb);
            QCOMPARE(color.alpha(), 255);
            QCOMPARE(color.rgb(),   qRgb(0, 0, 0));

            int r, g, b, a2;
            color.setRgb(0, 0, 0, a);
            color.getRgb(&r, &g, &b, &a2);
            QCOMPARE(a2, a);

            QColor c(0, 0, 0);
            c.setAlpha(a);
            QCOMPARE(c.alpha(), a);
        }

        {
            // 0.0-1.0
            qreal a = A / qreal(USHRT_MAX);
            color.setRgbF(0.0, 0.0, 0.0, a);
            QCOMPARE(color.alphaF(), a);

            qreal r, g, b, a2;
            color.getRgbF(&r, &g, &b, &a2);
            QCOMPARE(a2, a);

            QColor c(0, 0, 0);
            c.setAlphaF(a);

            QCOMPARE(c.alphaF(), a);
        }
    }

    for (int R = 0; R <= USHRT_MAX; ++R) {
        {
            // 0-255
            int r = R >> 8;
            QRgb rgb = qRgb(r, 0, 0);

            color.setRgb(r, 0, 0);
            QCOMPARE(color.red(), r);
            QCOMPARE(color.rgb(), rgb);

            color.setRgb(rgb);
            QCOMPARE(color.red(), r);
            QCOMPARE(color.rgb(), rgb);

            int r2, g, b, a;
            color.getRgb(&r2, &g, &b, &a);
            QCOMPARE(r2, r);
        }

        {
            // 0.0-1.0
            qreal r = R / qreal(USHRT_MAX);
            color.setRgbF(r, 0.0, 0.0);
            QCOMPARE(color.redF(), r);

            qreal r2, g, b, a;
            color.getRgbF(&r2, &g, &b, &a);
            QCOMPARE(r2, r);
        }
    }

    for (int G = 0; G <= USHRT_MAX; ++G) {
        {
            // 0-255
            int g = G >> 8;
            QRgb rgb = qRgb(0, g, 0);

            color.setRgb(0, g, 0);
            QCOMPARE(color.green(), g);
            QCOMPARE(color.rgb(),   rgb);

            color.setRgb(rgb);
            QCOMPARE(color.green(), g);
            QCOMPARE(color.rgb(),   rgb);

            int r, g2, b, a;
            color.getRgb(&r, &g2, &b, &a);
            QCOMPARE(g2, g);
        }

        {
            // 0.0-1.0
            qreal g = G / qreal(USHRT_MAX);
            color.setRgbF(0.0, g, 0.0);
            QCOMPARE(color.greenF(), g);
//.........这里部分代码省略.........
开发者ID:SfietKonstantin,项目名称:radeon-qt5-qtbase-kms,代码行数:101,代码来源:tst_qcolor.cpp

示例8: QCOMPARE

// Testing get/set functions
void tst_QColor::getSetCheck()
{
    QColor obj1;
    // int QColor::alpha()
    // void QColor::setAlpha(int)
    obj1.setAlpha(0);
    QCOMPARE(obj1.alpha(), 0);
    obj1.setAlpha(-1);
    QCOMPARE(obj1.alpha(), 0); // range<0, 255>
    obj1.setAlpha(INT_MIN);
    QCOMPARE(obj1.alpha(), 0); // range<0, 255>
    obj1.setAlpha(255);
    QCOMPARE(obj1.alpha(), 255); // range<0, 255>
    obj1.setAlpha(INT_MAX);
    QCOMPARE(obj1.alpha(), 255); // range<0, 255>

    // qreal QColor::alphaF()
    // void QColor::setAlphaF(qreal)
    obj1.setAlphaF(0.0);
    QCOMPARE(obj1.alphaF(), qreal(0.0)); // range<0.0, 1.0>
    obj1.setAlphaF(-0.2);
    QCOMPARE(obj1.alphaF(), qreal(0.0)); // range<0.0, 1.0>
    obj1.setAlphaF(1.0);
    QCOMPARE(obj1.alphaF(), qreal(1.0)); // range<0.0, 1.0>
    obj1.setAlphaF(1.1);
    QCOMPARE(obj1.alphaF(), qreal(1.0)); // range<0.0, 1.0>

    // int QColor::red()
    // void QColor::setRed(int)
    obj1.setRed(0);
    QCOMPARE(obj1.red(), 0);
    obj1.setRed(-1);
    QCOMPARE(obj1.red(), 0); // range<0, 255>
    obj1.setRed(INT_MIN);
    QCOMPARE(obj1.red(), 0); // range<0, 255>
    obj1.setRed(255);
    QCOMPARE(obj1.red(), 255); // range<0, 255>
    obj1.setRed(INT_MAX);
    QCOMPARE(obj1.red(), 255); // range<0, 255>

    // int QColor::green()
    // void QColor::setGreen(int)
    obj1.setGreen(0);
    QCOMPARE(obj1.green(), 0);
    obj1.setGreen(-1);
    QCOMPARE(obj1.green(), 0); // range<0, 255>
    obj1.setGreen(INT_MIN);
    QCOMPARE(obj1.green(), 0); // range<0, 255>
    obj1.setGreen(255);
    QCOMPARE(obj1.green(), 255); // range<0, 255>
    obj1.setGreen(INT_MAX);
    QCOMPARE(obj1.green(), 255); // range<0, 255>

    // int QColor::blue()
    // void QColor::setBlue(int)
    obj1.setBlue(0);
    QCOMPARE(obj1.blue(), 0);
    obj1.setBlue(-1);
    QCOMPARE(obj1.blue(), 0); // range<0, 255>
    obj1.setBlue(INT_MIN);
    QCOMPARE(obj1.blue(), 0); // range<0, 255>
    obj1.setBlue(255);
    QCOMPARE(obj1.blue(), 255); // range<0, 255>
    obj1.setBlue(INT_MAX);
    QCOMPARE(obj1.blue(), 255); // range<0, 255>

    // qreal QColor::redF()
    // void QColor::setRedF(qreal)
    obj1.setRedF(0.0);
    QCOMPARE(obj1.redF(), qreal(0.0));
    obj1.setRedF(-0.2);
    QCOMPARE(obj1.redF(), qreal(0.0)); // range<0.0, 1.0
    obj1.setRedF(1.1);
    QCOMPARE(obj1.redF(), qreal(1.0)); // range<0.0, 1.0

    // qreal QColor::greenF()
    // void QColor::setGreenF(qreal)
    obj1.setGreenF(0.0);
    QCOMPARE(obj1.greenF(), qreal(0.0));
    obj1.setGreenF(-0.2);
    QCOMPARE(obj1.greenF(), qreal(0.0)); // range<0.0, 1.0
    obj1.setGreenF(1.1);
    QCOMPARE(obj1.greenF(), qreal(1.0)); // range<0.0, 1.0

    // qreal QColor::blueF()
    // void QColor::setBlueF(qreal)
    obj1.setBlueF(0.0);
    QCOMPARE(obj1.blueF(), qreal(0.0));
    obj1.setBlueF(-0.2);
    QCOMPARE(obj1.blueF(), qreal(0.0)); // range<0.0, 1.0
    obj1.setBlueF(1.1);
    QCOMPARE(obj1.blueF(), qreal(1.0)); // range<0.0, 1.0

    // QRgb QColor::rgba()
    // void QColor::setRgba(QRgb)
    QRgb var9(qRgba(10, 20, 30, 40));
    obj1.setRgba(var9);
    QCOMPARE(obj1.rgba(), var9);
    obj1.setRgba(QRgb(0));
//.........这里部分代码省略.........
开发者ID:SfietKonstantin,项目名称:radeon-qt5-qtbase-kms,代码行数:101,代码来源:tst_qcolor.cpp

示例9: defined

void tst_QColor::setallowX11ColorNames()
{
#if defined(Q_OS_IRIX)
    QSKIP("This fails due to the gamma settings in the SGI X server");
#endif
    RGBData x11RgbTbl[] = {
        // a few standard X11 color names
        { "DodgerBlue1", qRgb(30, 144, 255) },
        { "DodgerBlue2", qRgb(28, 134, 238) },
        { "DodgerBlue3", qRgb(24, 116, 205) },
        { "DodgerBlue4", qRgb(16, 78, 139) },
        { "SteelBlue1", qRgb(99, 184, 255) },
        { "SteelBlue2", qRgb(92, 172, 238) },
        { "SteelBlue3", qRgb(79, 148, 205) },
        { "SteelBlue4", qRgb(54, 100, 139) },
        { "DeepSkyBlue1", qRgb(0, 191, 255) },
        { "DeepSkyBlue2", qRgb(0, 178, 238) },
        { "DeepSkyBlue3", qRgb(0, 154, 205) },
        { "DeepSkyBlue4", qRgb(0, 104, 139) },
        { "SkyBlue1", qRgb(135, 206, 255) },
        { "SkyBlue2", qRgb(126, 192, 238) },
        { "SkyBlue3", qRgb(108, 166, 205) },
        { "SkyBlue4", qRgb(74, 112, 139) }
    };
    static const int x11RgbTblSize = sizeof(x11RgbTbl) / sizeof(RGBData);

    // X11 color names should not work by default
    QVERIFY(!QColor::allowX11ColorNames());
    for (int i = 0; i < x11RgbTblSize; ++i) {
        QString colorName = QLatin1String(x11RgbTbl[i].name);
        QColor color;
        color.setNamedColor(colorName);
        QVERIFY(!color.isValid());
    }

    // enable X11 color names
    QColor::setAllowX11ColorNames(true);
    QVERIFY(QColor::allowX11ColorNames());
    for (int i = 0; i < x11RgbTblSize; ++i) {
        QString colorName = QLatin1String(x11RgbTbl[i].name);
        QColor color;
        color.setNamedColor(colorName);
        QColor expected(x11RgbTbl[i].value);
        QCOMPARE(color, expected);
    }

    // should be able to turn off X11 color names
    QColor::setAllowX11ColorNames(false);
    QVERIFY(!QColor::allowX11ColorNames());
    for (int i = 0; i < x11RgbTblSize; ++i) {
        QString colorName = QLatin1String(x11RgbTbl[i].name);
        QColor color;
        color.setNamedColor(colorName);
        QVERIFY(!color.isValid());
    }
}
开发者ID:SfietKonstantin,项目名称:radeon-qt5-qtbase-kms,代码行数:56,代码来源:tst_qcolor.cpp

示例10: qDebug

bool QgsRenderChecker::compareImages( QString theTestName,
                                      unsigned int theMismatchCount,
                                      QString theRenderedImageFile )
{
  if ( mExpectedImageFile.isEmpty() )
  {
    qDebug( "QgsRenderChecker::runTest failed - Expected Image (control) File not set." );
    mReport = "<table>"
              "<tr><td>Test Result:</td><td>Expected Result:</td></tr>\n"
              "<tr><td>Nothing rendered</td>\n<td>Failed because Expected "
              "Image File not set.</td></tr></table>\n";
    return false;
  }
  if ( ! theRenderedImageFile.isEmpty() )
  {
    mRenderedImageFile = theRenderedImageFile;
  }
  if ( mRenderedImageFile.isEmpty() )
  {
    qDebug( "QgsRenderChecker::runTest failed - Rendered Image File not set." );
    mReport = "<table>"
              "<tr><td>Test Result:</td><td>Expected Result:</td></tr>\n"
              "<tr><td>Nothing rendered</td>\n<td>Failed because Rendered "
              "Image File not set.</td></tr></table>\n";
    return false;
  }
  //
  // Load /create the images
  //
  QImage myExpectedImage( mExpectedImageFile );
  QImage myResultImage( mRenderedImageFile );
  QImage myDifferenceImage( myExpectedImage.width(),
                            myExpectedImage.height(),
                            QImage::Format_RGB32 );
  QString myDiffImageFile = QDir::tempPath() + QDir::separator() +
                            QDir::separator()  +
                            theTestName + "_result_diff.png";
  myDifferenceImage.fill( qRgb( 152, 219, 249 ) );

  //
  // Set pixel count score and target
  //
  mMatchTarget = myExpectedImage.width() * myExpectedImage.height();
  unsigned int myPixelCount = myResultImage.width() * myResultImage.height();
  //
  // Set the report with the result
  //
  mReport = "<table>";
  mReport += "<tr><td colspan=2>";
  mReport += "Test image and result image for " + theTestName + "<br>"
             "Expected size: " + QString::number( myExpectedImage.width() ).toLocal8Bit() + "w x " +
             QString::number( myExpectedImage.height() ).toLocal8Bit() + "h (" +
             QString::number( mMatchTarget ).toLocal8Bit() + " pixels)<br>"
             "Actual   size: " + QString::number( myResultImage.width() ).toLocal8Bit() + "w x " +
             QString::number( myResultImage.height() ).toLocal8Bit() + "h (" +
             QString::number( myPixelCount ).toLocal8Bit() + " pixels)";
  mReport += "</td></tr>";
  mReport += "<tr><td colspan = 2>\n";
  mReport += "Expected Duration : <= " + QString::number( mElapsedTimeTarget ) +
             "ms (0 indicates not specified)<br>";
  mReport += "Actual Duration :  " + QString::number( mElapsedTime ) + "ms<br>";

  // limit image size in page to something reasonable
  int imgWidth = 420;
  int imgHeight = 280;
  if ( ! myExpectedImage.isNull() )
  {
    imgWidth = qMin( myExpectedImage.width(), imgWidth );
    imgHeight = myExpectedImage.height() * imgWidth / myExpectedImage.width();
  }
  QString myImagesString = "</td></tr>"
                           "<tr><td>Test Result:</td><td>Expected Result:</td><td>Difference (all blue is good, any red is bad)</td></tr>\n"
                           "<tr><td><img width=" + QString::number( imgWidth ) +
                           " height=" + QString::number( imgHeight ) +
                           " src=\"file://" +
                           mRenderedImageFile +
                           "\"></td>\n<td><img width=" + QString::number( imgWidth ) +
                           " height=" + QString::number( imgHeight ) +
                           " src=\"file://" +
                           mExpectedImageFile +
                           "\"></td>\n<td><img width=" + QString::number( imgWidth ) +
                           " height=" + QString::number( imgHeight ) +
                           " src=\"file://" +
                           myDiffImageFile  +
                           "\"></td>\n</tr>\n</table>";
  //
  // To get the images into CDash
  //
  QString myDashMessage = "<DartMeasurementFile name=\"Rendered Image " + theTestName + "\""
                          " type=\"image/png\">" + mRenderedImageFile +
                          "</DartMeasurementFile>\n"
                          "<DartMeasurementFile name=\"Expected Image " + theTestName + "\" type=\"image/png\">" +
                          mExpectedImageFile + "</DartMeasurementFile>\n"
                          "<DartMeasurementFile name=\"Difference Image " + theTestName + "\" type=\"image/png\">" +
                          myDiffImageFile + "</DartMeasurementFile>\n";
  qDebug( ) << myDashMessage;

  //
  // Put the same info to debug too
  //
//.........这里部分代码省略.........
开发者ID:AaronGaim,项目名称:QGIS,代码行数:101,代码来源:qgsrenderchecker.cpp

示例11: ttyRegExp


//.........这里部分代码省略.........
    QRegExp mmWidthRx(QLatin1String("mmWidth=?(\\d+)"));
    int dimIdxW = displayArgs.indexOf(mmWidthRx);
    QRegExp mmHeightRx(QLatin1String("mmHeight=?(\\d+)"));
    int dimIdxH = displayArgs.indexOf(mmHeightRx);
    if (dimIdxW >= 0) {
        mmWidthRx.exactMatch(displayArgs.at(dimIdxW));
        physWidth = mmWidthRx.cap(1).toInt();
        if (dimIdxH < 0)
            physHeight = dh*physWidth/dw;
    }
    if (dimIdxH >= 0) {
        mmHeightRx.exactMatch(displayArgs.at(dimIdxH));
        physHeight = mmHeightRx.cap(1).toInt();
        if (dimIdxW < 0)
            physWidth = dw*physHeight/dh;
    }
    if (dimIdxW < 0 && dimIdxH < 0) {
        if (vinfo.width != 0 && vinfo.height != 0
            && vinfo.width != UINT_MAX && vinfo.height != UINT_MAX) {
            physWidth = vinfo.width;
            physHeight = vinfo.height;
        } else {
            const int dpi = 72;
            physWidth = qRound(dw * 25.4 / dpi);
            physHeight = qRound(dh * 25.4 / dpi);
        }
    }

    dataoffset = yoff * lstep + xoff * d / 8;
    //qDebug("Using %dx%dx%d screen",w,h,d);

    /* Figure out the size of the screen in bytes */
    size = h * lstep;

    mapsize = finfo.smem_len;

    data = (unsigned char *)-1;
    if (d_ptr->fd != -1)
        data = (unsigned char *)mmap(0, mapsize, PROT_READ | PROT_WRITE,
                                     MAP_SHARED, d_ptr->fd, 0);

    if ((long)data == -1) {
        perror("QLinuxFbIntegration::connect");
        qWarning("Error: failed to map framebuffer device to memory.");
        return false;
    } else {
        data += dataoffset;
    }

#if 0
    canaccel = useOffscreen();
    if(canaccel)
        setupOffScreen();
#endif
    canaccel = false;

    // Now read in palette
    if((vinfo.bits_per_pixel==8) || (vinfo.bits_per_pixel==4)) {
        screencols= (vinfo.bits_per_pixel==8) ? 256 : 16;
        int loopc;
        fb_cmap startcmap;
        startcmap.start=0;
        startcmap.len=screencols;
        startcmap.red=(unsigned short int *)
                 malloc(sizeof(unsigned short int)*screencols);
        startcmap.green=(unsigned short int *)
                   malloc(sizeof(unsigned short int)*screencols);
        startcmap.blue=(unsigned short int *)
                  malloc(sizeof(unsigned short int)*screencols);
        startcmap.transp=(unsigned short int *)
                    malloc(sizeof(unsigned short int)*screencols);
        if (d_ptr->fd == -1 || ioctl(d_ptr->fd, FBIOGETCMAP, &startcmap)) {
            perror("QLinuxFbIntegration::connect");
            qWarning("Error reading palette from framebuffer, using default palette");
            createPalette(startcmap, vinfo, finfo);
        }
        int bits_used = 0;
        for(loopc=0;loopc<screencols;loopc++) {
            screenclut[loopc]=qRgb(startcmap.red[loopc] >> 8,
                                   startcmap.green[loopc] >> 8,
                                   startcmap.blue[loopc] >> 8);
            bits_used |= startcmap.red[loopc]
                         | startcmap.green[loopc]
                         | startcmap.blue[loopc];
        }
        // WORKAROUND: Some framebuffer drivers only return 8 bit
        // color values, so we need to not bit shift them..
        if ((bits_used & 0x00ff) && !(bits_used & 0xff00)) {
            for(loopc=0;loopc<screencols;loopc++) {
                screenclut[loopc] = qRgb(startcmap.red[loopc],
                                         startcmap.green[loopc],
                                         startcmap.blue[loopc]);
            }
            qWarning("8 bits cmap returned due to faulty FB driver, colors corrected");
        }
        free(startcmap.red);
        free(startcmap.green);
        free(startcmap.blue);
        free(startcmap.transp);
    } else {
开发者ID:sicily,项目名称:qt4.8.4,代码行数:101,代码来源:qlinuxfbintegration.cpp

示例12: leftSourcePixel

void Interpolate_sV::newTwowayFlow(const QImage &left, const QImage &right,
                                   const FlowField_sV *flowLeftRight, const FlowField_sV *flowRightLeft,
                                   float pos, QImage &output)
{
    const int W = left.width();
    const int H = left.height();


    SourceField_sV leftSourcePixel(flowLeftRight, pos);
    leftSourcePixel.inpaint();
    SourceField_sV rightSourcePixel(flowRightLeft, 1-pos);
    rightSourcePixel.inpaint();

    float aspect = 1 - (.5 + std::cos(M_PI*pos)/2);

#if defined(FIX_FLOW)
    FlowField_sV diffField(flowLeftRight->width(), flowLeftRight->height());
    FlowTools_sV::difference(*flowLeftRight, *flowRightLeft, diffField);
    float diffSum;
    float tmpAspect;
#endif

#ifdef FIX_BORDERS
    bool leftOk;
    bool rightOk;
#endif


    float fx, fy;
    QColor colLeft, colRight;
    for (int y = 0; y < H; y++) {
        for (int x = 0; x < W; x++) {

#ifdef FIX_BORDERS
            fx = leftSourcePixel.at(x,y).fromX;
            fy = leftSourcePixel.at(x,y).fromY;
            if (fx >= 0 && fx < W-1
                    && fy >= 0 && fy < H-1) {
                colLeft = interpolate(left, fx, fy);
                leftOk = true;
            } else {
                fx = leftSourcePixel.at(x,y).fromX;
                fy = leftSourcePixel.at(x,y).fromY;
                fx = CLAMP(fx, 0, W-1.01);
                fy = CLAMP(fy, 0, H-1.01);
                colLeft = interpolate(left, fx, fy);
                leftOk = false;
            }

            fx = rightSourcePixel.at(x,y).fromX;
            fy = rightSourcePixel.at(x,y).fromY;
            if (fx >= 0 && fx < W-1
                    && fy >= 0 && fy < H-1) {
                colRight = interpolate(right, fx, fy);
                rightOk = true;
            } else {
                colRight = qRgb(0,255,0);
                rightOk = false;
            }

            if (leftOk && rightOk) {
                output.setPixel(x,y, blend(colLeft, colRight, aspect).rgba());
            } else if (rightOk) {
                output.setPixel(x,y, colRight.rgba());
//                output.setPixel(x,y, qRgb(255, 0, 0));
            } else if (leftOk) {
                output.setPixel(x,y, colLeft.rgba());
//                output.setPixel(x,y, qRgb(0, 255, 0));
            } else {
                output.setPixel(x,y, colLeft.rgba());
            }
#else
            fx = leftSourcePixel.at(x,y).fromX;
            fy = leftSourcePixel.at(x,y).fromY;
            fx = CLAMP(fx, 0, W-1.01);
            fy = CLAMP(fy, 0, H-1.01);
            colLeft = interpolate(left, fx, fy);

#ifdef FIX_FLOW
            diffSum = diffField.x(fx, fy)+diffField.y(fx, fy);
            if (diffSum > 5) {
                tmpAspect = 0;
            } else if (diffSum < -5) {
                tmpAspect = 1;
            } else {
                tmpAspect = aspect;
            }
#endif

            fx = rightSourcePixel.at(x,y).fromX;
            fy = rightSourcePixel.at(x,y).fromY;
            fx = CLAMP(fx, 0, W-1.01);
            fy = CLAMP(fy, 0, H-1.01);
            colRight = interpolate(right, fx, fy);

#ifdef FIX_FLOW
            diffSum = diffField.x(fx, fy)+diffField.y(fx, fy);
            if (diffSum < 5) {
                tmpAspect = 0;
            } else if (diffSum > -5) {
//.........这里部分代码省略.........
开发者ID:Eric013,项目名称:slowmoVideo,代码行数:101,代码来源:interpolate_sV.cpp

示例13: qRgb

#include "queue.h"
#include "core/logging.h"
#include "core/player.h"
#include "core/utilities.h"
#include "library/librarybackend.h"
#include "widgets/trackslider.h"
#include "ui/iconloader.h"

#ifdef Q_OS_DARWIN
#include "core/mac_utilities.h"
#endif  // Q_OS_DARWIN

const int QueuedItemDelegate::kQueueBoxBorder = 1;
const int QueuedItemDelegate::kQueueBoxCornerRadius = 3;
const int QueuedItemDelegate::kQueueBoxLength = 30;
const QRgb QueuedItemDelegate::kQueueBoxGradientColor1 = qRgb(102, 150, 227);
const QRgb QueuedItemDelegate::kQueueBoxGradientColor2 = qRgb(77, 121, 200);
const int QueuedItemDelegate::kQueueOpacitySteps = 10;
const float QueuedItemDelegate::kQueueOpacityLowerBound = 0.4;

const int PlaylistDelegateBase::kMinHeight = 19;

QueuedItemDelegate::QueuedItemDelegate(QObject* parent, int indicator_column)
    : QStyledItemDelegate(parent), indicator_column_(indicator_column) {}

void QueuedItemDelegate::paint(QPainter* painter,
                               const QStyleOptionViewItem& option,
                               const QModelIndex& index) const {
  QStyledItemDelegate::paint(painter, option, index);

  if (index.column() == indicator_column_) {
开发者ID:Aceler,项目名称:Clementine,代码行数:31,代码来源:playlistdelegates.cpp

示例14: LM

/*!
    This function decodes some data into image changes.

    Returns the number of bytes consumed.
*/
int QGIFFormat::decode(QImage *image, const uchar *buffer, int length,
                       int *nextFrameDelay, int *loopCount)
{
    // We are required to state that
    //    "The Graphics Interchange Format(c) is the Copyright property of
    //    CompuServe Incorporated. GIF(sm) is a Service Mark property of
    //    CompuServe Incorporated."

    image->detach();
    int bpl = image->bytesPerLine();
    unsigned char *bits = image->bits();

#define LM(l, m) (((m)<<8)|l)
    digress = false;
    const int initial = length;
    while (!digress && length) {
        length--;
        unsigned char ch=*buffer++;
        switch (state) {
          case Header:
            hold[count++]=ch;
            if (count==6) {
                // Header
                gif89=(hold[3]!='8' || hold[4]!='7');
                state=LogicalScreenDescriptor;
                count=0;
            }
            break;
          case LogicalScreenDescriptor:
            hold[count++]=ch;
            if (count==7) {
                // Logical Screen Descriptor
                swidth=LM(hold[0], hold[1]);
                sheight=LM(hold[2], hold[3]);
                gcmap=!!(hold[4]&0x80);
                //UNUSED: bpchan=(((hold[4]&0x70)>>3)+1);
                //UNUSED: gcmsortflag=!!(hold[4]&0x08);
                gncols=2<<(hold[4]&0x7);
                bgcol=(gcmap) ? hold[5] : -1;
                //aspect=hold[6] ? double(hold[6]+15)/64.0 : 1.0;

                trans_index = -1;
                count=0;
                ncols=gncols;
                if (gcmap) {
                    ccount=0;
                    state=GlobalColorMap;
                    globalcmap = new QRgb[gncols+1]; // +1 for trans_index
                    globalcmap[gncols] = Q_TRANSPARENT;
                } else {
                    state=Introducer;
                }
            }
            break;
          case GlobalColorMap: case LocalColorMap:
            hold[count++]=ch;
            if (count==3) {
                QRgb rgb = qRgb(hold[0], hold[1], hold[2]);
                if (state == LocalColorMap) {
                    if (ccount < lncols)
                        localcmap[ccount] =  rgb;
                } else {
                    globalcmap[ccount] = rgb;
                }
                if (++ccount >= ncols) {
                    if (state == LocalColorMap)
                        state=TableImageLZWSize;
                    else
                        state=Introducer;
                }
                count=0;
            }
            break;
          case Introducer:
            hold[count++]=ch;
            switch (ch) {
              case ',':
                state=ImageDescriptor;
                break;
              case '!':
                state=ExtensionLabel;
                break;
              case ';':
                  // ### Changed: QRect(0, 0, swidth, sheight)
                state=Done;
                break;
              default:
                digress=true;
                // Unexpected Introducer - ignore block
                state=Error;
            }
            break;
          case ImageDescriptor:
            hold[count++]=ch;
            if (count==10) {
//.........这里部分代码省略.........
开发者ID:Nacto1,项目名称:qt-everywhere-opensource-src-4.6.2,代码行数:101,代码来源:qgifhandler.cpp

示例15: reset_view

void MainWindow::reset_view()
{
	m_fgcolor=qRgb(0,0,0);
	m_bgcolor=qRgb(0xff,0xff,0xff);
	update_preview();
}
开发者ID:DroiDev,项目名称:zint,代码行数:6,代码来源:mainwindow.cpp


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