Esempio n. 1
0
QImage FileFormat::readThumbnail(const QString& fileName) const
{
	return (plug && load && thumb) ? plug->readThumbnail(fileName) : QImage();
}
Esempio n. 2
0
QImage XfigPlug::readThumbnail(QString fName)
{
	QFileInfo fi = QFileInfo(fName);
	baseFile = QDir::cleanPath(QDir::toNativeSeparators(fi.absolutePath()+"/"));
	double w=0.0, h=0.0, x=0.0, y=0.0;
	parseHeader(fName, x, y, w, h);
	docX = x;
	docY = y;
	if (w == 0.0)
		w = PrefsManager::instance()->appPrefs.docSetupPrefs.pageWidth;
	if (h == 0.0)
		h = PrefsManager::instance()->appPrefs.docSetupPrefs.pageHeight;
	docWidth = w - x;
	docHeight = h - y;
	progressDialog = NULL;
	m_Doc = new ScribusDoc();
	m_Doc->setup(0, 1, 1, 1, 1, "Custom", "Custom");
	m_Doc->setPage(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false);
	m_Doc->addPage(0);
	m_Doc->setGUI(false, ScCore->primaryMainWindow(), 0);
	baseX = m_Doc->currentPage()->xOffset();
	baseY = m_Doc->currentPage()->yOffset();
	Elements.clear();
	CustColors.clear();
	importedColors.insert(0, "Black");
	importedColors.insert(1, "Blue");
	importedColors.insert(2, "Green");
	importedColors.insert(3, "Cyan");
	importedColors.insert(4, "Red");
	importedColors.insert(5, "Magenta");
	importedColors.insert(6, "Yellow");
	importedColors.insert(7, "White");
	importedColors.insert(8, "Blue4");
	importedColors.insert(9, "Blue3");
	importedColors.insert(10, "Blue2");
	importedColors.insert(11, "LtBlue");
	importedColors.insert(12, "Green4");
	importedColors.insert(13, "Green3");
	importedColors.insert(14, "Green2");
	importedColors.insert(15, "Cyan4");
	importedColors.insert(16, "Cyan3");
	importedColors.insert(17, "Cyan2");
	importedColors.insert(18, "Red4");
	importedColors.insert(19, "Red3");
	importedColors.insert(20, "Red2");
	importedColors.insert(21, "Magenta4");
	importedColors.insert(22, "Magenta3");
	importedColors.insert(23, "Magenta2");
	importedColors.insert(24, "Brown4");
	importedColors.insert(25, "Brown3");
	importedColors.insert(26, "Brown2");
	importedColors.insert(27, "Pink4");
	importedColors.insert(28, "Pink3");
	importedColors.insert(29, "Pink2");
	importedColors.insert(30, "Pink");
	importedColors.insert(31, "Gold");
	CustColors.insert("Blue", ScColor(0, 0, 255));
	CustColors.insert("Blue4", ScColor(0, 0, 144));
	CustColors.insert("Blue3", ScColor(0, 0, 176));
	CustColors.insert("Blue2", ScColor(0, 0, 208));
	CustColors.insert("LtBlue", ScColor(135, 206, 255));
	CustColors.insert("Cyan", ScColor(255, 0, 0, 0));
	CustColors.insert("Cyan4", ScColor(0, 144, 144));
	CustColors.insert("Cyan3", ScColor(0, 176, 176));
	CustColors.insert("Cyan2", ScColor(0, 208, 208));
	CustColors.insert("Green", ScColor(255, 0, 255, 0));
	CustColors.insert("Green4", ScColor(0, 144, 0));
	CustColors.insert("Green3", ScColor(0, 176, 0));
	CustColors.insert("Green2", ScColor(0, 208, 0));
	CustColors.insert("Red", ScColor(0, 255, 255, 0));
	CustColors.insert("Red4", ScColor(144, 0, 0));
	CustColors.insert("Red3", ScColor(176, 0, 0));
	CustColors.insert("Red2", ScColor(208, 0, 0));
	CustColors.insert("Yellow", ScColor(0, 0, 255, 0));
	CustColors.insert("Magenta", ScColor(0, 255, 0, 0));
	CustColors.insert("Magenta4", ScColor(144, 0, 144));
	CustColors.insert("Magenta3", ScColor(176, 0, 176));
	CustColors.insert("Magenta2", ScColor(208, 0, 208));
	CustColors.insert("Brown4", ScColor(128, 48, 0));
	CustColors.insert("Brown3", ScColor(160, 64, 0));
	CustColors.insert("Brown2", ScColor(192, 96, 0));
	CustColors.insert("Pink4", ScColor(255, 128, 128));
	CustColors.insert("Pink3", ScColor(255, 160, 160));
	CustColors.insert("Pink2", ScColor(255, 192, 192));
	CustColors.insert("Pink", ScColor(255, 224, 224));
	CustColors.insert("Gold", ScColor(255, 215, 0));
	m_Doc->setLoading(true);
	m_Doc->DoDrawing = false;
	m_Doc->scMW()->setScriptRunning(true);
	QString CurDirP = QDir::currentPath();
	QDir::setCurrent(fi.path());
	if (convert(fName))
	{
		tmpSel->clear();
		QDir::setCurrent(CurDirP);
		if (Elements.count() > 1)
			m_Doc->groupObjectsList(Elements);
		m_Doc->DoDrawing = true;
		m_Doc->m_Selection->delaySignalsOn();
		QImage tmpImage;
		if (Elements.count() > 0)
		{
			for (int dre=0; dre<Elements.count(); ++dre)
			{
				tmpSel->addItem(Elements.at(dre), true);
			}
			tmpSel->setGroupRect();
			double xs = tmpSel->width();
			double ys = tmpSel->height();
			tmpImage = Elements.at(0)->DrawObj_toImage(500);
			tmpImage.setText("XSize", QString("%1").arg(xs));
			tmpImage.setText("YSize", QString("%1").arg(ys));
		}
		m_Doc->scMW()->setScriptRunning(false);
		m_Doc->setLoading(false);
		m_Doc->m_Selection->delaySignalsOff();
		delete m_Doc;
		return tmpImage;
	}
	else
	{
		QDir::setCurrent(CurDirP);
		m_Doc->DoDrawing = true;
		m_Doc->scMW()->setScriptRunning(false);
		delete m_Doc;
	}
	return QImage();
}
Esempio n. 3
0
	QImage RoomCLEntry::GetAvatar () const
	{
		return QImage ();
	}
