本文整理汇总了C++中QPixmap::scaledToHeight方法的典型用法代码示例。如果您正苦于以下问题:C++ QPixmap::scaledToHeight方法的具体用法?C++ QPixmap::scaledToHeight怎么用?C++ QPixmap::scaledToHeight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPixmap
的用法示例。
在下文中一共展示了QPixmap::scaledToHeight方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setData
void PlayerLabel::setData(const QPixmap& icon, const QString& text)
{
m_icon->setPixmap(icon.scaledToHeight(15, Qt::FastTransformation));
m_name->setText(text);
update();
}
示例2: loadFromFile
void MathMainWindow::loadFromFile()
{
QString fileName = QFileDialog::getOpenFileName(this,
tr("Open a picture"), "",
tr("All picture files (*)"));
if (fileName.isEmpty())
return;
else {
QFile file(fileName);
if (!file.open(QIODevice::ReadOnly)) {
QMessageBox::information(this, tr("Unable to open file"),
file.errorString());
return;
}
IplImage *image;
const QByteArray text = fileName.toLocal8Bit();
const char *data = text.data();
image = cvLoadImage(data);
c1->execute(image);
QPixmap mp;
mp.load(fileName);;
label->setPixmap(mp.scaledToHeight(150));
submitButton->setEnabled(true);
}
}
示例3: getImgCrop
QPixmap SelectedObject::getImgCrop(
shared_ptr<AnnotatorLib::Annotation> annotation, int size) const {
// TODO: getImage changes position, this is an unexpected behaviour...
// START ugly hack
// long prev_pos = project->getImageSet()->getPosition();
cv::Mat tmp = project->getImageSet()->getImage(
annotation->getFrame()->getFrameNumber());
// project->getImageSet()->gotoPosition(prev_pos);
// END ugly hack
float x = std::max(annotation->getX(), 0.f);
float y = std::max(annotation->getY(), 0.f);
float w = std::min(annotation->getWidth(), tmp.cols - x);
float h = std::min(annotation->getHeight(), tmp.rows - y);
cv::Rect rect(x, y, w, h);
cv::Mat cropped;
try {
tmp(rect).copyTo(cropped);
} catch (cv::Exception &e) {
std::cout << e.what();
}
cropped.convertTo(cropped, CV_8U);
cv::cvtColor(cropped, cropped, CV_BGR2RGB);
QImage img((const unsigned char *)(cropped.data), cropped.cols, cropped.rows,
cropped.step, QImage::Format_RGB888);
QPixmap pim = QPixmap::fromImage(img);
pim = pim.scaledToHeight(size);
return pim;
}
示例4: LoadFile
HRESULT PlaybackControls::LoadFile()
{
QPixmap picture;
picture = getPicture(mFile);
if (!picture.isNull())
{
mpParentWindow->id3Art->setPixmap(picture.scaledToHeight(128));
}
HRESULT hr = 0;
if (!mpGraph)
{
if (FAILED(hr = InitialiseFilterGraph()))
return hr;
}
if (!mGraphValid)
{
hr = mpGraph->RenderFile(mFile.toStdWString().c_str(), NULL);
if (SUCCEEDED(hr))
{
QString metadata = getArtist(mFile);
mpParentWindow->artistLabel->setText("Artist : " + metadata);
metadata = getAlbum(mFile);
mpParentWindow->albumLabel->setText("Album : " + metadata);
metadata = getTitle(mFile);
mpParentWindow->titleLabel->setText("Title : " + metadata);
mGraphValid = true;
setVolume(mVolume);
emit volumeChanged(mVolume);
}
return hr;
}
return S_OK;
}
示例5: paint
void ImageDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QStyledItemDelegate::paint(painter,option, index);
QString filename = index.data().toString();
if(filename != "")
{
QStyleOptionViewItemV4 options = option;
initStyleOption(&options, index);
QImage image(filename);
if (image.isNull())
return;
painter->save();
QSize imageSize = options.icon.actualSize(options.rect.size());
imageSize.scale(imageSize.width(), imageSize.height(), Qt::KeepAspectRatioByExpanding);
painter->translate(options.rect.left() + imageSize.width(), options.rect.top());
QPixmap pix = QPixmap::fromImage(image);
pix = pix.scaledToHeight(options.rect.height(), Qt::SmoothTransformation);
if (pix.width() > options.rect.width())
pix = pix.scaledToWidth(options.rect.width(), Qt::SmoothTransformation);
painter->drawPixmap(0,0,pix);
painter->restore();
}
}
示例6: getPixmap
QPixmap Data::getPixmap(QString name, int height)
{
QDirIterator it(appFolder->absolutePath(),QDir::Files,QDirIterator::Subdirectories);
QPixmap pixi;
QString pixiPath;
bool gefunden = false;
while(it.hasNext())
{
QString path = it.next();
if(path.contains(name.toLower() + ".png") || path.contains(name + ".png"))
{
if(gefunden)
{
qDebug() << "Die Bilddatei " + name + ".png wurde mehrfach gefunden.";
qDebug() << "Fundort 1: " + pixiPath;
qDebug() << "Fundort 2: " + path;
}
else
pixiPath = path;
if(pixi.load(path))
{
pixi = pixi.scaledToHeight(height);
}
gefunden = true;
}
}
return pixi;
}
示例7: on_edit_image_clicked
void MovieTickets::on_edit_image_clicked(){
QString image_name(this->window.edit_image_lineEdit->text());
QPixmap* image;
if(image_name.length() > 0){
QString image_full_path(this->image_path);
image_full_path.append(image_name);
image = new QPixmap(image_full_path);
if(image->isNull()){
image = new QPixmap("..\\Data\\Images\\no_movie.jpg");
}
}
else{
image = new QPixmap("..\\Data\\Images\\no_movie.jpg");
}
QPixmap aux = image->scaledToWidth(this->window.edit_image_label->width());
if(aux.height() > this->window.edit_image_label->height()){
aux = image->scaledToHeight(this->window.edit_image_label->height());
}
this->window.edit_image_label->setPixmap(aux);
}
示例8: setMultipleCover
void PropertiesDialog::setMultipleCover()
{
ComicDB lastComic = comics.last();
QPixmap last = lastComic.info.getCover(basePath);
last = last.scaledToHeight(444,Qt::SmoothTransformation);
coverImage = QPixmap::fromImage(blurred(last.toImage(),QRect(0,0,last.width(),last.height()),15));
}
示例9: paintEvent
void ThumbnailLabel::paintEvent(QPaintEvent *event)
{
int w = width();
int h = height();
QStyleOption o;
QPainter p;
event->accept();
o.initFrom(this);
p.begin(this);
style()->drawPrimitive(
QStyle::PE_Widget, &o, &p, this);
p.end();
if (!m_pixmap || m_pixmap->isNull())
{
m_pixmap = new QPixmap(sizeHint());
m_pixmap->fill(QColor(0, 0, 0, 0));
}
if (w > 0 && h > 0 && m_pixmap && !m_pixmap->isNull())
{
int newHeight = (m_pixmap->height() / static_cast<float>(m_pixmap->width())) * width();
QPixmap pixmapScaled = *m_pixmap;
QPixmap pixmap;
QPainter pScale;
int pw = 0;
int ph = 0;
unsigned *buf = new unsigned[w * h];
if (newHeight > h)
pixmapScaled = pixmapScaled.scaledToHeight(h, Qt::SmoothTransformation);
else
pixmapScaled = pixmapScaled.scaledToWidth(w, Qt::SmoothTransformation);
pw = pixmapScaled.width();
ph = pixmapScaled.height();
pixmap = QPixmap(w, h);
pixmap.fill(QColor(0, 0, 0, 0));
pScale.begin(&pixmap);
pScale.drawPixmap(QRect((w - pw) / 2, (h - ph) / 2, pw, ph), pixmapScaled, pixmapScaled.rect());
pScale.end();
if (!pixmap.isNull())
{
p.begin(this);
p.drawPixmap(rect(), pixmap, pixmap.rect());
p.end();
}
delete []buf;
}
else
QWidget::paintEvent(event);
}
示例10: setImg
void MainWindow::setImg()
{
if(!this->imgdir.dirExist || this->imgdir.fileList.length() == 0)
{
QPixmap empty;
ui->imgLabel->setPixmap(empty);
if(!this->imgdir.dirExist)
ui->imgLabel->setText("Path is invalid, is not a directory?");
else
ui->imgLabel->setText("Couldn't find any image in the directory");
return;
}
// in case index is outbounds, should not happen
if(index > imgdir.fileList.count())
return;
QString temp = imgdir.dir.absoluteFilePath(imgdir.fileList.value(index));
dbg << imgdir.fileList.value(index).toStdString().c_str() << std::endl;
dbg << temp.toStdString().c_str() << std::endl;
dbg << index << std::endl;
QPixmap imgtemp;
imgtemp.load(temp.toStdString().c_str());
if(scaleImg)
{
if(imgtemp.height() > program_settings.retrive_as_int(MAX_HEIGHT_SETT))
imgtemp = imgtemp.scaledToHeight(
program_settings.retrive_as_int(MAX_HEIGHT_SETT),
Qt::SmoothTransformation);
if(imgtemp.width() > program_settings.retrive_as_int(MAX_WIDTH_SETT))
imgtemp = imgtemp.scaledToWidth(
program_settings.retrive_as_int(MAX_WIDTH_SETT),
Qt::SmoothTransformation);
}
if(temp.endsWith(".gif",Qt::CaseInsensitive) ||
temp.endsWith(".webm",Qt::CaseInsensitive)) // not yet support for webm
{
QMovie *movie = new QMovie(temp.toStdString().c_str());
ui->imgLabel->setMovie(movie);
movie->start();
dbg << "movie" << std::endl;
}else
{
ui->imgLabel->setPixmap(imgtemp);
}
adjustScrollArea();
imgdir.saveIndex(imgdir.buildPath(
program_settings.retrive(DIR1_SETT),"i.txt").c_str(),
index);
updateFileName();
coutdebug();
}
示例11: scaledPixmap
QPixmap MovieLabel::scaledPixmap(const QPixmap& pix)
{
if (pix.isNull())
return pix;
if (pix.width()/(double)width() < pix.height()/(double)height())
return pix.scaledToHeight(height());
else
return pix.scaledToWidth(width());
}
示例12: rotateIcon
QIcon IndigoTabbar::rotateIcon(const QIcon &icon, TabPosition tabPos){
QSize sz;
for (int var = 0; var < icon.availableSizes().count(); ++var) {
if (icon.availableSizes().at(var).width() > sz.width())
sz = icon.availableSizes().at(var);
}
QPixmap pix = icon.pixmap(sz);
QTransform trans;
switch(this->tabPosition()){
case QTabWidget::East:{
switch(tabPos){
case QTabWidget::West:{
trans.rotate(180);
break;
}
case QTabWidget::North:{
trans.rotate(-90);
break;
}
default:
break;
}
break;
}
case QTabWidget::West:{
switch(tabPos){
case QTabWidget::East:{
trans.rotate(180);
break;
}
case QTabWidget::North:{
trans.rotate(+90);
break;
}
default:
break;
}
break;
}
default:
break;
}
pix = pix.transformed(trans);
pix = pix.scaledToWidth( iconScale );
pix = pix.scaledToHeight( iconScale );
return QIcon(pix);
}
示例13: onImageLoaded
void DetailView::onImageLoaded()
{
QPixmap pic;
pic.loadFromData(reply->readAll());
if (pic.height() > 300)
pic = pic.scaledToHeight(300, Qt::SmoothTransformation);
reply->deleteLater();
reply = NULL;
ui->picLabel->setPixmap(pic);
ui->picLabel->setFixedSize(pic.size());
}
示例14: RefreshLayout
void StatusScreen::RefreshLayout()
{
Builds builds = m_builders->builds();
int nCount = builds.count();
if (nCount == 0)
return;
if (m_discoveredBuilds != nCount)
{
m_discoveredBuilds = nCount;
m_DisplayLines.clear();
m_Icons.clear();
m_lineHeight = (height()-14* nCount) / nCount;
QVBoxLayout * layout = new QVBoxLayout();
for (int i=0; i<nCount; i++)
{
QHBoxLayout * line = new QHBoxLayout();
QPixmap image;
Build::TARGET_OS os = builds.at(i)->Target();
switch (os)
{
case Build::Windows: image = QPixmap(":/resources/windows-logo.png"); break;
case Build::Mac: image = QPixmap(":/resources/osx_logo.jpg"); break;
case Build::Linux: image = QPixmap(":/resources/linux-logo.jpg"); break;
default: image = QPixmap(":/resources/undefined.png");
}
QLabel * label = new QLabel(this);
QPixmap scaled = image.scaledToHeight(m_lineHeight);
label->setPixmap(scaled);
label->resize(50, 50);
line->addWidget(label);
QLineEdit * pEdit = new QLineEdit(this);
pEdit->setReadOnly(true);
m_DisplayLines.push_back(pEdit);
m_Icons.push_back(label);
line->addWidget(pEdit);
layout->addLayout(line);
}
m_mainWindow = new QWidget(this);
m_mainWindow->setStyleSheet("QWidget { background: white;}");
m_mainWindow->setLayout(layout);
setCentralWidget(m_mainWindow);
InitDisplayMessage();
}
}
示例15: loginAlias
/*
* Sets up the profile for alias and initializes wallDialog and friendDialog.
*/
void Facepamphlet::loginAlias(QString alias) {
// Setup profile image
QString profileImageSource = ":/images_section/";
if(alias.compare("Cheryl/Carol/Cristal") == 0) {
profileImageSource += "cheryl";
}
else if(alias.compare("Lana Kain") == 0) {
profileImageSource += "lana";
}
else {
profileImageSource += alias.toLower();
}
QPixmap image = QPixmap(profileImageSource);
profileIcon->setPixmap(image.scaledToHeight(std::min(200, image.height())));
// Setup selfInfo
selfInfo.image = QIcon(profileImageSource);
selfInfo.alias = alias;
// Setup visual layout settings for wallPostList
wallPostList->setIconSize(QSize(50,50));
wallPostList->setSpacing(1);
wallPostList->setWordWrap(true);
// Setup visual layout settings for wallPostList
friendsList->setIconSize(QSize(50,50));
// Initialize dialogs
// Initialize the wallDialog (for posts to wall by friends)
wallDialog = new WallDialog;
// Initialize the friendsDialog (for adding friends)
friendDialog = new FriendDialog(alias);
// Setup connections
connect(selfPostButton, SIGNAL(clicked()), this, SLOT(selfWallPost()));
connect(friendRemoveButton, SIGNAL(clicked()), this, SLOT(friendRemove()));
connect(friendAddButton, SIGNAL(clicked()), this, SLOT(showFriendDialog()));
connect(friendWallButton, SIGNAL(clicked()), this, SLOT(showWallDialog()));
// Connect with friendDialog
connect(this, SIGNAL(setDefaults()), friendDialog, SLOT(addDefaultFriends()));
connect(friendDialog, SIGNAL(addFriend(friendInfo)), this, SLOT(friendAdded(friendInfo)));
connect(this, SIGNAL(friendRemoved(friendInfo)), friendDialog, SLOT(friendRemoved(friendInfo)));
// Connect with wallDialog
connect(this, SIGNAL(friendRemoved(friendInfo)), wallDialog, SLOT(friendRemoved(friendInfo)));
connect(friendDialog, SIGNAL(addFriend(friendInfo)), wallDialog, SLOT(friendAdded(friendInfo)));
// Emit signal to cause friendDialog to add a few default friends
emit setDefaults();
// Show main window
show();
}