void E1DialerButton::generateBgPixmap( const E1DialerButton::State& st ) { QPixmap pm; if( !m_bgImage.isNull() && m_colorForState[st].isValid() ) { QImage tmpImg = m_bgImage.copy(); ThemePixmapItem::colorizeImage(tmpImg, m_colorForState[st], 255, true); pm = pm.fromImage(tmpImg); m_bgForState[st] = pm; } else if( !m_bgImage.isNull() ) { pm = pm.fromImage( m_bgImage ); m_bgForState[st] = pm; } }
void ribi::QtBoenkenMainDialog::Paint( QPixmap& pixmap, const unsigned char r, const unsigned char g, const unsigned char b, const unsigned char a) { const int width = pixmap.width(); const int height = pixmap.height(); QImage image = pixmap.toImage(); assert(image.bytesPerLine() / width == 4 && "Assume there are 4 bytes per pixel"); for (int y=0; y!=height; ++y) { unsigned char * const line = static_cast<unsigned char *>(image.scanLine(y)); for (int x=0; x!=width; ++x) { line[x*4+3] = a; //Alpha value line[x*4+2] = r; //Red line[x*4+1] = g; //Green line[x*4+0] = b; //Blue } } pixmap = pixmap.fromImage(image); }
//Mostrara imagen recojida del socket void ViewerWindow::mostrar_captura_s(const QImage &image) { QPixmap pixmap; pixmap=pixmap.fromImage(image); ui->label->setPixmap(pixmap); }
void ScrollBox::setThumbnail(QPixmap img) { QPixmap bkPixmap = img.fromImage(img.toImage().scaled(size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); QPalette palette; palette.setBrush(backgroundRole(), bkPixmap); setPalette(palette); // Qt3 //setPaletteBackgroundPixmap(img.fromImage(img.toImage().scaled(size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation))); }
void ICQPicture::setPict(QImage &img) { if (img.isNull()){ lblPict->setText(i18n("Picture is not available")); return; } QPixmap pict; pict.fromImage(img); lblPict->setPixmap(pict); lblPict->setMinimumSize(pict.size()); }
// experimental QPixmap PrintLayout::convertPixmapToGrayscale(QPixmap pixmap) const { QImage image = pixmap.toImage(); int gray, width = pixmap.width(), height = pixmap.height(); for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { gray = qGray(image.pixel(i, j)); image.setPixel(i, j, qRgb(gray, gray, gray)); } } return pixmap.fromImage(image); }
//Procesar los frame recibidos por la cam para mostrarlos y modificarlo(pintar sobre ellos) void ViewerWindow::image_s(const QImage &image) { //Procesar la image para poder pintar sobre ella la hora QTime time = QTime::currentTime(); QString timeString = time.toString(); QPixmap pixmap; pixmap=pixmap.fromImage(image); QPainter paint(&pixmap); paint.setPen(Qt::green); paint.drawText(0,0,pixmap.width(),pixmap.height(),Qt::AlignRight |Qt::AlignBottom ,timeString,0); ui->label->setPixmap(pixmap); }
void setPixmap(const QPixmap &_pm) { QPixmap pm; QImage i = _pm.toImage(); i = i.scaled(i.width() * 2, i.height() * 2); pm.fromImage(i); TrayIconPrivate::setPixmap(pm); // thanks to Robert Spier for this: // for some reason the repaint() isn't being honored, or isn't for // the icon. So force one on the widget behind the icon repaint(); }
void PackThemeImageWidget::imageSelectionChanged(const QString & szImagePath) { QImage pix(szImagePath); if(!pix.isNull()) { QPixmap out; if(pix.width() > 300 || pix.height() > 225) { pix=pix.scaled(300,225,Qt::KeepAspectRatio,Qt::SmoothTransformation); out=out.fromImage(pix); } else { out=out.fromImage(pix); } m_pImageLabel->setPixmap(out); return; } QMessageBox::critical(this,__tr2qs_ctx("Export Theme - KVIrc","theme"),__tr2qs_ctx("Failed to load the selected image","theme"), QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton); m_pImageSelector->setSelection(""); m_pImageLabel->setPixmap(QPixmap()); }
QPixmap MusicItem::changeColor(const QPixmap &pixmap, QColor c) { QImage image = pixmap.toImage(); QRgb old; int width = pixmap.width(); int height = pixmap.height(); for (int i = 0; i < width; ++i) { for (int j = 0; j < height; ++j) { old = image.pixel(i, j); if (qAlpha(old) == 255) image.setPixel(i, j, c.rgb()); } } return pixmap.fromImage(image); }
QPixmap TransparentTop::background(const QColor &c) { #if COMPAT_QT_VERSION < 0x030000 QWidget *w = (QWidget*)parent(); const QPixmap *bg = w->backgroundPixmap(); if (bg == NULL) return QPixmap(); QImage img = bg->toImage(); #else if (bg.isNull()) return QPixmap(); QImage img = bg.toImage(); #endif img = KImageEffect::fade(img, m_transparent, c); QPixmap res; res.fromImage(img); return res; }
void QImage2MatDialog::qimageShow(QImage& qImage, QGraphicsView*& graphView) { int imageWidth = qImage.width(); int imageHeight = qImage.height(); int viewWidth = ui->graphicsView_qimg->width(); int viewHight = ui->graphicsView_qimg->height(); QPixmap pixMap; pixMap = pixMap.fromImage(qImage.scaled(viewWidth, viewHight, Qt::KeepAspectRatioByExpanding)); #if 0 qDebug() << viewWidth << " " << viewHight; #endif QGraphicsScene *graphicsViewScene = new QGraphicsScene(); graphicsViewScene->setSceneRect(0, 0, viewWidth, viewHight); graphicsViewScene->clear(); graphicsViewScene->addPixmap(pixMap); graphView->setScene(graphicsViewScene); graphView->show(); }
bool packageThemes( const QString &szPackagePath, const QString &szPackageName, const QString &szPackageVersion, const QString &szPackageDescription, const QString &szPackageAuthor, const QString &szPackageImagePath, KviPointerList<KviThemeInfo> &lThemeInfoList, QString &szError ) { if(szPackagePath.isEmpty()) { szError = __tr2qs_ctx("Invalid empty package path","theme"); return false; } if(szPackageName.isEmpty()) { szError = __tr2qs_ctx("Invalid empty package name","theme"); return false; } QPixmap out; if(!szPackageImagePath.isEmpty()) { QImage pix(szPackageImagePath); if(pix.isNull()) { szError = __tr2qs_ctx("Failed to load the selected image: please fix it","theme"); return false; } if((pix.width() > 300) || (pix.height() > 225)) out = out.fromImage(pix.scaled(300,225,Qt::KeepAspectRatio)); else out=out.fromImage(pix); } KviPackageWriter f; f.addInfoField("PackageType","ThemePack"); f.addInfoField("ThemePackVersion",KVI_CURRENT_THEME_ENGINE_VERSION); f.addInfoField("Name",szPackageName); f.addInfoField("Version",szPackageVersion.isEmpty() ? "1.0.0" : szPackageVersion); f.addInfoField("Author",szPackageAuthor); f.addInfoField("Description",szPackageDescription); // this is the equivalent to an empty date.toString() call, but it's needed // to ensure qt4 will use the default() locale and not the system() one f.addInfoField("Date",QDateTime::currentDateTime().toString(Qt::ISODate)); f.addInfoField("Application","KVIrc " KVI_VERSION "." KVI_SOURCES_DATE); if(!out.isNull()) { QByteArray * pba = new QByteArray(); QBuffer buffer(pba,0); buffer.open(QIODevice::WriteOnly); out.save(&buffer,"PNG"); buffer.close(); f.addInfoField("Image",pba); // cool :) [no disk access needed] } QString szTmp; szTmp.setNum(lThemeInfoList.count()); f.addInfoField("ThemeCount",szTmp); int iIdx = 0; for(KviThemeInfo * pInfo = lThemeInfoList.first();pInfo;pInfo = lThemeInfoList.next()) { if(pInfo->name().isEmpty()) { szError = __tr2qs_ctx("Invalid theme name","theme"); return false; } if(pInfo->version().isEmpty()) { szError = __tr2qs_ctx("Invalid theme version","theme"); return false; } QString szSubdir = pInfo->name() + QString("-") + pInfo->version(); szSubdir.replace(QRegExp("[^a-zA-Z0-9_\\-.][^a-zA-Z0-9_\\-.]*"),"_"); szTmp = QString("Theme%1Name").arg(iIdx); f.addInfoField(szTmp,pInfo->name()); szTmp = QString("Theme%1Version").arg(iIdx); f.addInfoField(szTmp,pInfo->version()); szTmp = QString("Theme%1Description").arg(iIdx); f.addInfoField(szTmp,pInfo->description()); szTmp = QString("Theme%1Date").arg(iIdx); f.addInfoField(szTmp,pInfo->date()); szTmp = QString("Theme%1Subdirectory").arg(iIdx); f.addInfoField(szTmp,szSubdir); szTmp = QString("Theme%1Author").arg(iIdx); f.addInfoField(szTmp,pInfo->author()); szTmp = QString("Theme%1Application").arg(iIdx); f.addInfoField(szTmp,pInfo->application()); szTmp = QString("Theme%1ThemeEngineVersion").arg(iIdx); f.addInfoField(szTmp,pInfo->themeEngineVersion()); QPixmap pixScreenshot = pInfo->smallScreenshot(); if(!pixScreenshot.isNull()) { szTmp = QString("Theme%1Screenshot").arg(iIdx); QByteArray * pba = new QByteArray(); QBuffer bufferz(pba,0); bufferz.open(QIODevice::WriteOnly); pixScreenshot.save(&bufferz,"PNG"); bufferz.close(); f.addInfoField(szTmp,pba); } if(!f.addDirectory(pInfo->directory(),szSubdir)) { szError = __tr2qs_ctx("Packaging failed","theme"); szError += ": "; szError += f.lastError(); return false; } iIdx++; } if(!f.pack(szPackagePath)) { szError = __tr2qs_ctx("Packaging failed","theme"); szError += ": "; szError += f.lastError(); return false; } return true; }
QPixmap Image::pixmap() { QPixmap pixmap; return pixmap.fromImage(m_image) ; }
MainWindow::MainWindow(QWidget * parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this) ; device = new epocDevice() ; th = new epocThread(device) ; timerDraw = new QTimer() ; timerDraw->setInterval(100) ; ui->graphSignal->setScene(&sceneSignal) ; QPixmap pix ; pix.fromImage(QImage("../epocWatch/images/head.jpg")) ; QGraphicsScene scenePosition ; ui->graphPosition->setScene(&scenePosition) ; scenePosition.addPixmap(pix) ; vecDataAF3.fill(0, 1024) ; vecDataAF4.fill(0, 1024) ; vecDataF3.fill(0, 1024) ; vecDataF4.fill(0, 1024) ; vecDataF7.fill(0, 1024) ; vecDataF8.fill(0, 1024) ; vecDataFC5.fill(0, 1024) ; vecDataFC6.fill(0, 1024) ; vecDataT7.fill(0, 1024) ; vecDataT8.fill(0, 1024) ; vecDataP7.fill(0, 1024) ; vecDataP8.fill(0, 1024) ; vecDataO1.fill(0, 1024) ; vecDataO2.fill(0, 1024) ; vecFoufou.fill(0, 1024) ; isCheckedAF34 = false ; isCheckedF34 = false ; isCheckedF78 = false ; isCheckedFC56 = false ; isCheckedO12 = false ; isCheckedP78 = false ; isCheckedT78 = false ; ui->progressDelta->setStyleSheet(ui->progressDelta->property("defaultStyleSheet").toString() + " QProgressBar::chunk { background: yellow; }") ; ui->progressTheta->setStyleSheet(ui->progressTheta->property("defaultStyleSheet").toString() + " QProgressBar::chunk { background: orange; }") ; ui->progressAlpha->setStyleSheet(ui->progressAlpha->property("defaultStyleSheet").toString() + " QProgressBar::chunk { background: blue; }") ; ui->progressBeta->setStyleSheet(ui->progressBeta->property("defaultStyleSheet").toString() + " QProgressBar::chunk { background: green; }") ; ui->progressGamma->setStyleSheet(ui->progressGamma->property("defaultStyleSheet").toString() + " QProgressBar::chunk { background: red; }") ; connect(ui->cbAF34, SIGNAL(clicked()), this, SLOT(slotChecked())) ; connect(ui->cbF34, SIGNAL(clicked()), this, SLOT(slotChecked())) ; connect(ui->cbF78, SIGNAL(clicked()), this, SLOT(slotChecked())) ; connect(ui->cbFC56, SIGNAL(clicked()), this, SLOT(slotChecked())) ; connect(ui->cbO12, SIGNAL(clicked()), this, SLOT(slotChecked())) ; connect(ui->cbP78, SIGNAL(clicked()), this, SLOT(slotChecked())) ; connect(ui->cbT78, SIGNAL(clicked()), this, SLOT(slotChecked())) ; connect(ui->cbAll, SIGNAL(clicked()), this, SLOT(slotCheckedAll())) ; connect(timerDraw, SIGNAL(timeout()), this, SLOT(slotDraw())) ; connect(ui->pbConnect, SIGNAL(clicked()), this, SLOT(slotConnect())) ; connect(ui->pbStart, SIGNAL(clicked()), this, SLOT(slotStart())) ; connect(ui->pbQuit, SIGNAL(clicked()), this, SLOT(close())) ; }
void wifiscanssid::scanWifi() { QString strength, ssid, tmp, FileLoad; QStringList ifconfout, ifline; int newStrength; int foundItem = 0; // Clear the list box listWifi->clear(); textTop->setText(tr("Scanning for wireless networks...") ); // Start the scan and get the output ifconfout = pcbsd::Utils::runShellCommand("ifconfig -v " + DeviceName + " up list scan"); //display the info for each wifi access point for(int i=1; i<ifconfout.size(); i++){ //Skip the header line by starting at 1 ifline = NetworkInterface::parseWifiScanLine(ifconfout[i],true); //get a single line //save the info for this wifi ssid = ifline[0]; strength = ifline[4]; //determine the icon based on the signal strength tmp = strength.section("%",0,0,QString::SectionSkipEmpty); //remove the % from the end newStrength = tmp.toInt(); //integer strength value bool duplicateSSID = FALSE; for ( int z = 0 ; z < listWifi->count() ; z++){ qDebug() << listWifi->item(z)->text() << ssid; if ( listWifi->item(z)->text().contains(ssid+" (") ){ duplicateSSID = TRUE; break; } } if( !duplicateSSID ){ if ( newStrength < 25 ){ FileLoad= PROGPATH + "/pics/tray_wifi.png"; } else if ( newStrength < 50 ) { FileLoad= PROGPATH + "/pics/tray_wifi30.png"; } else if ( newStrength < 75 ) { FileLoad= PROGPATH + "/pics/tray_wifi60.png"; } else { FileLoad= PROGPATH + "/pics/tray_wifi85.png"; } QImage *Icon = new QImage(FileLoad); QPixmap PixmapIcon; PixmapIcon.fromImage(Icon->scaled(22,22)); //Add the wifi access point to the list listWifi->addItem(new QListWidgetItem(PixmapIcon, ssid + " (signal strength: " +strength + ")") ); foundItem = 1; //set the flag for wifi signals found }else{ //if the new signal is stronger, change the current label to reflect it } } if ( foundItem == 1 ){ textTop->setText(tr("Select a wireless network to connect.") ); listWifi->setCurrentRow(0); pushSelect->setEnabled(TRUE); } else { textTop->setText(tr("No wireless networks found!") ); pushSelect->setEnabled(FALSE); } }
void Techni::slotOpenImage(){ QImage image("myCanvas.png"); QPixmap pixMap; pixMap.fromImage(image); myCanvas->getScene()->addPixmap(pixMap); }
dlpy_main::dlpy_main(int state,string filename,QWidget *parent) : QMainWindow(parent), ui(new Ui::dlpy_main) { ui->setupUi(this); setGeometry(697, 50, 220, 480); wid = new widget(); wid->setWindowFlags(Qt::FramelessWindowHint); wid->show(); frame = new dlpy_frames(state,filename); frame->setWindowFlags(Qt::FramelessWindowHint); //隐藏标题栏 frame->show(); connect(this,SIGNAL(setparasignal(int,int,int,int,int)),frame,SLOT(setparaslot(int,int,int,int,int))); connect(frame,SIGNAL(setalertsignal(int)),this,SLOT(setalertslot(int))); //每一帧图像信号槽初始化警报参数 connect(this,SIGNAL(setlinesignal(int)),frame,SLOT(setlineslot(int))); ///////////////////////////////////////////////////////////////////////////////////////////// //img_alert: 显示所有 //img_alert_1: 红色警报 //img_alert_3: 无警报 //img_temp:所有 //img:所有 //////////////////////////////////////////////////////////////////////////////////////////// img_alert = cv::imread("/home/hugo/code/bin/alert.bmp"); img_alert_1 = cv::imread("/home/hugo/code/bin/alert_2.bmp"); img_alert_2 = cv::imread("/home/hugo/code/bin/alert_3.bmp"); img_temp = cv::imread("/home/hugo/code/bin/alert.bmp"); roi_l=Rect(0, 0, (img_alert.cols-1)/2, img_alert.rows-1); roi_r=Rect((img_alert.cols-1)/2, 0, (img_alert.cols-1)/2, img_alert.rows-1); QGraphicsScene *scene = new QGraphicsScene; QImage img; img.load("/home/hugo/code/bin/alert.bmp"); QPixmap mp; mp=mp.fromImage(img); times_alert=0; last_alert=0; w0=weatherobj(10,20,30,40,50); w1=weatherobj(60,70,80,90,100); w2=weatherobj(100,110,120,130,140); w3=weatherobj(10,60,0,42,100); w4=weatherobj(150,160,170,180,190); w5=weatherobj(200,210,220,230,240); w6=weatherobj(10,25,10,32,90); w7=weatherobj(200,240,220,250,123); QImage *qimg=new QImage; *qimg=mat2qimage(img_temp); /*cvtColor(img_temp, img_temp, CV_BGR2RGB); qimg = new QImage((unsigned char*)img_temp.data, // uchar* data img_temp.cols, img_temp.rows, // width height img_temp.step, //bytesPerLine QImage::Format_RGB888); //format*/ scene->addPixmap(QPixmap::fromImage(*qimg)); ui->graphicsView->setScene(scene); ui->graphicsView->resize(qimg->width() + 10, qimg->height() + 10); ui->graphicsView->show(); timer = new QTimer(this); timer->setInterval(30); connect(timer,SIGNAL(timeout()),this,SLOT(alertFrame())); //每隔30s读取一次报警图片 timer->start(); }