Esempio n. 4
0
HCURSOR QWindowsCursor::createSystemCursor(const QCursor &c)
{
    int hx = c.hotSpot().x();
    int hy = c.hotSpot().y();
    const Qt::CursorShape cshape = c.shape();
    if (cshape == Qt::BitmapCursor) {
        const QPixmap pixmap = c.pixmap();
        if (!pixmap.isNull())
            if (const HCURSOR hc = createPixmapCursor(pixmap, hx, hy))
                return hc;
    }

    // Non-standard Windows cursors are created from bitmaps

    static const uchar vsplit_bits[] = {
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00,
        0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
        0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00,
        0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
        0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00,
        0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
    static const uchar vsplitm_bits[] = {
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
        0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xf0, 0x07, 0x00,
        0x00, 0xf8, 0x0f, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00,
        0x00, 0xc0, 0x01, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00,
        0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00,
        0x80, 0xff, 0xff, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00,
        0x00, 0xc0, 0x01, 0x00, 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00,
        0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
    static const uchar hsplit_bits[] = {
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00,
        0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00,
        0x00, 0x41, 0x82, 0x00, 0x80, 0x41, 0x82, 0x01, 0xc0, 0x7f, 0xfe, 0x03,
        0x80, 0x41, 0x82, 0x01, 0x00, 0x41, 0x82, 0x00, 0x00, 0x40, 0x02, 0x00,
        0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00,
        0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
    static const uchar hsplitm_bits[] = {
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00,
        0x00, 0xe0, 0x07, 0x00, 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe3, 0xc7, 0x00,
        0x80, 0xe3, 0xc7, 0x01, 0xc0, 0xff, 0xff, 0x03, 0xe0, 0xff, 0xff, 0x07,
        0xc0, 0xff, 0xff, 0x03, 0x80, 0xe3, 0xc7, 0x01, 0x00, 0xe3, 0xc7, 0x00,
        0x00, 0xe2, 0x47, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00,
        0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
    static const uchar phand_bits[] = {
        0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x80, 0x04, 0x00, 0x00,
        0x80, 0x04, 0x00, 0x00, 0x80, 0x04, 0x00, 0x00, 0x80, 0x04, 0x00, 0x00,
        0x80, 0x1c, 0x00, 0x00, 0x80, 0xe4, 0x00, 0x00, 0x80, 0x24, 0x03, 0x00,
        0x80, 0x24, 0x05, 0x00, 0xb8, 0x24, 0x09, 0x00, 0xc8, 0x00, 0x09, 0x00,
        0x88, 0x00, 0x08, 0x00, 0x90, 0x00, 0x08, 0x00, 0xa0, 0x00, 0x08, 0x00,
        0x20, 0x00, 0x08, 0x00, 0x40, 0x00, 0x08, 0x00, 0x40, 0x00, 0x04, 0x00,
        0x80, 0x00, 0x04, 0x00, 0x80, 0x00, 0x04, 0x00, 0x00, 0x01, 0x02, 0x00,
        0x00, 0x01, 0x02, 0x00, 0x00, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };

   static const uchar phandm_bits[] = {
        0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x80, 0x07, 0x00, 0x00,
        0x80, 0x07, 0x00, 0x00, 0x80, 0x07, 0x00, 0x00, 0x80, 0x07, 0x00, 0x00,
        0x80, 0x1f, 0x00, 0x00, 0x80, 0xff, 0x00, 0x00, 0x80, 0xff, 0x03, 0x00,
        0x80, 0xff, 0x07, 0x00, 0xb8, 0xff, 0x0f, 0x00, 0xf8, 0xff, 0x0f, 0x00,
        0xf8, 0xff, 0x0f, 0x00, 0xf0, 0xff, 0x0f, 0x00, 0xe0, 0xff, 0x0f, 0x00,
        0xe0, 0xff, 0x0f, 0x00, 0xc0, 0xff, 0x0f, 0x00, 0xc0, 0xff, 0x07, 0x00,
        0x80, 0xff, 0x07, 0x00, 0x80, 0xff, 0x07, 0x00, 0x00, 0xff, 0x03, 0x00,
        0x00, 0xff, 0x03, 0x00, 0x00, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };

   static const uchar openhand_bits[] = {
        0x80,0x01,0x58,0x0e,0x64,0x12,0x64,0x52,0x48,0xb2,0x48,0x92,
        0x16,0x90,0x19,0x80,0x11,0x40,0x02,0x40,0x04,0x40,0x04,0x20,
        0x08,0x20,0x10,0x10,0x20,0x10,0x00,0x00};
    static const uchar openhandm_bits[] = {
       0x80,0x01,0xd8,0x0f,0xfc,0x1f,0xfc,0x5f,0xf8,0xff,0xf8,0xff,
       0xf6,0xff,0xff,0xff,0xff,0x7f,0xfe,0x7f,0xfc,0x7f,0xfc,0x3f,
       0xf8,0x3f,0xf0,0x1f,0xe0,0x1f,0x00,0x00};
    static const uchar closedhand_bits[] = {
        0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0x48,0x32,0x08,0x50,
        0x10,0x40,0x18,0x40,0x04,0x40,0x04,0x20,0x08,0x20,0x10,0x10,
        0x20,0x10,0x20,0x10,0x00,0x00,0x00,0x00};
    static const uchar closedhandm_bits[] = {
        0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0xf8,0x3f,0xf8,0x7f,
        0xf0,0x7f,0xf8,0x7f,0xfc,0x7f,0xfc,0x3f,0xf8,0x3f,0xf0,0x1f,
        0xe0,0x1f,0xe0,0x1f,0x00,0x00,0x00,0x00};

    static const uchar * const cursor_bits32[] = {
        vsplit_bits, vsplitm_bits, hsplit_bits, hsplitm_bits,
        phand_bits, phandm_bits
    };

    wchar_t *sh = 0;
    switch (c.shape()) {                        // map to windows cursor
    case Qt::ArrowCursor:
        sh = IDC_ARROW;
        break;
    case Qt::UpArrowCursor:
        sh = IDC_UPARROW;
        break;
    case Qt::CrossCursor:
        sh = IDC_CROSS;
        break;
    case Qt::WaitCursor:
        sh = IDC_WAIT;
        break;
    case Qt::IBeamCursor:
        sh = IDC_IBEAM;
        break;
    case Qt::SizeVerCursor:
        sh = IDC_SIZENS;
        break;
    case Qt::SizeHorCursor:
        sh = IDC_SIZEWE;
        break;
    case Qt::SizeBDiagCursor:
        sh = IDC_SIZENESW;
        break;
    case Qt::SizeFDiagCursor:
        sh = IDC_SIZENWSE;
        break;
    case Qt::SizeAllCursor:
        sh = IDC_SIZEALL;
        break;
    case Qt::ForbiddenCursor:
        sh = IDC_NO;
        break;
    case Qt::WhatsThisCursor:
        sh = IDC_HELP;
        break;
    case Qt::BusyCursor:
        sh = IDC_APPSTARTING;
        break;
    case Qt::PointingHandCursor:
        sh = IDC_HAND;
        break;
    case Qt::BlankCursor:
    case Qt::SplitVCursor:
    case Qt::SplitHCursor:
    case Qt::OpenHandCursor:
    case Qt::ClosedHandCursor:
    case Qt::BitmapCursor: {
        QImage bbits, mbits;
        bool invb, invm;
        if (cshape == Qt::BlankCursor) {
            bbits = QImage(32, 32, QImage::Format_Mono);
            bbits.fill(0);                // ignore color table
            mbits = bbits.copy();
            hx = hy = 16;
            invb = invm = false;
        } else if (cshape == Qt::OpenHandCursor || cshape == Qt::ClosedHandCursor) {
            bool open = cshape == Qt::OpenHandCursor;
            QBitmap cb = QBitmap::fromData(QSize(16, 16), open ? openhand_bits : closedhand_bits);
            QBitmap cm = QBitmap::fromData(QSize(16, 16), open ? openhandm_bits : closedhandm_bits);
            bbits = cb.toImage().convertToFormat(QImage::Format_Mono);
            mbits = cm.toImage().convertToFormat(QImage::Format_Mono);
            hx = hy = 8;
            invb = invm = false;
        } else if (cshape != Qt::BitmapCursor) {
            int i = cshape - Qt::SplitVCursor;
            QBitmap cb = QBitmap::fromData(QSize(32, 32), cursor_bits32[i * 2]);
            QBitmap cm = QBitmap::fromData(QSize(32, 32), cursor_bits32[i * 2 + 1]);
            bbits = cb.toImage().convertToFormat(QImage::Format_Mono);
            mbits = cm.toImage().convertToFormat(QImage::Format_Mono);
            if (cshape == Qt::PointingHandCursor) {
                hx = 7;
                hy = 0;
            } else
                hx = hy = 16;
            invb = invm = false;
        } else {
            bbits = c.bitmap()->toImage().convertToFormat(QImage::Format_Mono);
            mbits = c.mask()->toImage().convertToFormat(QImage::Format_Mono);
            invb = bbits.colorCount() > 1 && qGray(bbits.color(0)) < qGray(bbits.color(1));
            invm = mbits.colorCount() > 1 && qGray(mbits.color(0)) < qGray(mbits.color(1));
        }
        const int n = qMax(1, bbits.width() / 8);
        const int h = bbits.height();
#if !defined(Q_OS_WINCE)
        QScopedArrayPointer<uchar> xBits(new uchar[h * n]);
        QScopedArrayPointer<uchar> xMask(new uchar[h * n]);
        int x = 0;
        for (int i = 0; i < h; ++i) {
            uchar *bits = bbits.scanLine(i);
            uchar *mask = mbits.scanLine(i);
            for (int j = 0; j < n; ++j) {
                uchar b = bits[j];
                uchar m = mask[j];
                if (invb)
                    b ^= 0xff;
                if (invm)
                    m ^= 0xff;
                xBits[x] = ~m;
                xMask[x] = b ^ m;
                ++x;
            }
        }
        return CreateCursor(GetModuleHandle(0), hx, hy, bbits.width(), bbits.height(),
                            xBits.data(), xMask.data());
#elif defined(GWES_ICONCURS) // Q_WS_WINCE
        // Windows CE only supports fixed cursor size.
        int sysW = GetSystemMetrics(SM_CXCURSOR);
        int sysH = GetSystemMetrics(SM_CYCURSOR);
        int sysN = qMax(1, sysW / 8);
        uchar* xBits = new uchar[sysH * sysN];
        uchar* xMask = new uchar[sysH * sysN];
        int x = 0;
        for (int i = 0; i < sysH; ++i) {
            if (i >= h) {
                memset(&xBits[x] , 255, sysN);
                memset(&xMask[x] ,   0, sysN);
                x += sysN;
            } else {
                int fillWidth = n > sysN ? sysN : n;
                uchar *bits = bbits.scanLine(i);
                uchar *mask = mbits.scanLine(i);
                for (int j = 0; j < fillWidth; ++j) {
                    uchar b = bits[j];
                    uchar m = mask[j];
                    if (invb)
                        b ^= 0xFF;
                    if (invm)
                        m ^= 0xFF;
                    xBits[x] = ~m;
                    xMask[x] = b ^ m;
                    ++x;
                }
                for (int j = fillWidth; j < sysN; ++j ) {
                    xBits[x] = 255;
                    xMask[x] = 0;
                    ++x;
                }
            }
        }

        HCURSOR hcurs = CreateCursor(qWinAppInst(), hx, hy, sysW, sysH,
                                   xBits, xMask);
        delete [] xBits;
        delete [] xMask;
        return hcurs;
#else
        Q_UNUSED(n);
        Q_UNUSED(h);
        return 0;
#endif

    }
    case Qt::DragCopyCursor:
    case Qt::DragMoveCursor:
    case Qt::DragLinkCursor: {
        const QPixmap pixmap = QGuiApplicationPrivate::instance()->getPixmapCursor(cshape);
        return createPixmapCursor(pixmap, hx, hy);
    }
    default:
        qWarning("%s: Invalid cursor shape %d", __FUNCTION__, cshape);
        return 0;
    }
#ifdef Q_OS_WINCE
    return LoadCursor(0, sh);
#else
    return (HCURSOR)LoadImage(0, sh, IMAGE_CURSOR, 0, 0, LR_DEFAULTSIZE | LR_SHARED);
#endif
}
Esempio n. 5
0
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++;
            }
        }
        while (i < num_palette) {
            image.setColor(i, qRgba(
                palette[i].red,
                palette[i].green,
                palette[i].blue,
                0xff
               )
           );
            i++;
        }
    } else {
        // 32-bit
        if (bit_depth == 16)
            png_set_strip_16(png_ptr);

        png_set_expand(png_ptr);

        if (color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
            png_set_gray_to_rgb(png_ptr);

        QImage::Format format = QImage::Format_ARGB32;
        // Only add filler if no alpha, or we can get 5 channel data.
        if (!(color_type & PNG_COLOR_MASK_ALPHA)
            && !png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) {
            png_set_filler(png_ptr, 0xff, QSysInfo::ByteOrder == QSysInfo::BigEndian ?
                           PNG_FILLER_BEFORE : PNG_FILLER_AFTER);
            // We want 4 bytes, but it isn't an alpha channel
            format = QImage::Format_RGB32;
        }
        QSize outSize(width,height);
        if (!scaledSize.isEmpty() && quint32(scaledSize.width()) <= width &&
            quint32(scaledSize.height()) <= height && interlace_method == PNG_INTERLACE_NONE) {
            // Do inline downscaling
            outSize = scaledSize;
            if (doScaledRead)
                *doScaledRead = true;
        }
        if (image.size() != outSize || image.format() != format) {
            image = QImage(outSize, format);
            if (image.isNull())
                return;
        }

        if (QSysInfo::ByteOrder == QSysInfo::BigEndian)
            png_set_swap_alpha(png_ptr);

        png_read_update_info(png_ptr, info_ptr);
    }

    // Qt==ARGB==Big(ARGB)==Little(BGRA)
    if (QSysInfo::ByteOrder == QSysInfo::LittleEndian) {
        png_set_bgr(png_ptr);
    }
}
Esempio n. 6
0
QImage VectorscopeGenerator::calculateVectorscope(const QSize &vectorscopeSize, const QImage &image, const float &gain,
                                                  const VectorscopeGenerator::PaintMode &paintMode,
                                                  const VectorscopeGenerator::ColorSpace &colorSpace,
                                                  const bool &, const uint &accelFactor) const
{
    if (vectorscopeSize.width() <= 0 || vectorscopeSize.height() <= 0 || image.width() <= 0 || image.height() <= 0) {
        // Invalid size
        return QImage();
    }

    // Prepare the vectorscope data
    const int cw = (vectorscopeSize.width() < vectorscopeSize.height()) ? vectorscopeSize.width() : vectorscopeSize.height();
    QImage scope = QImage(cw, cw, QImage::Format_ARGB32);
    scope.fill(qRgba(0,0,0,0));

    const uchar *bits = image.bits();

    int r,g,b;
    double dy, dr, dg, db, dmax;
    double /*y,*/ u, v;
    QPoint pt;
    QRgb px;

    const int stepsize = 4 * accelFactor;

    // Just an average for the number of image pixels per scope pixel.
    // NOTE: byteCount() has to be replaced by (img.bytesPerLine()*img.height()) for Qt 4.5 to compile, see: http://doc.trolltech.org/4.6/qimage.html#bytesPerLine
    double avgPxPerPx = (double) 4*(image.bytesPerLine()*image.height())/scope.size().width()/scope.size().height()/accelFactor;

    for (int i = 0; i < (image.bytesPerLine()*image.height()); i+= stepsize) {
        QRgb *col = (QRgb *) bits;

        r = qRed(*col);
        g = qGreen(*col);
        b = qBlue(*col);

        switch (colorSpace) {
        case VectorscopeGenerator::ColorSpace_YUV:
//             y = (double)  0.001173 * r +0.002302 * g +0.0004471* b;
            u = (double) -0.0005781* r -0.001135 * g +0.001713 * b;
            v = (double)  0.002411 * r -0.002019 * g -0.0003921* b;
            break;
        case VectorscopeGenerator::ColorSpace_YPbPr:
        default:
//             y = (double)  0.001173 * r +0.002302 * g +0.0004471* b;
            u = (double) -0.0006671* r -0.001299 * g +0.0019608* b;
            v = (double)  0.001961 * r -0.001642 * g -0.0003189* b;
            break;
        }


        pt = mapToCircle(vectorscopeSize, QPointF(SCALING*gain*u, SCALING*gain*v));

        if (pt.x() >= scope.width() || pt.x() < 0
            || pt.y() >= scope.height() || pt.y() < 0) {
            // Point lies outside (because of scaling), don't plot it

        } else {

            // Draw the pixel using the chosen draw mode.
            switch (paintMode) {
            case PaintMode_YUV:
                // see yuvColorWheel
                dy = 128; // Default Y value. Lower = darker.

                // Calculate the RGB values from YUV/YPbPr
                switch (colorSpace) {
                case VectorscopeGenerator::ColorSpace_YUV:
                    dr = dy + 290.8*v;
                    dg = dy - 100.6*u - 148*v;
                    db = dy + 517.2*u;
                    break;
                case VectorscopeGenerator::ColorSpace_YPbPr:
                default:
                    dr = dy + 357.5*v;
                    dg = dy - 87.75*u - 182*v;
                    db = dy + 451.9*u;
                    break;
                }


                if (dr < 0) dr = 0;
                if (dg < 0) dg = 0;
                if (db < 0) db = 0;
                if (dr > 255) dr = 255;
                if (dg > 255) dg = 255;
                if (db > 255) db = 255;

                scope.setPixel(pt, qRgba(dr, dg, db, 255));
                break;

            case PaintMode_Chroma:
                dy = 200; // Default Y value. Lower = darker.

                // Calculate the RGB values from YUV/YPbPr
                switch (colorSpace) {
                case VectorscopeGenerator::ColorSpace_YUV:
                    dr = dy + 290.8*v;
                    dg = dy - 100.6*u - 148*v;
                    db = dy + 517.2*u;
                    break;
                case VectorscopeGenerator::ColorSpace_YPbPr:
                default:
                    dr = dy + 357.5*v;
                    dg = dy - 87.75*u - 182*v;
                    db = dy + 451.9*u;
                    break;
                }

                // Scale the RGB values back to max 255
                dmax = dr;
                if (dg > dmax) dmax = dg;
                if (db > dmax) dmax = db;
                dmax = 255/dmax;

                dr *= dmax;
                dg *= dmax;
                db *= dmax;

                scope.setPixel(pt, qRgba(dr, dg, db, 255));
                break;
            case PaintMode_Original:
                scope.setPixel(pt, *col);
                break;
            case PaintMode_Green:
                px = scope.pixel(pt);
                scope.setPixel(pt, qRgba(qRed(px)+(255-qRed(px))/(3*avgPxPerPx), qGreen(px)+20*(255-qGreen(px))/(avgPxPerPx),
                                         qBlue(px)+(255-qBlue(px))/(avgPxPerPx), qAlpha(px)+(255-qAlpha(px))/(avgPxPerPx)));
                break;
            case PaintMode_Green2:
                px = scope.pixel(pt);
                scope.setPixel(pt, qRgba(qRed(px)+ceil((255-(float)qRed(px))/(4*avgPxPerPx)), 255,
                                         qBlue(px)+ceil((255-(float)qBlue(px))/(avgPxPerPx)), qAlpha(px)+ceil((255-(float)qAlpha(px))/(avgPxPerPx))));
                break;
            case PaintMode_Black:
                px = scope.pixel(pt);
                scope.setPixel(pt, qRgba(0,0,0, qAlpha(px)+(255-qAlpha(px))/20));
                break;
            }
        }

        bits += stepsize;
    }
    return scope;
}
void KisQPainterCanvas::paintEvent(QPaintEvent * ev)
{
    KisImageWSP image = canvas()->image();
    if (image == 0) return;

    setAutoFillBackground(false);

    if (m_buffer.size() != size()) {
        m_buffer = QImage(size(), QImage::Format_ARGB32_Premultiplied);
    }


    QPainter gc(&m_buffer);

    // we double buffer, so we paint on an image first, then from the image onto the canvas,
    // so copy the clip region since otherwise we're filling the whole buffer every time with
    // the background color _and_ the transparent squares.
    gc.setClipRegion(ev->region());

    KisCoordinatesConverter *converter = coordinatesConverter();
    QTransform imageTransform = converter->viewportToWidgetTransform();

    gc.save();

    gc.setCompositionMode(QPainter::CompositionMode_Source);
    gc.fillRect(QRect(QPoint(0, 0), size()), borderColor());

    QTransform checkersTransform;
    QPointF brushOrigin;
    QPolygonF polygon;

    converter->getQPainterCheckersInfo(&checkersTransform, &brushOrigin, &polygon);
    gc.setPen(Qt::NoPen);
    gc.setBrush(m_d->checkBrush);
    gc.setBrushOrigin(brushOrigin);
    gc.setTransform(checkersTransform);
    gc.drawPolygon(polygon);

    gc.setTransform(imageTransform);
    if (m_d->smooth) {
        gc.setRenderHint(QPainter::SmoothPixmapTransform, true);
    }

    QRectF viewportRect = converter->widgetToViewport(ev->rect());

    gc.setCompositionMode(QPainter::CompositionMode_SourceOver);
    gc.drawImage(viewportRect, m_d->prescaledProjection->prescaledQImage(),
                 viewportRect);

    gc.restore();


#ifdef DEBUG_REPAINT
    QColor color = QColor(random() % 255, random() % 255, random() % 255, 150);
    gc.fillRect(ev->rect(), color);
#endif

    QRect boundingRect = converter->imageRectInWidgetPixels().toAlignedRect();
    drawDecorations(gc, boundingRect);
    gc.end();

    QPainter painter(this);
    painter.drawImage(ev->rect(), m_buffer, ev->rect());
}
Esempio n. 8
0
void Subimage::createImage() {
    mImg = QImage((uchar *)mMat.data, mMat.cols, mMat.rows, mMat.step, QImage::Format_RGB888);
}
Esempio n. 9
0
//drao table
void gamewidget::paintEvent(QPaintEvent*)
{
    QPainter painter(this);
    for(int i=0;i<ROW;++i){
        for(int j = 0;j<COL;++j){
            painter.drawRect(QRect(j*20,i*20,20,20));
        }
    }
//draw food
    painter.drawImage(QRectF(foodx*20,foody*20,20,20),QImage(":/new/prefix1/img/apple.png"));
//draw snake head
    switch (directioin) {
    case UP:
        painter.drawImage(QRectF(snake[0][0]*20,snake[0][1]*20,20,20),QImage(":/new/prefix1/img/headup.png"));
        break;
    case DOWN:
        painter.drawImage(QRectF(snake[0][0]*20,snake[0][1]*20,20,20),QImage(":/new/prefix1/img/headdown.png"));
        break;
    case LEFT:
        painter.drawImage(QRectF(snake[0][0]*20,snake[0][1]*20,20,20),QImage(":/new/prefix1/img/headleft.png"));
        break;
    case RIGHT:
        painter.drawImage(QRectF(snake[0][0]*20,snake[0][1]*20,20,20),QImage(":/new/prefix1/img/headright.png"));
        break;
    default:
        break;
    }
//draw body
    for(int i=1;i<foodcount;++i){
        //左下和上右
        if((snake[i][0]==snake[i-1][0] && snake[i][1]<snake[i-1][1]&&
            snake[i][0]<snake[i+1][0] && snake[i][1]==snake[i+1][1])||
            (snake[i][0]<snake[i-1][0] && snake[i][1]==snake[i-1][1]&&
             snake[i][0]==snake[i+1][0] && snake[i][1]<snake[i+1][1])
           )
           painter.drawImage(QRectF(snake[i][0]*20,snake[i][1]*20,20,20),QImage(":/new/prefix1/img/tl_corner.png"));
        //上左和右下
        else if((snake[i][0]>snake[i-1][0] && snake[i][1]==snake[i-1][1]&&
                 snake[i][0]==snake[i+1][0] && snake[i][1]<snake[i+1][1])||
                 (snake[i][0]==snake[i-1][0] && snake[i][1]<snake[i-1][1]&&
                  snake[i][0]>snake[i+1][0] && snake[i][1]==snake[i+1][1])
                )
            painter.drawImage(QRectF(snake[i][0]*20,snake[i][1]*20,20,20),QImage(":/new/prefix1/img/tr_corner.png"));
        //下右和左上
        else if((snake[i][0]<snake[i-1][0] && snake[i][1]==snake[i-1][1]&&
                 snake[i][0]==snake[i+1][0] && snake[i][1]>snake[i+1][1])||
                 (snake[i][0]==snake[i-1][0] && snake[i][1]>snake[i-1][1]&&
                  snake[i][0]<snake[i+1][0] && snake[i][1]==snake[i+1][1])
                )
            painter.drawImage(QRectF(snake[i][0]*20,snake[i][1]*20,20,20),QImage(":/new/prefix1/img/bl_corner.png"));
        //右上和下左
        else if((snake[i][0]==snake[i-1][0] && snake[i][1]>snake[i-1][1]&&
                 snake[i][0]>snake[i+1][0] && snake[i][1]==snake[i+1][1])||
                 (snake[i][0]>snake[i-1][0] && snake[i][1]==snake[i-1][1]&&
                  snake[i][0]==snake[i+1][0] && snake[i][1]>snake[i+1][1])
                )
            painter.drawImage(QRectF(snake[i][0]*20,snake[i][1]*20,20,20),QImage(":/new/prefix1/img/br_corner.png"));
        else if(snake[i][1]==snake[i-1][1]){
            painter.drawImage(QRectF(snake[i][0]*20,snake[i][1]*20,20,20),QImage(":/new/prefix1/img/h_body.png"));
        }
        else if(snake[i][0]==snake[i-1][0]){
            painter.drawImage(QRectF(snake[i][0]*20,snake[i][1]*20,20,20),QImage(":/new/prefix1/img/v_body.png"));
        }
    }
    if(foodcount){
        if(snake[foodcount][0]==snake[foodcount-1][0]&&snake[foodcount][1]>snake[foodcount-1][1])
            painter.drawImage(QRectF(snake[foodcount][0]*20,snake[foodcount][1]*20,20,20),QImage(":/new/prefix1/img/tail.png"));
        else if(snake[foodcount][0]==snake[foodcount-1][0]&&snake[foodcount][1]<snake[foodcount-1][1])
            painter.drawImage(QRectF(snake[foodcount][0]*20,snake[foodcount][1]*20,20,20),QImage(":/new/prefix1/img/taildown.png"));
        else if(snake[foodcount][0]>snake[foodcount-1][0]&&snake[foodcount][1]==snake[foodcount-1][1])
            painter.drawImage(QRectF(snake[foodcount][0]*20,snake[foodcount][1]*20,20,20),QImage(":/new/prefix1/img/tailleft.png"));
        else
            painter.drawImage(QRectF(snake[foodcount][0]*20,snake[foodcount][1]*20,20,20),QImage(":/new/prefix1/img/tailright.png"));
    }
}
Esempio n. 10
0
 static QPixmap
 loadOverlay( const char *iconName )
 {
     return QImage( locate( "data", QString( "amarok/images/b_%1.png" ).arg( iconName ) ), "PNG" ).smoothScale( 10, 10 );
 }
Esempio n. 11
0
QLayout * PageEditTeam::bodyLayoutDefinition()
{
    QGridLayout * pageLayout = new QGridLayout();
    tbw = new QTabWidget();
    QWidget * page1 = new QWidget(this);
    binder = new KeyBinder(this, tr("Select an action to choose a custom key bind for this team"), tr("Use my default"), tr("Reset all binds"));
    connect(binder, SIGNAL(resetAllBinds()), this, SLOT(resetAllBinds()));
    tbw->addTab(page1, tr("General"));
    tbw->addTab(binder, tr("Custom Controls"));
    pageLayout->addWidget(tbw, 0, 0, 1, 3);

    QHBoxLayout * page1Layout = new QHBoxLayout(page1);
    page1Layout->setAlignment(Qt::AlignTop);

// ====== Page 1 ======
    QVBoxLayout * vbox1 = new QVBoxLayout();
    QVBoxLayout * vbox2 = new QVBoxLayout();
    page1Layout->addLayout(vbox1);
    page1Layout->addLayout(vbox2);

    GBoxHedgehogs = new QGroupBox(this);
    GBoxHedgehogs->setTitle(QGroupBox::tr("Team Members"));
    GBoxHedgehogs->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    QGridLayout * GBHLayout = new QGridLayout(GBoxHedgehogs);


    GBHLayout->addWidget(new QLabel(tr("Hat")), 0, 0);
    GBHLayout->addWidget(new QLabel(tr("Name")), 0, 1);

    for(int i = 0; i < HEDGEHOGS_PER_TEAM; i++)
    {
        HHHats[i] = new HatButton(GBoxHedgehogs);
        GBHLayout->addWidget(HHHats[i], i + 1, 0);

        HHNameEdit[i] = new QLineEdit(GBoxHedgehogs);
        HHNameEdit[i]->setMaxLength(64);
        HHNameEdit[i]->setMinimumWidth(120);
        HHNameEdit[i]->setFixedHeight(36);
        HHNameEdit[i]->setWhatsThis(tr("This hedgehog's name"));
        HHNameEdit[i]->setStyleSheet("padding: 6px;");
        GBHLayout->addWidget(HHNameEdit[i], i + 1, 1, 1, 2);

        btnRandomHogName[i] = addButton(":/res/dice.png", GBHLayout, i + 1, 5, 1, 1, true);
        btnRandomHogName[i]->setFixedHeight(HHNameEdit[i]->height());
        btnRandomHogName[i]->setWhatsThis(tr("Randomize this hedgehog's name"));
    }

    btnRandomHats = new QPushButton();
    btnRandomHats->setText(tr("Random Hats"));
    btnRandomHats->setStyleSheet("padding: 6px 10px;");
    GBHLayout->addWidget(btnRandomHats, 9, 1, 1, 1, Qt::AlignCenter);
    btnRandomHats->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);

    btnRandomNames = new QPushButton();
    btnRandomNames->setText(tr("Random Names"));
    btnRandomNames->setStyleSheet("padding: 6px 10px;");
    GBHLayout->addWidget(btnRandomNames, 9, 2, 1, 1, Qt::AlignCenter);
    btnRandomNames->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);

    vbox1->addWidget(GBoxHedgehogs);

    btnRandomTeam = new QPushButton();
    btnRandomTeam->setText(tr("Random Team"));
    btnRandomTeam->setStyleSheet("padding: 6px 10px;");
    btnRandomTeam->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    vbox1->addWidget(btnRandomTeam, 0, Qt::AlignCenter);

    GBoxTeam = new QGroupBox(this);
    GBoxTeam->setTitle(QGroupBox::tr("Team Settings"));
    GBoxTeam->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    QGridLayout * GBTLayout = new QGridLayout(GBoxTeam);
    QLabel * tmpLabel = new QLabel(GBoxTeam);
    tmpLabel->setText(QLabel::tr("Name"));
    GBTLayout->addWidget(tmpLabel, 0, 0);
    tmpLabel = new QLabel(GBoxTeam);
    tmpLabel->setText(QLabel::tr("Player"));
    GBTLayout->addWidget(tmpLabel, 1, 0);
    tmpLabel = new QLabel(GBoxTeam);
    tmpLabel->setText(QLabel::tr("Grave"));
    GBTLayout->addWidget(tmpLabel, 2, 0);
    tmpLabel = new QLabel(GBoxTeam);
    tmpLabel->setText(QLabel::tr("Flag"));
    GBTLayout->addWidget(tmpLabel, 3, 0);
    tmpLabel = new QLabel(GBoxTeam);
    tmpLabel->setText(QLabel::tr("Voice"));
    GBTLayout->addWidget(tmpLabel, 4, 0);

    TeamNameEdit = new QLineEdit(GBoxTeam);
    TeamNameEdit->setMaxLength(64);
    TeamNameEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
    GBTLayout->addWidget(TeamNameEdit, 0, 1, 1, 2);
    vbox2->addWidget(GBoxTeam);

    CBTeamLvl = new QComboBox(GBoxTeam);
    CBTeamLvl->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
    CBTeamLvl->setIconSize(QSize(32, 32));
    CBTeamLvl->addItem(QIcon(":/res/botlevels/small0.png"), QComboBox::tr("Human"));
    for(int i = 5; i > 0; i--)
        CBTeamLvl->addItem(
            QIcon(QString(":/res/botlevels/small%1.png").arg(6 - i)),
            QComboBox::tr("Computer (Level %1)").arg(i)
        );
    CBTeamLvl->setFixedHeight(38);
    GBTLayout->addWidget(CBTeamLvl, 1, 1, 1, 2);

    CBGrave = new QComboBox(GBoxTeam);
    CBGrave->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
    CBGrave->setMaxCount(65535);
    CBGrave->setMaxVisibleItems(20);
    CBGrave->setIconSize(QSize(32, 32));
    CBGrave->setFixedHeight(44);
    GBTLayout->addWidget(CBGrave, 2, 1, 1, 2);

    // Player flags, combobox to select flag
    CBFlag = new QComboBox(GBoxTeam);
    CBFlag->setMaxCount(65535);
    CBFlag->setMaxVisibleItems(50);
    CBFlag->setIconSize(QSize(22, 15));
    CBFlag->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
    GBTLayout->addWidget(CBFlag, 3, 1, 1, 2);

    // CPU level flag. Static image, only displayed when computer player is selected
    QImage imgBotlevels = QImage("physfs://Graphics/botlevels.png");

    int botlevelOffsets[5]= { 19, 14, 10, 6, 0 };   

    for(int i=0; i<5; i++) {
        QImage imgCPU = QImage("physfs://Graphics/Flags/cpu.png");
        QPainter painter(&imgCPU);
        painter.drawImage(botlevelOffsets[i], 0, imgBotlevels, botlevelOffsets[i]);

        pixCPU[i] = QPixmap::fromImage(imgCPU);
    }

    QHBoxLayout* hboxCPU = new QHBoxLayout();
    hboxCPU->setContentsMargins(0, 0, 0, 0);

    hboxCPUWidget = new QWidget();
    hboxCPUWidget->setLayout(hboxCPU);

    CPUFlag = new QLabel();
    CPUFlag->setPixmap(pixCPU[0]);
    CPUFlag->setFixedHeight(38);

    hboxCPU->addWidget(CPUFlag);

    CPUFlagLabel = new QLabel("CPU");
    CPUFlagLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
    hboxCPU->addWidget(CPUFlagLabel);

    hboxCPUWidget->setHidden(true);
    GBTLayout->addWidget(hboxCPUWidget, 3, 1, 1, 1);

    btnRandomTeamName = addButton(":/res/dice.png", GBTLayout, 0, 3, 1, 1, true);
    btnRandomTeamName->setWhatsThis(tr("Randomize the team name"));

    btnRandomGrave = addButton(":/res/dice.png", GBTLayout, 2, 3, 1, 1, true);
    btnRandomGrave->setWhatsThis(tr("Randomize the grave"));

    btnRandomFlag = addButton(":/res/dice.png", GBTLayout, 3, 3, 1, 1, true);
    btnRandomFlag->setWhatsThis(tr("Randomize the flag"));

    CBVoicepack = new QComboBox(GBoxTeam);
    CBVoicepack->setMaxVisibleItems(50);
    CBVoicepack->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);

    GBTLayout->addWidget(CBVoicepack, 4, 1, 1, 1);

    btnTestSound = addSoundlessButton(":/res/PlaySound.png", GBTLayout, 4, 2, 1, 1, true);
    btnTestSound->setWhatsThis(tr("Play a random example of this voice"));

    btnRandomVoice = addButton(":/res/dice.png", GBTLayout, 4, 3, 1, 1, true);
    btnRandomVoice->setWhatsThis(tr("Randomize the voice"));

    GBoxFort = new QGroupBox(this);
    GBoxFort->setTitle(QGroupBox::tr("Fort"));
    QGridLayout * GBFLayout = new QGridLayout(GBoxFort);
    CBFort = new QComboBox(GBoxFort);
    CBFort->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
    CBFort->setMaxVisibleItems(25);
    CBFort->setMaxCount(65535);

    GBFLayout->addWidget(CBFort, 0, 0);

    btnRandomFort = addButton(":/res/dice.png", GBFLayout, 0, 2, 1, 1, true);
    btnRandomFort->setWhatsThis(tr("Randomize the fort"));

    FortPreview = new SquareLabel(GBoxFort);
    FortPreview->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    FortPreview->setMinimumSize(128, 128);
    FortPreview->setPixmap(QPixmap());
    // perhaps due to handling its own paintevents, SquareLabel doesn't play nice with the stars
    //FortPreview->setAttribute(Qt::WA_PaintOnScreen, true);
    GBFLayout->addWidget(FortPreview, 1, 0, 1, 2);
    vbox2->addWidget(GBoxFort);

    vbox1->addStretch();
    vbox2->addStretch();

    return pageLayout;
}
Esempio n. 12
0
QImage CameraHandler::Mat2QImage(cv::Mat const& src){
	/* Thanks to Marek R */
	QImage image = QImage((const uchar *) src.data, src.cols, src.rows, src.step, QImage::Format_RGB888);
	image.bits();
	return image;
}
Esempio n. 13
0
void LocalFileSource::unload() {
	_data = QImage();
}
Esempio n. 14
0
/*!
 * use latex to render LaTeX text (see tex2im, etc.)
 */
