本文整理汇总了C++中QPixmap::copy方法的典型用法代码示例。如果您正苦于以下问题:C++ QPixmap::copy方法的具体用法?C++ QPixmap::copy怎么用?C++ QPixmap::copy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPixmap
的用法示例。
在下文中一共展示了QPixmap::copy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setIconWithSates
void Button::setIconWithSates(const QPixmap &pixmap, IconState s1, IconState s2, IconState s3, IconState s4)
{
int a = pixmap.width();
int b = pixmap.height();
int count = qMax(a, b)/qMin(a, b);
bool hor = pixmap.height() < pixmap.width();
QPoint dp;
if (hor) {
a /= count;
dp.setX(a);
} else {
b /= count;
dp.setY(b);
}
QRect r(0, 0, a, b);
setIconForState(s1, pixmap.copy(r));
if (count > 1) {
r.translate(dp);
setIconForState(s2, pixmap.copy(r));
if (count > 2) {
r.translate(dp);
setIconForState(s3, pixmap.copy(r));
if (count > 3) {
r.translate(dp);
setIconForState(s4, pixmap.copy(r));
}
}
}
setIconState(iconState(), true); //TODO: other states set to existing icon
}
示例2: qMin
bool
Skin::handle_balance (const QPixmap &img)
{
if (img.isNull ())
return false;
QPixmap p;
QPixmapList list;
list << img.copy (9, 15, 38, 13);
for (int i = 1; i < 28; i++) {
// use p to make use of Qt implicit sharing (I think it will not
// work if appended and prepended Images are copied seperately)
p = img.copy(9, i*15, 38, 13);
list.append (p);
list.prepend (p);
}
m_pixmaplists[SLIDER_BALANCEBAR_BGS] = list;
if (img.height() > 421) {
const int h = qMin (11, img.height () - 422);
ButtonPixmaps button;
button.addPixmap (img.copy (0, 422, 14, h), ButtonPixmaps::Normal);
button.addPixmap (img.copy (15, 422, 14, h), ButtonPixmaps::Pressed);
m_buttons[SLIDER_BALANCEBAR_BUTTON] = button;
}
return true;
}
示例3: initPixmap
//______________________________________________________________
void TileSet::initPixmap( PixmapList& pixmaps, const QPixmap &source, int width, int height, const QRect &rect)
{
QSize size( width, height );
if( !( size.isValid() && rect.isValid() ) )
{
pixmaps.append( QPixmap() );
} else if( size != rect.size() ) {
const qreal dpiRatio( devicePixelRatio( source ) );
const QRect scaledRect( rect.topLeft()*dpiRatio, rect.size()*dpiRatio );
const QSize scaledSize( size*dpiRatio );
const QPixmap tile( source.copy(scaledRect) );
QPixmap pixmap( scaledSize );
pixmap.fill(Qt::transparent);
QPainter painter(&pixmap);
painter.drawTiledPixmap(0, 0, scaledSize.width(), scaledSize.height(), tile);
setDevicePixelRatio( pixmap, dpiRatio );
pixmaps.append( pixmap );
} else {
const qreal dpiRatio( devicePixelRatio( source ) );
const QRect scaledRect( rect.topLeft()*dpiRatio, rect.size()*dpiRatio );
QPixmap pixmap( source.copy( scaledRect ) );
setDevicePixelRatio( pixmap, dpiRatio );
pixmaps.append( pixmap );
}
}
示例4: loadBoard
bool BoardTheme::loadBoard(const QString& board)
{
if(board.isEmpty())
{
m_boardFilename = board;
updateSquares();
return true;
}
QString themePath = AppSettings->getBoardPath(board);
QPixmap big;
if(!big.load(themePath))
{
return false;
}
int realsize = big.height() / 2;
if(realsize != big.width())
{
return false;
}
m_originalSquare[0] = big.copy(0, 0, realsize, realsize);
m_originalSquare[1] = big.copy(0, realsize, realsize, realsize);
m_boardFilename = themePath;
updateSquares();
return true;
}
示例5: updateStandardIcons
void pDockWidgetTitleBar::updateStandardIcons()
{
const QSize size( 16, 16 );
QPixmap pixmap;
QRect rect( QPoint(), iconSize() );
QTransform transform;
transform.rotate( 90 );
pixmap = style()->standardIcon( QStyle::SP_ToolBarHorizontalExtensionButton, 0, widgetForAction( aOrientation ) ).pixmap( size );
rect.moveCenter( pixmap.rect().center() );
pixmap = pixmap.copy( rect );
pixmap = pixmap.transformed( transform, Qt::SmoothTransformation );
aOrientation->setIcon( pixmap );
pixmap = style()->standardIcon( QStyle::SP_TitleBarNormalButton, 0, widgetForAction( aFloat ) ).pixmap( size );
rect.moveCenter( pixmap.rect().center() );
pixmap = pixmap.copy( rect );
aFloat->setIcon( pixmap );
pixmap = style()->standardIcon( QStyle::SP_TitleBarCloseButton, 0, widgetForAction( aClose ) ).pixmap( size );
rect.moveCenter( pixmap.rect().center() );
pixmap = pixmap.copy( rect );
aClose->setIcon( pixmap );
}
示例6: getIcon
MyIcon RecordingDelegate::getIcon(QPixmap pix)
{
MyIcon icon;
int w = pix.width();
int h = pix.height();
icon.setPixmap(pix.copy(0, 0, w, h/4 ), MyIcon::Normal, MyIcon::Off);
icon.setPixmap(pix.copy(0, h/4, w, h/4 ), MyIcon::MouseOver, MyIcon::Off);
icon.setPixmap(pix.copy(0, h/2, w, h/4 ), MyIcon::MouseDown, MyIcon::Off);
icon.setPixmap(pix.copy(0, 3*h/4, w, h/4 ), MyIcon::Disabled, MyIcon::Off);
return icon;
}
示例7: setKnobIcon
void PanelSeeker::setKnobIcon( QPixmap pix )
{
int w = pix.width();
int h = pix.height();
knobPix.setPixmap(pix.copy(0, 0, w, h/4 ), MyIcon::Normal, MyIcon::Off);
knobPix.setPixmap(pix.copy(0, h/4, w, h/4 ), MyIcon::MouseOver, MyIcon::Off);
knobPix.setPixmap(pix.copy(0, h/2, w, h/4 ), MyIcon::MouseDown, MyIcon::Off);
knobPix.setPixmap(pix.copy(0, 3*h/4, w, h/4 ), MyIcon::Disabled, MyIcon::Off);
knobCurrentPix = knobPix.pixmap(MyIcon::Normal, MyIcon::Off);
/* setSliderValue(minimum()); */
setState(Normal, true);
}
示例8:
bool
Skin::handle_monoster (const QPixmap &img)
{
if (img.isNull ())
return false;
m_items[MONO_1] = img.copy(29, 0, 27, 12);
m_items[MONO_0] = img.copy(29, 12, 27, 12);
m_items[STEREO_1] = img.copy(0, 0, 29, 12);
m_items[STEREO_0] = img.copy(0, 12, 29, 12);
return true;
}
示例9: initFadeTypes
static void initFadeTypes (void)
{
if (g_fadeTypes.isEmpty()) {
const QPixmap pmFadeIn(":/images/fadeIn.png");
const QPixmap pmFadeOut(":/images/fadeOut.png");
for (int i = 0; g_aFadeTypeNames[i]; ++i) {
FadeTypeInfo& info = g_fadeTypes[i];
info.name = QObject::tr(g_aFadeTypeNames[i], "fadeType");
info.iconFadeIn = pmFadeIn.copy(i << 4, 0, 16, 16);
info.iconFadeOut = pmFadeOut.copy(i << 4, 0, 16, 16);
}
}
}
示例10: setMultiIcon
void ToolButton::setMultiIcon(const QPixmap &image)
{
int w = image.width();
int h = image.height();
m_normalIcon = image.copy(0, 0, w, h / 4);
m_hoverIcon = image.copy(0, h / 4, w, h / 4);
m_activeIcon = image.copy(0, h / 2, w, h / 4);
m_disabledIcon = image.copy(0, 3 * h / 4, w, h / 4);
m_usingMultiIcon = true;
setFixedSize(m_normalIcon.size());
}
示例11: transmettreAttaque
void Case::transmettreAttaque(int nbPV, Entite*e) {
if (m_occupant!=NULL) {
if(e->Getnom() == "Chevalier"
|| e->Getnom() == "Archer"
|| e->Getnom() == "Pretre"
|| e->Getnom() == "Magicien"
|| e->Getnom() == "Voleur"
|| e->Getnom() == "Guerrier")
m_occupant->modifierVie(nbPV + ((Unite*)e)->getBonusUnite()[1]);
else
{
m_occupant->modifierVie(nbPV);
}
if (!contientBatiment()&&isOccupee() &&getOccupant()->getVie()==0){
QPixmap *tombe;
tombe=new QPixmap("images/Coffin.png");
(getOccupant())->setPixmap(tombe->copy(0,96,32,32));
getOccupant()->setFlag(QGraphicsItem::ItemIsSelectable,false);
setOccupant(NULL);
}
else if(isOccupee() && getOccupant()->Getnom()== "Chateau" && getOccupant()->getVie()==0)
{
QPixmap *tombe;
tombe=new QPixmap("images/ChateauDetruit.png");
(getOccupant())->setPixmap(tombe->copy(0,96,32,32));
QMessageBox popup;
popup.setText("Victoire " + this->getOccupant()->getJoueur()->getPseudo() + "!");
popup.exec();
this->getOccupant()->getPosition()[0]->parent()->finDuJeu();
}
else if(isOccupee() && getOccupant()->Getnom() == "Tour" && getOccupant()->getVie()==0)
{
QPixmap *tombe;
tombe=new QPixmap("images/TourDetruite.png");
(getOccupant())->setPixmap(tombe->copy(0,96,32,32));
this->parent()->supprimerTour((Batiment*)this->getOccupant());
getOccupant()->setFlag(QGraphicsItem::ItemIsSelectable,false);
setOccupant(NULL);
}
}
}
示例12: genFrames
void Scene::genFrames()
{
QPixmap pixmap = QPixmap( QString( ":Textures/pla1.bmp" ) );
const unsigned int step = pixmap.width() / 4;
QPixmap copyPixmap;
for ( unsigned int i = 0; i < 4; ++i ) {
copyPixmap = pixmap.copy( i * step, 0, step, step );
framesToRight.push_back( copyPixmap );
}
for( unsigned int i = 0; i < framesToRight.size(); ++i ) {
QImage image = framesToRight[i].toImage();
framesToLeft.push_back( QPixmap::fromImage( image.mirrored( true, false ) ) );
}
for( unsigned int i = 0; i < framesToRight.size(); ++i ) {
QPixmap rotatedPixmap( framesToRight[i] );
QMatrix rm;
rm.rotate( 90 );
framesToDown.push_back( rotatedPixmap.transformed( rm ) );
}
for( unsigned int i = 0; i < framesToDown.size(); ++i ) {
QImage image = framesToDown[i].toImage();
framesToUp.push_back( QPixmap::fromImage( image.mirrored( false, true ) ) );
}
}
示例13: QPixmap
QPixmap *BoardPixmaps::getBoardPixmap(int x, int y, double w, double h)
{
if (w != width || h != height) {
width = w;
height = h;
clearPix();
}
QPixmap *scPixmap = scaledPixmap.value(0, NULL);
if (scPixmap == NULL) {
// Масштабирование картинки под целое количество единиц ширины и высоты
scPixmap = new QPixmap();
w_cnt = boardPixmap->width() / w;
h_cnt = boardPixmap->height() / h;
// Тут можно ограничить максимальное количество кусков
//--
*scPixmap = boardPixmap->scaled(QSize(w_cnt * w, h_cnt * h), Qt::IgnoreAspectRatio, Qt::FastTransformation);
scaledPixmap[0] = scPixmap;
}
int curr_key = (x % w_cnt) * 100 + (y % h_cnt) + 1;
QPixmap *scPixmap2 = scaledPixmap.value(curr_key, NULL);
if (scPixmap2 == NULL) {
// Вырезаем необходимый кусок картинки
scPixmap2 = new QPixmap();
int xpixpos = (x % w_cnt) * w;
int ypixpos = (y % h_cnt) * h;
*scPixmap2 = scPixmap->copy(xpixpos, ypixpos, w, h);
scaledPixmap[curr_key] = scPixmap2;
}
return scPixmap2;
}
示例14: outlineText
QPixmap NumberChoiceLive::outlineText(QString text) {
QPixmap *canvas = new QPixmap(200,200);
canvas->fill(Qt::transparent);
QFont font;
font.setPointSize(60);
font.setBold(true);
QPen pen; // Give a nice black outline
pen.setWidth(5);
QPainterPath path; // Have to use path to get an outline
path.addText(0,90, font, text);
QPainter painter(canvas); // Make the outlines text
painter.setBrush(QBrush(Qt::yellow));
painter.setPen(pen);
painter.setRenderHint(QPainter::Antialiasing);
painter.drawPath(path);
painter.setFont(font); // Remove the rubbish from the image so we only have the text
QRect textBounds = painter.boundingRect(canvas->rect(), 0, text);
return canvas->copy(textBounds);
}
示例15: outlineText
QPixmap ScoresLive::outlineText(QString text) {
QPixmap *canvas = new QPixmap(1000,1000);
canvas->fill(Qt::transparent);
QFont font;
font.setPointSize(150);
font.setBold(true);
QFontMetrics fontMetrics(font); // So we can determine the position of the text. We use the ascent function, this gives the distance between the baseline of the text and highest point.
QPen pen; // Give a nice black outline
pen.setWidth(10);
QPainterPath path; // Have to use path to get an outline
path.addText(0,fontMetrics.ascent(), font, text); // TODO Find out why I have to minus 10 from the ascent, I'm sure it's very simple, but a task for another day I think.
QPainter painter(canvas); // Make the outlines text
painter.setBrush(QBrush(Qt::green));
painter.setPen(pen);
painter.setRenderHint(QPainter::Antialiasing);
painter.drawPath(path);
painter.setFont(font); // Remove the rubbish from the image so we only have the text
QRect textBounds = painter.boundingRect(canvas->rect(), 0, text);
return canvas->copy(textBounds);
}