| Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date | |
| All threads index page 2 | |
Sebastian,
Could run the attached C++ file, on two images. When I do, its pretty clear, the alpha channel is not being kept.
Scott
> -----Original Message-----
> From: Scott Aron Bloom
> Sent: Thursday, December 07, 2006 2:35 AM
> To: Scott Aron Bloom; Sebastien Emonet; qt-interest@xxxxxxxxxxxxx
> Subject: RE: Help in custom painting an image to a pixmap
>
> Well the good news is, I was able to create a simple test case. Its built
> using 4.1.2, I have attached the C++ file and a resulting screen shot.
> Any help would be appreciated. Worst case it goes to bugs@ tomorrow.
>
> Basically to show the problem, I create a simple widget, with a horizontal
> layout. The layout contans 3 labels, one with pic1 (loaded at runtime)
> one with pic2, and the third the merged picture.
>
> I set the background to blue, just so it REALLY stands out. I get a green
> background behind the merged pictures.
>
> I have attached 2 very simple images that show the problem.
> Thanks again in advance
>
> Scott
>
> > -----Original Message-----
> > From: Scott Aron Bloom [mailto:scott@xxxxxxxxxxxx]
> > Sent: Thursday, December 07, 2006 2:11 AM
> > To: Sebastien Emonet; qt-interest@xxxxxxxxxxxxx
> > Subject: RE: Help in custom painting an image to a pixmap
> >
> > Thanks... But unfortunately, that is not working for me either...
> >
> > Im going to come up with a "real" example to show the problem in the
> > morning.. Maybe it's a version based bug, I am running 4.1.2.
> >
> > The only difference between your code, and my previous code, was I used
> > QPixmap the whole time, you created an image to paint on.
> >
> > I get the same results with both flows.
> >
> > Another difference, yours puts on top of the other, I place them side by
> > side...
> >
> > Thanks again.
> >
> > Scott
> >
> > > -----Original Message-----
> > > From: Sebastien Emonet [mailto:emonet@xxxxxxxxxxxxxxxxxxx]
> > > Sent: Thursday, December 07, 2006 12:49 AM
> > > To: Scott Aron Bloom; qt-interest@xxxxxxxxxxxxx
> > > Subject: AW: Help in custom painting an image to a pixmap
> > >
> > > Hi,
> > >
> > > Here's a small function I wrote to merge two images.
> > > It keeps the translucence of the images:
> > >
> > > QPixmap mergeBackgroundAndForeground(QPixmap bkg,QPixmap foreg){
> > > if(bkg.isNull())
> > > return foreg;
> > > if(foreg.isNull())
> > > return bkg;
> > > QImage img(bkg);
> > > QPainter painter;
> > > painter.begin(&img);
> > > painter.drawPixmap(0,0,foreg);
> > > painter.end();
> > > return QPixmap(img);
> > > }
> > >
> > > If your images are not the same size, change the coordinate in the
> > > function drawPixmap(x,y,foreg) to choose where you paint the
> foreground.
> > >
> > > I hope it will help!
> > >
> > > Sébastien
> > >
> > >
> > > -----Ursprüngliche Nachricht-----
> > > Von: Scott Aron Bloom [mailto:scott@xxxxxxxxxxxx]
> > > Gesendet: Donnerstag, 7. Dezember 2006 03:26
> > > An: qt-interest@xxxxxxxxxxxxx
> > > Betreff: Help in custom painting an image to a pixmap
> > >
> > > In general here is the code I am trying get working a bit better.
> > >
> > > Essentially, I have 2 pixmaps, both with translucent background, so
> > > that if I use painter->drawPixmap() the background of the widget
> shows,
> > > except where the image has data.
> > >
> > > However, when I need to merge the to images, into 1 pixmap, I lose
> that
> > > translucent background property, and I get very strange data in the
> > > background area.
> > >
> > > Here is what Im doing now...
> > >
> > > QPixmap pix1( ":....." ); // its correctly stored in my resource
> > > QPixmap pix2( ":....." ); // its correctly stored in my resource
> > >
> > > QPixmap pix3( pix1.width() * 2, pix1.height() ); // they are
> guaranteed
> > > to have the same height
> > >
> > > QPainter painter(&pix3 );
> > > painter.drawPixmap( pix1.rect(), pix1 );
> > > QRect rect( pix1.rect() );
> > > rect.moveRight( pix1.rect().right() );
> > > rect.setWidth( pix2.width() )
> > >
> > > painter.drawPixmap( rect, pix2 );
> > >
> > > Any suggestions on how to draw a pixmap to a pixmap and havce the new
> > > pixmap maintain the background.
> > >
> > > Thank
> > >
> > >
> > >
> > >
> >
> > --
> > To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> > "unsubscribe" in the subject or the body.
> > List archive and information: http://lists.trolltech.com/qt-interest/
Attachment:
Attachment:
main.cpp
Description: main.cpp