QImage TeXRenderer::renderImageLaTeX( const QString& teXString, const QColor& fontColor, const int fontSize, const int dpi){
	QTemporaryFile file("/dev/shm/labplot_XXXXXX.tex");
	//file.setAutoRemove(false);
	if(file.open()) {
		QDir::setCurrent("/dev/shm");
	}
	else {
		kWarning()<<"/dev/shm failed. using /tmp"<<endl;
		file.setFileTemplate("/tmp/labplot_XXXXXX.tex");
		if(file.open())
			QDir::setCurrent("/tmp");
		else
			return QImage();
	}

	// create latex code
	QTextStream out(&file);
	out << "\\documentclass{minimal}";
	out << "\\usepackage{color}\\usepackage[active,displaymath,textmath,tightpage]{preview}";
	out << "\\begin{document}";
	out << "\\definecolor{fontcolor}{rgb}{" << fontColor.redF() << ',' << fontColor.greenF() << ','<<fontColor.blueF() << "}";
	out << "\\begin{preview}";
	out << "{\\fontsize{" << QString::number(fontSize) << "}{" << QString::number(fontSize) << "}\\selectfont";
	out << "{\\color{fontcolor}\n";
	out << teXString;
	out << "\n}}\\end{preview}";
	out << "\\end{document}";
	out.flush();

	// pdflatex: TeX -> PDF
	QProcess latexProcess, convertProcess;
	latexProcess.start("pdflatex", QStringList() << "-interaction=batchmode" << file.fileName());

	QFileInfo fi(file.fileName());
	if (latexProcess.waitForFinished()) { 	// pdflatex finished
		QFile::remove(fi.completeBaseName()+".aux");
		QFile::remove(fi.completeBaseName()+".log");

		//TODO: pdflatex doesn't come back with EX_OK
// 		if(latexProcess.exitCode() != 0)	// skip if pdflatex failed
// 			return QImage();

		// convert: PDF -> PNG
		convertProcess.start("convert",  QStringList() << "-density"<< QString::number(dpi) + 'x' + QString::number(dpi)
														<< fi.completeBaseName() + ".pdf"
														<< fi.completeBaseName() + ".png");
		//gs doesn't work here. Why?
// 		convertProcess.start("gs", QStringList()<< "-sDEVICE=png16m"
// 												<< "-dTextAlphaBits=4"
// 												<< "-r" + QString::number(dpi)
// 												<< "-dGraphicsAlphaBits=4"
// 												<< "-sDEVICE=pngalpha"
// 												<< "-dSAFER"
// 												<< "-q"
// 												<< "-dNOPAUSE"
// 												<< "-sOutputFile=" + fi.completeBaseName() + ".png"
// 												<< fi.completeBaseName() + ".pdf");

		// clean up and read png file
		if (convertProcess.waitForFinished()) {
			QFile::remove(fi.completeBaseName()+".pdf");

			QImage image;
			image.load(fi.completeBaseName()+".png");
			QFile::remove(fi.completeBaseName()+".png");

			return image;
		}else{
			QFile::remove(fi.completeBaseName()+".pdf");
			return QImage();
		}
	}else{
		kWarning()<<"pdflatex failed."<<endl;
	}

	//////////// fallback if pdflatex fails ///////////////

	// latex: TeX -> DVI
	latexProcess.start("latex", QStringList() << "-interaction=batchmode" << file.fileName());
	// also possible: latexmf -C
	if (!latexProcess.waitForFinished()) {
		kWarning()<<"latex failed."<<endl;
		QFile::remove(fi.completeBaseName()+".aux");
		QFile::remove(fi.completeBaseName()+".log");
		return QImage();
	}
	if(latexProcess.exitCode() != 0)	// skip if latex failed
		return QImage();

	// dvips: DVI -> PS
	QProcess dvipsProcess;
	dvipsProcess.start("dvips", QStringList() << "-E" << fi.completeBaseName());
	if (!dvipsProcess.waitForFinished()) {
		kWarning()<<"dvips failed."<<endl;
		QFile::remove(fi.completeBaseName()+".dvi");
		return QImage();
	}

	// convert: PS -> PNG
	convertProcess.start("convert", QStringList() << "-density" << QString::number(dpi) + 'x' + QString::number(dpi)  << fi.completeBaseName()+".ps" << fi.completeBaseName()+".png");
	if (!convertProcess.waitForFinished()) {
		kWarning()<<"convert failed."<<endl;
		QFile::remove(fi.completeBaseName()+".ps");
		return QImage();
	}

	// read png file
	QImage image;
	image.load(fi.completeBaseName()+".png", "png");

	//clean up
	QFile::remove(fi.completeBaseName()+".png");
	QFile::remove(fi.completeBaseName()+".aux");
	QFile::remove(fi.completeBaseName()+".log");
	QFile::remove(fi.completeBaseName()+".dvi");
	QFile::remove(fi.completeBaseName()+".ps");

	return image;
}
Esempio n. 15
0
void core::ImageEffect::setSampledImage(const QString &path)
{
	minImage = QImage(path);
}
Esempio n. 16
0
    void render() {

        // setup the screen surface
        if (buffer.size() != bufferSize)
            buffer = QImage(bufferSize, QImage::Format_ARGB32);
        int bufw = buffer.width();
        int bufh = buffer.height();
        if (bufw <= 0 || bufh <= 0)
            return;

        // we intentionally cheat here, to avoid detach
        const uchar *ptr = buffer.bits();
        QRgb *start = (QRgb*)(ptr);
        QRgb stride = buffer.bytesPerLine() / 4;
        QRgb *finish = start + stride * bufh;

        // prepare the texture pointer
        const uchar *src = textureImg.bits();
        const QRgb *texsrc = reinterpret_cast<const QRgb*>(src);

        // cast all rays here
        qreal sina = sin(angle);
        qreal cosa = cos(angle);
        qreal u = cosa - sina;
        qreal v = sina + cosa;
        qreal du = 2 * sina / bufw;
        qreal dv = -2 * cosa / bufw;

        for (int ray = 0; ray < bufw; ++ray, u += du, v += dv) {
            // every time this ray advances 'u' units in x direction,
            // it also advanced 'v' units in y direction
            qreal uu = (u < 0) ? -u : u;
            qreal vv = (v < 0) ? -v : v;
            qreal duu = 1 / uu;
            qreal dvv = 1 / vv;
            int stepx = (u < 0) ? -1 : 1;
            int stepy = (v < 0) ? -1 : 1;

            // the cell in the map that we need to check
            qreal px = playerPos.x();
            qreal py = playerPos.y();
            int mapx = static_cast<int>(px);
            int mapy = static_cast<int>(py);

            // the position and texture for the hit
            int texture = 0;
            qreal hitdist = 0.1;
            qreal texofs = 0;
            bool dark = false;

            // first hit at constant x and constant y lines
            qreal distx = (u > 0) ? (mapx + 1 - px) * duu : (px - mapx) * duu;
            qreal disty = (v > 0) ? (mapy + 1 - py) * dvv : (py - mapy) * dvv;

            // loop until we hit something
            while (texture <= 0) {
                if (distx > disty) {
                    // shorter distance to a hit in constant y line
                    hitdist = disty;
                    disty += dvv;
                    mapy += stepy;
                    texture = world_map[mapy][mapx];
                    if (texture > 0) {
                        dark = true;
                        if (stepy > 0) {
                            qreal ofs = px + u * (mapy - py) / v;
                            texofs = ofs - floor(ofs);
                        } else {
                            qreal ofs = px + u * (mapy + 1 - py) / v;
                            texofs = ofs - floor(ofs);
                        }
                    }
                } else {
                    // shorter distance to a hit in constant x line
                    hitdist = distx;
                    distx += duu;
                    mapx += stepx;
                    texture = world_map[mapy][mapx];
                    if (texture > 0) {
                        if (stepx > 0) {
                            qreal ofs = py + v * (mapx - px) / u;
                            texofs = ofs - floor(ofs);
                        } else {
                            qreal ofs = py + v * (mapx + 1 - px) / u;
                            texofs = ceil(ofs) - ofs;
                        }
                    }
                }
            }

            // get the texture, note that the texture image
            // has two textures horizontally, "normal" vs "dark"
            int col = static_cast<int>(texofs * TEXTURE_SIZE);
            col = qBound(0, col, TEXTURE_SIZE - 1);
            texture = (texture - 1) % textureCount;
            const QRgb *tex = texsrc + TEXTURE_BLOCK * texture * 2 +
                              (TEXTURE_SIZE * 2 * col);
            if (dark)
                tex += TEXTURE_SIZE;

            // start from the texture center (horizontally)
            int h = static_cast<int>(bufw / hitdist / 2);
            int dy = (TEXTURE_SIZE << 12) / h;
            int p1 = ((TEXTURE_SIZE / 2) << 12) - dy;
            int p2 = p1 + dy;

            // start from the screen center (vertically)
            // y1 will go up (decrease), y2 will go down (increase)
            int y1 = bufh / 2;
            int y2 = y1 + 1;
            QRgb *pixel1 = start + y1 * stride + ray;
            QRgb *pixel2 = pixel1 + stride;

            // map the texture to the sliver
            while (y1 >= 0 && y2 < bufh && p1 >= 0) {
                *pixel1 = tex[p1 >> 12];
                *pixel2 = tex[p2 >> 12];
                p1 -= dy;
                p2 += dy;
                --y1;
                ++y2;
                pixel1 -= stride;
                pixel2 += stride;
            }

            // ceiling and floor
            for (; pixel1 > start; pixel1 -= stride)
                *pixel1 = qRgb(0, 0, 0);
            for (; pixel2 < finish; pixel2 += stride)
                *pixel2 = qRgb(96, 96, 96);
        }

        update(QRect(QPoint(0, 0), bufferSize));
    }
