PDA

View Full Version : Pixmap Overlay



ToddAtWSU
15th June 2006, 15:17
I am finally back working on my video player and I am still having problems with my overlay. I am rendering the video using DirectShow so I can enable frame skipping. What I am trying to do is click on a spot on the video, and display a red dot to show where I clicked. I thought I would create a QPixmap with a fill color of Qt::transparent so I could display this over the video. I then thought I could add the red dot to the overlay using DrawPoint with a QPainter created saying QPainter* paintOverlay = new QPainter(mpOverlay), but this did not work. The only way I can get the red point to display is on the frame itself and not the overlay or video that I display inside the frame. And everytime the update occurs, it puts the video on the screen for a split second and then shows the empty frame with its red dot. Is there anyway to add this red dot to the overlay and then display this almost transparent overlay on top of the video window? Thanks for your help!

munna
15th June 2006, 15:29
see if this (http://doc.trolltech.com/qq/qq16-fader.html) helps.

ToddAtWSU
15th June 2006, 18:03
I don't think this is really going to help me. I have looked at the code and run the program, but it just makes something fade from nothing to being 100% visible. But it never shows the old image and the new image at the same time. I want my video to be shown at all times and the red dot to be displayed on top of it. I thought a transparent QPixmap with one red pixel would be able to work for this, but I am having problems getting the red pixel to draw on the transparent QPixmap and display over the video. Thanks again for your help!

wysota
15th June 2006, 18:17
Some ActiveX controls might not allow overlays. First thing you should try is to decode a frame, draw it on a QImage, draw a red dot on the image and display the result on your widget. Of course it might prove to be too slow, but it's worth to try it.

ToddAtWSU
15th June 2006, 18:21
Should it matter what the activeX control wants since I have my DirectShow object inside a QAxWidget? I would think the QAxWidget would allow an alomst-transparent QPixmap to be displayed over it. Or does the QAxWidget have no control or say over this? Thanks again but I will take what you said into consideration!

ToddAtWSU
22nd June 2006, 21:19
After looking through adding an overlay through some DirectShow commands, I discovered DirectShow's functionality to add the overlay was not sufficient enough to handle my needs. Right now, I am trying to just create an overlay to put on top of my buttons to get a handle on how to use transparent overlays. Here is essentially what I want it to do.

I intialize a couple things like this:

QWidget* privateLayoutWidget = new QWidget( this );
privateLayoutWidget->setGeometry( QRect( 182, 429, 248, 40 ) );
mpButtonLayout = new QHBoxLayout( privateLayoutWidget );

QSize videoButtonSize( 30, 25 );
mpGoBeginningButton = new QToolButton( privateLayoutWidget );
mpGoBeginningButton->setMinimumSize(videoButtonSize );
QFont webDings_font( "Webdings", 12 );
mpGoBeginningButton->setFont( webDings_font );
mpGoBeginningButton->setText( "9" );
mpGoBeginningButton->setToolTip( "Jump to beginning of video" );
mpButtonLayout->addWidget( mpGoBeginningButton );
...
mpTest = new QPixmap( 500, 500 );
mpTest->fill( Qt::transparent );

Then to draw my pixmap onto my object, I do the following:

if( event->type( ) == QEvent::Paint )
{
if( pMediaSeeking != NULL )
{
QPainter* painter2;
painter2 = new QPainter( mpTest );
painter2->setPen( QPen( Qt::green, 3 ) );
for( int i = 0 ; i < azElPoints.size( ) ; i++ )
{
if( azElPoints[i].frameNumber == getCurrentFrame( ) )
{
if( erasePoint == true )
{
// Fill the overlay with transparent again since using a
// transparent pen does not remove the red dot.
mpTest->fill( Qt::transparent );
}
painter2->drawPoint( azElPoints[i].xPos, azElPoints[i].yPos );
}
}
//updateAlphaBitmap( );
repaintWindow( );
delete painter2;
QPainter *painter = new QPainter( mpGoBeginningButton );
painter->drawPixmap( 0, 0, *mpTest );
delete painter;
return true;
}
}

Is this the correct way to try and make a transparent QPixmap because if so, I cannot get it to work. I am thinking maybe I should do something other than a fill( transparent ) to make the transparent QPixmap besides the occasional dot of color, but I do not know what it is that I am missing. Any more guidance with this would be great! Thanks!