Exemple #1
0
void Decorator::drawPanel( Pictures& stack, const Rect& rectangle, int picId, Rects* rects )
{
  // left side
  Picture startpic( gui::rc.panel, picId);
  if( !startpic.isValid() )
    picId = 68;

  float koeff = 1.f;
  startpic.load( gui::rc.panel, picId );
  if( rects != nullptr )
     koeff = rectangle.height() / (float)startpic.height();

  int width = startpic.width() * koeff;
  if( width == 0 )
    width = 1;

  stack.append( startpic, rectangle.lefttop() );
  if( rects != nullptr )
    rects->push_back( Rect( rectangle.lefttop(), startpic.size() * koeff ) );

  // draws the inside
  Picture centerPic( gui::rc.panel, picId+1);
  for (int i = 0; i<(rectangle.width()/width-1); ++i)
  {
    stack.append( centerPic, rectangle.lefttop() + Point( (i+1)*width, 0 ) );
    if( rects != nullptr )
    {
      rects->push_back( Rect( rectangle.lefttop() + Point( (i+1)*width, 0 ),
                              centerPic.size() * koeff ) );
    }
  }

  // right side
  Picture endpic( gui::rc.panel, picId+2);
  stack.append( endpic, rectangle.lefttop() + Point( rectangle.width()-width, 0) );
  if( rects != nullptr )
  {
    rects->push_back( Rect( rectangle.lefttop() + Point( rectangle.width()-width, 0),
                            endpic.size() * koeff ) );
  }
}
Exemple #2
0
void MyVideoSurface::paint(QPainter *painter)
 {
     if (m_frame.map(QAbstractVideoBuffer::ReadOnly)) {
         QImage image(
                 m_frame.bits(),
                 m_frame.width(),
                 m_frame.height(),
                 m_frame.bytesPerLine(),
                 m_imageFormat);

         QRect r = m_targetWidget->rect();
         QPoint centerPic((qAbs(r.size().width() - image.size().width())) / 2, (qAbs(
             r.size().height() - image.size().height())) / 2);

         if (!image.isNull()) {
            painter->drawImage(centerPic,image);
         }

         m_frame.unmap();
     }
 }