Esempio n. 17
0
		return;
	}

	if (d->m_need_initialize_window) {
		float max=0;
		MemoryMda *grid=&d->m_grid;
		foreach (int pt,d->m_active_pixels) {
			long x=pt%N1;
			long y=pt/N1;
			max=qMax(max,(float)grid->value(x,y)*d->m_increment_weight);
		}
		d->m_window_max=max/3;
		d->m_need_initialize_window=false;
	}

	d->m_image=QImage(N1,N2,QImage::Format_ARGB32);
	d->m_image.fill(Qt::black);

	foreach (long pt,d->m_active_pixels) {
		long x=pt%N1;
		long y=pt/N1;
		int r0=(int)qMin(255.0,d->m_grid.value(x,y,0)*1.0/d->m_window_max*d->m_increment_weight*255);
		int g0=(int)qMin(255.0,d->m_grid.value(x,y,1)*1.0/d->m_window_max*d->m_increment_weight*255);
		int b0=(int)qMin(255.0,d->m_grid.value(x,y,2)*1.0/d->m_window_max*d->m_increment_weight*255);
		QColor CC(r0,g0,b0);
		d->m_image.setPixel(x,y,CC.rgb());
	}

	painter.drawImage(0,0,d->m_image);

	d->draw_overlay(&painter);
Esempio n. 18
0
void PlaylistView::ReloadSettings() {
  QSettings s;
  s.beginGroup(Playlist::kSettingsGroup);
  glow_enabled_ = s.value("glow_effect", true).toBool();

  if (setting_initial_header_layout_ || upgrading_from_qheaderview_) {
    header_->SetStretchEnabled(s.value("stretch", true).toBool());
    upgrading_from_qheaderview_ = false;
  }

  if (currently_glowing_ && glow_enabled_ && isVisible()) StartGlowing();
  if (!glow_enabled_) StopGlowing();

  if (setting_initial_header_layout_) {
    header_->SetColumnWidth(Playlist::Column_Length, 0.06);
    header_->SetColumnWidth(Playlist::Column_Track, 0.05);
    setting_initial_header_layout_ = false;
  }

  if (upgrading_from_version_ != -1) {
    if (upgrading_from_version_ < 4) {
      header_->SetColumnWidth(Playlist::Column_Source, 0.05);
    }
    upgrading_from_version_ = -1;
  }

  column_alignment_ = s.value("column_alignments").value<ColumnAlignmentMap>();
  if (column_alignment_.isEmpty()) {
    column_alignment_ = DefaultColumnAlignment();
  }

  emit ColumnAlignmentChanged(column_alignment_);

  // Background:
  QVariant q_playlistview_background_type =
      s.value(kSettingBackgroundImageType);
  BackgroundImageType background_type(Default);
  // bg_enabled should also be checked for backward compatibility (in releases
  // <= 1.0, there was just a boolean to activate/deactivate the background)
  QVariant bg_enabled = s.value("bg_enabled");
  if (q_playlistview_background_type.isValid()) {
    background_type = static_cast<BackgroundImageType>(
        q_playlistview_background_type.toInt());
  } else if (bg_enabled.isValid()) {
    if (bg_enabled.toBool()) {
      background_type = Default;
    } else {
      background_type = None;
    }
  }
  QString background_image_filename =
      s.value(kSettingBackgroundImageFilename).toString();
  int blur_radius = s.value("blur_radius", kDefaultBlurRadius).toInt();
  int opacity_level = s.value("opacity_level", kDefaultOpacityLevel).toInt();
  // Check if background properties have changed.
  // We change properties only if they have actually changed, to avoid to call
  // set_background_image when it is not needed, as this will cause the fading
  // animation to start again. This also avoid to do useless
  // "force_background_redraw".
  if (background_image_filename != background_image_filename_ ||
      background_type != background_image_type_ ||
      blur_radius_ != blur_radius || opacity_level_ != opacity_level) {
    // Store background properties
    background_image_type_ = background_type;
    background_image_filename_ = background_image_filename;
    blur_radius_ = blur_radius;
    opacity_level_ = opacity_level;
    if (background_image_type_ == Custom) {
      set_background_image(QImage(background_image_filename));
    } else if (background_image_type_ == AlbumCover) {
      set_background_image(current_song_cover_art_);
    } else {
      // User changed background image type to something that will not be
      // painted through paintEvent: reset all background images.
      // This avoid to use old (deprecated) images for fading when selecting
      // AlbumCover or Custom background image type later.
      set_background_image(QImage());
      cached_scaled_background_image_ = QPixmap();
      previous_background_image_ = QPixmap();
    }
    setProperty("default_background_enabled",
                background_image_type_ == Default);
    emit BackgroundPropertyChanged();
    force_background_redraw_ = true;
  }
}
Esempio n. 19
0
void game_list_frame::Refresh(bool fromDrive)
{
	if (fromDrive)
	{
		// Load PSF

		m_game_data.clear();

		const std::string& game_path = Emu.GetGameDir();

		for (const auto& entry : fs::dir(Emu.GetGameDir()))
		{
			if (!entry.is_directory)
			{
				continue;
			}

			const std::string& dir = game_path + entry.name;
			const std::string& sfb = dir + "/PS3_DISC.SFB";
			const std::string& sfo = dir + (fs::is_file(sfb) ? "/PS3_GAME/PARAM.SFO" : "/PARAM.SFO");

			const fs::file sfo_file(sfo);
			if (!sfo_file)
			{
				continue;
			}

			const auto& psf = psf::load_object(sfo_file);

			GameInfo game;
			game.root         = entry.name;
			game.serial       = psf::get_string(psf, "TITLE_ID", "");
			game.name         = psf::get_string(psf, "TITLE", "unknown");
			game.app_ver      = psf::get_string(psf, "APP_VER", "unknown");
			game.category     = psf::get_string(psf, "CATEGORY", "unknown");
			game.fw           = psf::get_string(psf, "PS3_SYSTEM_VER", "unknown");
			game.parental_lvl = psf::get_integer(psf, "PARENTAL_LEVEL");
			game.resolution   = psf::get_integer(psf, "RESOLUTION");
			game.sound_format = psf::get_integer(psf, "SOUND_FORMAT");

			if (game.category == "HG")
			{
				game.category = sstr(category::hdd_Game);
				game.icon_path = dir + "/ICON0.PNG";
			}
			else if (game.category == "DG")
			{
				game.category = sstr(category::disc_Game);
				game.icon_path = dir + "/PS3_GAME/ICON0.PNG";
			}
			else if (game.category == "HM")
			{
				game.category = sstr(category::home);
				game.icon_path = dir + "/ICON0.PNG";
			}
			else if (game.category == "AV")
			{
				game.category = sstr(category::audio_Video);
				game.icon_path = dir + "/ICON0.PNG";
			}
			else if (game.category == "GD")
			{
				game.category = sstr(category::game_Data);
				game.icon_path = dir + "/ICON0.PNG";
			}
			else if (game.category == "unknown")
			{
				game.category = sstr(category::unknown);
			}

			// Load Image
			QImage img;
			QPixmap pxmap;

			if (!game.icon_path.empty() && img.load(qstr(game.icon_path)))
			{
				QImage scaled = img.scaled(m_Icon_Size, Qt::KeepAspectRatio, Qt::TransformationMode::SmoothTransformation);
				pxmap = QPixmap::fromImage(scaled);
			}
			else
			{
				img = QImage(m_Icon_Size, QImage::Format_ARGB32);
				QString abspath = QDir(qstr(game.icon_path)).absolutePath();
				LOG_ERROR(HLE, "Count not load image from path %s", sstr(abspath));
				img.fill(QColor(0, 0, 0, 0));
				pxmap = QPixmap::fromImage(img);
			}

			m_game_data.push_back({ game, img, pxmap });
		}

		auto op = [](const GUI_GameInfo& game1, const GUI_GameInfo& game2) {
			return game1.info.name < game2.info.name;
		};

		// Sort by name at the very least.
		std::sort(m_game_data.begin(), m_game_data.end(), op);
	}

	// Fill Game List / Game Grid

	if (m_isListLayout)
	{
		int row = PopulateGameList();
		FilterData();
		gameList->selectRow(row);
		gameList->sortByColumn(m_sortColumn, m_colSortOrder);
		gameList->verticalHeader()->setMinimumSectionSize(m_Icon_Size.height());
		gameList->verticalHeader()->setMaximumSectionSize(m_Icon_Size.height());
		gameList->resizeRowsToContents();
		gameList->resizeColumnToContents(0);
		gameList->scrollTo(gameList->currentIndex());
	}
	else
	{
		if (m_Icon_Size.width() > 0 && m_Icon_Size.height() > 0)
		{
			m_games_per_row = width() / (m_Icon_Size.width() + m_Icon_Size.width() * m_xgrid->getMarginFactor() * 2);
		}
		else
		{
			m_games_per_row = 0;
		}

		PopulateGameGrid(m_games_per_row, m_Icon_Size);
		connect(m_xgrid, &QTableWidget::doubleClicked, this, &game_list_frame::doubleClickedSlot);
		connect(m_xgrid, &QTableWidget::customContextMenuRequested, this, &game_list_frame::ShowContextMenu);
		m_Central_Widget->addWidget(m_xgrid);
		m_Central_Widget->setCurrentWidget(m_xgrid);
		m_xgrid->scrollTo(m_xgrid->currentIndex());
	}
}
Esempio n. 20
0
void PlaylistView::PlayerStopped() {
  CurrentSongChanged(Song(), QString(), QImage());
}
Esempio n. 21
0
StepItem::StepItem(StepItemType type, QString icon_path, QString step_name)
    : type_(type), icon_path_(icon_path), step_name_(step_name) {
    image_ = QImage(icon_path);
    is_executed_ = false;
}
void TravelStageListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
                              const QModelIndex &index) const {
    QStyledItemDelegate::paint(painter, option, index);

    TravelStage *e = qVariantValue<TravelStage *>(index.data());

    QFont font = option.font;
    QRect rect = option.rect;
    QSize iconSize(48, 48);
    if(dialog->portraitMode()) {
        rect.adjust(2, 2, -10, -2);
    } else {
        rect.adjust(2, 2, -10, -5);
    }
    QPoint iconPosition = rect.topLeft();
    iconPosition.setY(iconPosition.y() + 5);

    rect.adjust(60, 0, 0, 0);

    painter->save();

    int maxLabelLength;
    if (dialog->portraitMode()) {
        maxLabelLength = 24;
    } else {
        maxLabelLength = 40;
    }

    QString lineAndDestination;
    if(e->transportation == "Walking") {
        lineAndDestination = tr("Walking");
    } else {
        QString lineDestination;
        if(e->destination.length() > maxLabelLength) {
            lineDestination = e->destination.left(maxLabelLength - 2) + "...";
        } else {
            lineDestination = e->destination;
        }
        lineAndDestination = e->lineName + " " + lineDestination;
    }
    QString departureStopPlaceName;
    if(e->departureStop.placeName.length() > maxLabelLength) {
        departureStopPlaceName = e->departureStop.placeName.left(maxLabelLength - 2) + "...";
    } else {
        departureStopPlaceName = e->departureStop.placeName;
    }
    QString arrivalStopPlaceName;
    if(e->arrivalStop.placeName.length() > maxLabelLength) {
        arrivalStopPlaceName = e->arrivalStop.placeName.left(maxLabelLength - 2) + "...";
    } else {
        arrivalStopPlaceName = e->arrivalStop.placeName;
    }

    int minutes = (int)((double)e->departureTime.secsTo(e->arrivalTime) / 60.0);

    if(dialog->portraitMode()) {

        font.setPointSizeF(font.pointSizeF() * 0.70);
        painter->setFont(font);

        painter->drawText(rect, Qt::AlignTop | Qt::AlignLeft, lineAndDestination);
        painter->drawText(rect, Qt::AlignTop | Qt::AlignRight, tr("%n min", "", minutes));
        painter->setPen(option.palette.mid().color());
        painter->drawText(rect, Qt::AlignVCenter | Qt::AlignLeft, departureStopPlaceName + " " + e->departureTime.toString("hh:mm"));
        painter->drawText(rect, Qt::AlignBottom | Qt::AlignLeft, arrivalStopPlaceName + " " + e->arrivalTime.toString("hh:mm"));
    } else {
        painter->drawText(rect, Qt::AlignTop | Qt::AlignLeft, lineAndDestination);
        painter->drawText(rect, Qt::AlignTop | Qt::AlignRight, departureStopPlaceName + " " + e->departureTime.toString("hh:mm"));

        painter->setPen(option.palette.mid().color());
        font.setPointSizeF(font.pointSizeF() * 0.70);
        painter->setFont(font);

        painter->drawText(rect, Qt::AlignBottom | Qt::AlignRight, arrivalStopPlaceName + " " + e->arrivalTime.toString("hh:mm"));
        painter->drawText(rect, Qt::AlignBottom | Qt::AlignLeft, tr("%n min", "", minutes));
    }

    if(e->transportation == "Bus" || e->transportation == "AirportBus") {
        QImage icon = QImage(":/images/bus.png").scaled(iconSize);
        painter->drawImage(iconPosition, icon);
    } else if(e->transportation == "Tram") {
        QImage icon = QImage(":/images/tram.png").scaled(iconSize);
        painter->drawImage(iconPosition, icon);
    } else if(e->transportation == "Metro") {
        QImage icon = QImage(":/images/tbane.png").scaled(iconSize);
        painter->drawImage(iconPosition, icon);
    } else if(e->transportation == "Train" || e->transportation == "AirportTrain") {
        QImage icon = QImage(":/images/train.png").scaled(iconSize);
        painter->drawImage(iconPosition, icon);
    }
    painter->restore();
}
Esempio n. 23
0
void KBImageLoader::run()
{
    QMutexLocker locker(&d->condLock);

    // we enter the loop with d->needImage==true, so we will immediately
    // try to load an image

    while (true)
    {
        if (d->quitRequested)
            break;

        if (d->needImage)
        {
            if ( d->fileIndex == (int)d->sharedData->urlList.count() )
            {
                if (d->sharedData->loop)
                {
                    d->fileIndex = 0;
                }
                else
                {
                    d->needImage = false;
                    emit(signalEndOfShow());
                    continue;
                }
            }

            d->needImage = false;
            d->condLock.unlock();
            bool ok;

            do
            {
                ok = loadImage();

                if ( !ok)
                    invalidateCurrentImageName();
            }
            while ( !ok && d->fileIndex < (int)d->sharedData->urlList.count());

            if ( d->fileIndex == (int)d->sharedData->urlList.count() )
            {

                emit(signalEndOfShow());
                d->condLock.lock();
                continue;
            }

            if ( !ok)
            {
                // generate a black dummy image
                d->texture = QImage(128, 128, QImage::Format_ARGB32);
                d->texture.fill(Qt::black);
            }

            d->condLock.lock();

            d->fileIndex++;

            if ( !d->initialized)
            {
                d->haveImages  = ok;
                d->initialized = true;
            }
        }
        else
        {
            // wait for new requests from the consumer
            d->imageRequest.wait(&d->condLock);
        }
    }
}
Esempio n. 24
0
/*!
   \brief Render an image from the data and color map.

   The area is translated into a rect of the paint device.
   For each pixel of this rect the intensity is mapped
   into a color.

  \param azimuthMap Maps azimuth values to values related to 0.0, M_2PI
  \param radialMap Maps radius values into painter coordinates.
  \param pole Position of the pole in painter coordinates
  \param rect Target rectangle of the image in painter coordinates

   \return A QImage::Format_Indexed8 or QImage::Format_ARGB32 depending
           on the color map.

   \sa QwtRasterData::intensity(), QwtColorMap::rgb(),
       QwtColorMap::colorIndex()
*/
QImage QwtPolarSpectrogram::renderImage(
    const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap,
    const QPointF &pole, const QRect &rect ) const
{
    if ( d_data->data == NULL || d_data->colorMap == NULL )
        return QImage();

    QImage image( rect.size(), d_data->colorMap->format() == QwtColorMap::RGB
                  ? QImage::Format_ARGB32 : QImage::Format_Indexed8 );

    const QwtInterval intensityRange = d_data->data->interval( Qt::ZAxis );
    if ( !intensityRange.isValid() )
        return image;

    if ( d_data->colorMap->format() == QwtColorMap::Indexed )
        image.setColorTable( d_data->colorMap->colorTable( intensityRange ) );

    /*
     For the moment we only announce the composition of the image by
     calling initRaster(), but we don't pass any useful parameters.
     ( How to map rect into something, that is useful to initialize a matrix
       of values in polar coordinates ? )
     */
    d_data->data->initRaster( QRectF(), QSize() );


#if QT_VERSION >= 0x040400 && !defined(QT_NO_QFUTURE)
    uint numThreads = renderThreadCount();

    if ( numThreads <= 0 )
        numThreads = QThread::idealThreadCount();

    if ( numThreads <= 0 )
        numThreads = 1;

    const int numRows = rect.height() / numThreads;


    QVector<TileInfo> tileInfos;
    for ( uint i = 0; i < numThreads; i++ )
    {
        QRect tile( rect.x(), rect.y() + i * numRows, rect.width(), numRows );
        if ( i == numThreads - 1 )
            tile.setHeight( rect.height() - i * numRows );

        TileInfo tileInfo;
        tileInfo.imagePos = rect.topLeft();
        tileInfo.rect = tile;
        tileInfo.image = &image;

        tileInfos += tileInfo;
    }

    QVector< QFuture<void> > futures;
    for ( int i = 0; i < tileInfos.size(); i++ )
    {
        if ( i == tileInfos.size() - 1 )
        {
            renderTile( azimuthMap, radialMap, pole, &tileInfos[i] );
        }
        else
        {
            futures += QtConcurrent::run( this, &QwtPolarSpectrogram::renderTile,
                azimuthMap, radialMap, pole, &tileInfos[i] );
        }
    }
    for ( int i = 0; i < futures.size(); i++ )
        futures[i].waitForFinished();

#else // QT_VERSION < 0x040400
    renderTile( azimuthMap, radialMap, pole, rect.topLeft(), rect, &image );
#endif

    d_data->data->discardRaster();

    return image;
}
Esempio n. 25
0
QFileInfo Content::GetPreviewImage(        int        nRecordedId,
                                           int        nChanId,
                                     const QDateTime &recstarttsRaw,
                                           int        nWidth,
                                           int        nHeight,
                                           int        nSecsIn,
                                     const QString   &sFormat )
{
    if ((nRecordedId <= 0) &&
        (nChanId <= 0 || !recstarttsRaw.isValid()))
        throw QString("Recorded ID or Channel ID and StartTime appears invalid.");

    if (!sFormat.isEmpty()
        && !QImageWriter::supportedImageFormats().contains(sFormat.toLower().toLocal8Bit()))
    {
        throw "GetPreviewImage: Specified 'Format' is not supported.";
    }

    // ----------------------------------------------------------------------
    // Read Recording From Database
    // ----------------------------------------------------------------------

    // TODO Should use RecordingInfo
    ProgramInfo pginfo;
    if (nRecordedId > 0)
        pginfo = ProgramInfo(nRecordedId);
    else
        pginfo = ProgramInfo(nChanId, recstarttsRaw.toUTC());

    if (!pginfo.GetChanID())
    {
        LOG(VB_GENERAL, LOG_ERR,
            QString("GetPreviewImage: No recording for '%1'")
            .arg(nRecordedId));
        return QFileInfo();
    }

    if (pginfo.GetHostname().toLower() != gCoreContext->GetHostName().toLower())
    {
        QString sMsg =
            QString("GetPreviewImage: Wrong Host '%1' request from '%2'")
                          .arg( gCoreContext->GetHostName())
                          .arg( pginfo.GetHostname() );

        LOG(VB_UPNP, LOG_ERR, sMsg);

        throw HttpRedirectException( pginfo.GetHostname() );
    }

    QString sImageFormat = sFormat;
    if (sImageFormat.isEmpty())
        sImageFormat = "PNG";

    QString sFileName = GetPlaybackURL(&pginfo);

    // ----------------------------------------------------------------------
    // check to see if default preview image is already created.
    // ----------------------------------------------------------------------

    QString sPreviewFileName;

    if (nSecsIn <= 0)
    {
        nSecsIn = -1;
        sPreviewFileName = QString("%1.png").arg(sFileName);
    }
    else
    {
        sPreviewFileName = QString("%1.%2.png").arg(sFileName).arg(nSecsIn);
    }

    if (!QFile::exists( sPreviewFileName ))
    {
        // ------------------------------------------------------------------
        // Must generate Preview Image, Generate Image and save.
        // ------------------------------------------------------------------
        if (!pginfo.IsLocal() && sFileName.startsWith("/"))
            pginfo.SetPathname(sFileName);

        if (!pginfo.IsLocal())
            return QFileInfo();

        PreviewGenerator *previewgen = new PreviewGenerator( &pginfo, 
                                                             QString(), 
                                                             PreviewGenerator::kLocal);
        previewgen->SetPreviewTimeAsSeconds( nSecsIn          );
        previewgen->SetOutputFilename      ( sPreviewFileName );

        bool ok = previewgen->Run();

        previewgen->deleteLater();

        if (!ok)
            return QFileInfo();
    }

    bool bDefaultPixmap = (nWidth == 0) && (nHeight == 0);

    QString sNewFileName;

    if (bDefaultPixmap)
        sNewFileName = sPreviewFileName;
    else
    {
        sNewFileName = QString( "%1.%2.%3x%4.%5" )
                          .arg( sFileName )
                          .arg( nSecsIn   )
                          .arg( nWidth == 0 ? -1 : nWidth )
                          .arg( nHeight == 0 ? -1 : nHeight )
                          .arg( sImageFormat.toLower() );

        // ----------------------------------------------------------------------
        // check to see if scaled preview image is already created and isn't
        // out of date
        // ----------------------------------------------------------------------
        if (QFile::exists( sNewFileName ))
        {
            if (QFileInfo(sPreviewFileName).lastModified() <=
                QFileInfo(sNewFileName).lastModified())
                return QFileInfo( sNewFileName );
        }

        QImage image = QImage(sPreviewFileName);

        if (image.isNull())
            return QFileInfo();

        // We can just re-scale the default (full-size version) to avoid
        // a preview generator run
        if ( nWidth <= 0 )
            image = image.scaledToHeight(nHeight, Qt::SmoothTransformation);
        else if ( nHeight <= 0 )
            image = image.scaledToWidth(nWidth, Qt::SmoothTransformation);
        else
            image = image.scaled(nWidth, nHeight, Qt::IgnoreAspectRatio,
                                        Qt::SmoothTransformation);

        image.save(sNewFileName, sImageFormat.toUpper().toLocal8Bit());

        // Let anybody update it
        bool ret = makeFileAccessible(sNewFileName.toLocal8Bit().constData());
        if (!ret)
        {
            LOG(VB_GENERAL, LOG_ERR, "Unable to change permissions on "
                                     "preview image. Backends and frontends "
                                     "running under different users will be "
                                     "unable to access it");
        }
    }

    if (QFile::exists( sNewFileName ))
        return QFileInfo( sNewFileName );

    PreviewGenerator *previewgen = new PreviewGenerator( &pginfo,
                                                         QString(),
                                                         PreviewGenerator::kLocal);
    previewgen->SetPreviewTimeAsSeconds( nSecsIn             );
    previewgen->SetOutputFilename      ( sNewFileName        );
    previewgen->SetOutputSize          (QSize(nWidth,nHeight));

    bool ok = previewgen->Run();

    previewgen->deleteLater();

    if (!ok)
        return QFileInfo();

    return QFileInfo( sNewFileName );
}
Esempio n. 26
0
void Controller::ComputeSteerableViewMap()
{
#if 0  //soc
    if ((!_Canvas) || (!_ViewMap))
        return;

    // Build 4 nodes containing the edges in the 4 directions
    NodeGroup *ng[Canvas::NB_STEERABLE_VIEWMAP];
    unsigned i;
    real c = 32.0f/255.0f; // see SteerableViewMap::readSteerableViewMapPixel() for information about this 32.
    for (i = 0; i < Canvas::NB_STEERABLE_VIEWMAP; ++i) {
        ng[i] = new NodeGroup;
    }
    NodeShape *completeNS = new NodeShape;
    completeNS->material().setDiffuse(c,c,c,1);
    ng[Canvas::NB_STEERABLE_VIEWMAP-1]->AddChild(completeNS);
    SteerableViewMap * svm = _Canvas->getSteerableViewMap();
    svm->Reset();

    ViewMap::fedges_container& fedges = _ViewMap->FEdges();
    LineRep * fRep;
    NodeShape *ns;
    for (ViewMap::fedges_container::iterator f = fedges.begin(), fend = fedges.end();
            f != fend;
            ++f)
    {
        if ((*f)->viewedge()->qi() != 0)
            continue;
        fRep = new LineRep((*f)->vertexA()->point2d(), (*f)->vertexB()->point2d());
        completeNS->AddRep(fRep); // add to the complete map anyway
        double *oweights = svm->AddFEdge(*f);
        for (i = 0; i < (Canvas::NB_STEERABLE_VIEWMAP - 1); ++i) {
            ns = new NodeShape;
            double wc = oweights[i]*c;
            if (oweights[i] == 0)
                continue;
            ns->material().setDiffuse(wc, wc, wc, 1);
            ns->AddRep(fRep);
            ng[i]->AddChild(ns);
        }
    }

    GrayImage *img[Canvas::NB_STEERABLE_VIEWMAP];
    //#ifdef WIN32
    QGLBasicWidget offscreenBuffer(_pView, "SteerableViewMap", _pView->width(), _pView->height());
    QPixmap pm;
    QImage qimg;
    for (i = 0; i < Canvas::NB_STEERABLE_VIEWMAP; ++i) {
        offscreenBuffer.AddNode(ng[i]);
#if 0
        img[i] = new GrayImage(_pView->width(), _pView->height());
        offscreenBuffer.readPixels(0,0,_pView->width(), _pView->height(), img[i]->getArray());
#endif
        pm = offscreenBuffer.renderPixmap(_pView->width(), _pView->height());

        if (pm.isNull()) {
            if (G.debug & G_DEBUG_FREESTYLE) {
                cout << "BuildViewMap Warning: couldn't render the steerable ViewMap" << endl;
            }
        }
        //pm.save(QString("steerable") + QString::number(i) + QString(".bmp"), "BMP");
        // FIXME!! Lost of time !
        qimg = pm.toImage();
        // FIXME !! again!
        img[i] = new GrayImage(_pView->width(), _pView->height());
        for (unsigned int y = 0; y < img[i]->height(); ++y) {
            for (unsigned int x = 0; x < img[i]->width(); ++x) {
                //img[i]->setPixel(x, y, (float)qGray(qimg.pixel(x, y)) / 255.0f);
                img[i]->setPixel(x, y, (float)qGray(qimg.pixel(x, y)));
                //float c = qGray(qimg.pixel(x, y));
                //img[i]->setPixel(x, y, qGray(qimg.pixel(x, y)));
            }
        }
        offscreenBuffer.DetachNode(ng[i]);
        ng[i]->destroy();
        delete ng[i];
        // check
#if 0
        qimg = QImage(_pView->width(), _pView->height(), 32);
        for (unsigned int y = 0; y < img[i]->height(); ++y) {
            for (unsigned int x = 0; x < img[i]->width(); ++x) {
                float v = img[i]->pixel(x, y);
                qimg.setPixel(x, y, qRgb(v, v, v));
            }
        }
        qimg.save(QString("newsteerable") + QString::number(i) + QString(".bmp"), "BMP");
#endif
    }


    svm->buildImagesPyramids(img, false, 0, 1.0f);
#endif
}
Esempio n. 27
0
void CompositionRenderer::paint(QPainter *painter)
{
#if defined(QT_OPENGL_SUPPORT) && !defined(QT_OPENGL_ES)
    if (usesOpenGL()) {

        int new_pbuf_size = m_pbuffer_size;
        if (size().width() > m_pbuffer_size ||
            size().height() > m_pbuffer_size)
            new_pbuf_size *= 2;

        if (size().width() < m_pbuffer_size/2 &&
            size().height() < m_pbuffer_size/2)
            new_pbuf_size /= 2;

        if (!m_pbuffer || new_pbuf_size != m_pbuffer_size) {
            if (m_pbuffer) {
                m_pbuffer->deleteTexture(m_base_tex);
                m_pbuffer->deleteTexture(m_compositing_tex);
                delete m_pbuffer;
            }

            m_pbuffer = new QGLPixelBuffer(QSize(new_pbuf_size, new_pbuf_size), QGLFormat::defaultFormat(), glWidget());
            m_pbuffer->makeCurrent();
            m_base_tex = m_pbuffer->generateDynamicTexture();
            m_compositing_tex = m_pbuffer->generateDynamicTexture();
            m_pbuffer_size = new_pbuf_size;
        }

        if (size() != m_previous_size) {
            m_previous_size = size();
            QPainter p(m_pbuffer);
            p.setCompositionMode(QPainter::CompositionMode_Source);
            p.fillRect(QRect(0, 0, m_pbuffer->width(), m_pbuffer->height()), Qt::transparent);
            drawBase(p);
            p.end();
            m_pbuffer->updateDynamicTexture(m_base_tex);
        }

        qreal x_fraction = width()/float(m_pbuffer->width());
        qreal y_fraction = height()/float(m_pbuffer->height());

        {
            QPainter p(m_pbuffer);
            p.setCompositionMode(QPainter::CompositionMode_Source);
            p.fillRect(QRect(0, 0, m_pbuffer->width(), m_pbuffer->height()), Qt::transparent);

            p.save(); // Needed when using the GL1 engine
            p.beginNativePainting(); // Needed when using the GL2 engine

            glBindTexture(GL_TEXTURE_2D, m_base_tex);
            glEnable(GL_TEXTURE_2D);
            glColor4f(1.,1.,1.,1.);

            glBegin(GL_QUADS);
            {
                glTexCoord2f(0, 1.0);
                glVertex2f(0, 0);

                glTexCoord2f(x_fraction, 1.0);
                glVertex2f(width(), 0);

                glTexCoord2f(x_fraction, 1.0-y_fraction);
                glVertex2f(width(), height());

                glTexCoord2f(0, 1.0-y_fraction);
                glVertex2f(0, height());
            }
            glEnd();

            glDisable(GL_TEXTURE_2D);

            p.endNativePainting(); // Needed when using the GL2 engine
            p.restore(); // Needed when using the GL1 engine

            drawSource(p);
            p.end();
            m_pbuffer->updateDynamicTexture(m_compositing_tex);
        }

        painter->beginNativePainting(); // Needed when using the GL2 engine
        glWidget()->makeCurrent(); // Needed when using the GL1 engine
        glBindTexture(GL_TEXTURE_2D, m_compositing_tex);
        glEnable(GL_TEXTURE_2D);
        glEnable(GL_BLEND);
        glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
        glColor4f(1.,1.,1.,1.);
        glBegin(GL_QUADS);
        {
            glTexCoord2f(0, 1.0);
            glVertex2f(0, 0);

            glTexCoord2f(x_fraction, 1.0);
            glVertex2f(width(), 0);

            glTexCoord2f(x_fraction, 1.0-y_fraction);
            glVertex2f(width(), height());

            glTexCoord2f(0, 1.0-y_fraction);
            glVertex2f(0, height());
        }
        glEnd();
        glDisable(GL_TEXTURE_2D);
        painter->endNativePainting(); // Needed when using the GL2 engine
    } else
#endif
    {
        // using a QImage
        if (m_buffer.size() != size()) {
#ifdef Q_WS_QWS
            m_base_buffer = QPixmap(size());
            m_base_buffer.fill(Qt::transparent);
#else
            m_buffer = QImage(size(), QImage::Format_ARGB32_Premultiplied);
            m_base_buffer = QImage(size(), QImage::Format_ARGB32_Premultiplied);

            m_base_buffer.fill(0);
#endif

            QPainter p(&m_base_buffer);

            drawBase(p);
        }

#ifdef Q_WS_QWS
        m_buffer = m_base_buffer;
#else
        memcpy(m_buffer.bits(), m_base_buffer.bits(), m_buffer.byteCount());
#endif

        {
            QPainter p(&m_buffer);
            drawSource(p);
        }

#ifdef Q_WS_QWS
        painter->drawPixmap(0, 0, m_buffer);
#else
        painter->drawImage(0, 0, m_buffer);
#endif
    }
}
Esempio n. 28
0
// ============================================================================
//for drawing examples see
//  http://opencvexamples.blogspot.com/2013/10/basic-drawing-examples.html
void VideoReader::nextFrame() {
  //
  if (!playingOptions.playing) {
    return;
  }

  Mat inputFrame;
  if (!capture.read(inputFrame)) {
    emit finished() ;
    return;
  }

  int gfw = inputFrame.cols;
  int gfh = inputFrame.rows;
  float scaleFactor =1;
  if ( (inputFrame.cols>playingOptions.guiFrameWidth) ||
       (inputFrame.rows>playingOptions.guiFrameHeight) ) {
    if (playingOptions.guiFrameWidth > playingOptions.guiFrameHeight) {
      gfw = playingOptions.guiFrameWidth ;
      scaleFactor = (playingOptions.guiFrameWidth*1.0)/inputFrame.cols ;
      gfh = (int)round(inputFrame.rows*scaleFactor) ;
    }
    else {
      gfh = playingOptions.guiFrameHeight ;
      scaleFactor = (playingOptions.guiFrameHeight*1.0)/inputFrame.rows ;
      gfw = (int)round(inputFrame.cols*scaleFactor) ;
    }
  }

//  c5d(c5, QString("Calculated scale from %1x%2 to %3x%4 (%5)")
//                 .arg(inputFrame.cols).arg(inputFrame.rows)
//                 .arg(playingOptions.guiFrameWidth).arg(playingOptions.guiFrameHeight)
//                 .arg(scaleFactor) ) ;

  resize(inputFrame, frame, Size(gfw, gfh) );
  drawCornerCircles();

  switch (playingOptions.crosshairType) {
  case 0 :
    drawCrosshairType1(scaleFactor);
    break;
  case 1 :
    drawCrosshairType2(scaleFactor);
    break;
  case 2 :
    drawCrosshairType3(scaleFactor);
    break;
  }

  //
  drawSelectorRectangle(scaleFactor);
  drawFilename(scaleFactor);

  Mat fullFrame = Mat::zeros(playingOptions.guiFrameWidth, playingOptions.guiFrameHeight, CV_8UC3);  
  const int topShift = (playingOptions.guiFrameHeight-frame.rows) /2 ;
  const int lowShift = playingOptions.guiFrameHeight - topShift - frame.rows;  
//  copyMakeBorder(frame, fullFrame, topShift, lowShift, 0,0,BORDER_REPLICATE );
  copyMakeBorder(frame, fullFrame, topShift, lowShift, 0,0,BORDER_CONSTANT, Scalar( 128, 128, 0 ) );
  frame =  fullFrame;

  if (frame.channels()== 3){
    cv::cvtColor(frame, RGBframe, CV_BGR2RGB);
    img = QImage((const unsigned char*)(RGBframe.data),
                 RGBframe.cols,RGBframe.rows, RGBframe.step, QImage::Format_RGB888);
    }
    else {
      img = QImage((const unsigned char*)(frame.data),
                   frame.cols,frame.rows,QImage::Format_Indexed8);
    }

  emit processedImage(img);
}
Esempio n. 29
0
void QWSSharedMemSurface::releaseSurface()
{
    mem.detach();
    img = QImage();
}
Esempio n. 30
0
QImage LoadSavePlugin::readThumbnail(const QString& /*fileName*/)
{
	return QImage();
}