| Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date | |
| All threads index page 2 | |
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
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
--
[ signature omitted ]
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
>
>
>
>
--
[ signature omitted ]
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 Attachment:
pic2.png Attachment:
pic1.png Attachment:
mergepicbug.png
Description: main.cpp
Description: pic2.png
Description: pic1.png
Description: mergepicbug.png
Message 5 in thread
Try to fill the QImage before painting on it.
...
QImage img( width, height, QImage::Format_RGB32 );//retVal =
QPixmap( width, height );
img.fill(255);
...
it should solve your problem
Sébastien
-----Ursprüngliche Nachricht-----
Von: Scott Aron Bloom [mailto:scott@xxxxxxxxxxxx]
Gesendet: Donnerstag, 7. Dezember 2006 11:35
An: Scott Aron Bloom; Sebastien Emonet; qt-interest@xxxxxxxxxxxxx
Betreff: 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/
--
[ signature omitted ]
Message 6 in thread
That just sets the background to blue for the merged image..
Blue was just a overly simplified example... In reality, the background is set by the customer, and can also be a gradient, or a background image... Thus the need for the transparency...
Scott
> -----Original Message-----
> From: Sebastien Emonet [mailto:emonet@xxxxxxxxxxxxxxxxxxx]
> Sent: Thursday, December 07, 2006 2:48 AM
> To: Scott Aron Bloom; qt-interest@xxxxxxxxxxxxx
> Subject: AW: Help in custom painting an image to a pixmap
>
> Try to fill the QImage before painting on it.
>
> ...
> QImage img( width, height, QImage::Format_RGB32 );//retVal =
> QPixmap( width, height );
>
> img.fill(255);
> ...
>
> it should solve your problem
>
> Sébastien
>
> -----Ursprüngliche Nachricht-----
> Von: Scott Aron Bloom [mailto:scott@xxxxxxxxxxxx]
> Gesendet: Donnerstag, 7. Dezember 2006 11:35
> An: Scott Aron Bloom; Sebastien Emonet; qt-interest@xxxxxxxxxxxxx
> Betreff: 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/
>
--
[ signature omitted ]
Message 7 in thread
Maybe it's a Misunderstanding...
After creating your QImage (and before painting on it) use the fill
function to init the image:
img.fill(255);
or replace your function by this one:
QPixmap getMergedPixmaps( const QPixmap & lhs, const QPixmap & rhs )
{
int width = lhs.width() + rhs.width() + 1;
int height = qMax( lhs.height(), rhs.height() );
QImage img( width, height, QImage::Format_RGB32 );//retVal =
QPixmap( width, height );
img.fill(255);
QPainter painter( &img );
painter.drawPixmap( 0, 0, lhs.width(), lhs.height(), lhs );
painter.drawPixmap( lhs.width() + 1 , 0, rhs.width(),
rhs.height(), rhs );
return QPixmap::fromImage( img );
}
-----Ursprüngliche Nachricht-----
Von: Scott Aron Bloom [mailto:scott@xxxxxxxxxxxx]
Gesendet: Donnerstag, 7. Dezember 2006 11:56
An: Sebastien Emonet; qt-interest@xxxxxxxxxxxxx
Betreff: RE: Help in custom painting an image to a pixmap
That just sets the background to blue for the merged image..
Blue was just a overly simplified example... In reality, the background
is set by the customer, and can also be a gradient, or a background
image... Thus the need for the transparency...
Scott
> -----Original Message-----
> From: Sebastien Emonet [mailto:emonet@xxxxxxxxxxxxxxxxxxx]
> Sent: Thursday, December 07, 2006 2:48 AM
> To: Scott Aron Bloom; qt-interest@xxxxxxxxxxxxx
> Subject: AW: Help in custom painting an image to a pixmap
>
> Try to fill the QImage before painting on it.
>
> ...
> QImage img( width, height, QImage::Format_RGB32 );//retVal =
> QPixmap( width, height );
>
> img.fill(255);
> ...
>
> it should solve your problem
>
> Sébastien
>
> -----Ursprüngliche Nachricht-----
> Von: Scott Aron Bloom [mailto:scott@xxxxxxxxxxxx]
> Gesendet: Donnerstag, 7. Dezember 2006 11:35
> An: Scott Aron Bloom; Sebastien Emonet; qt-interest@xxxxxxxxxxxxx
> Betreff: 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/
>
--
[ signature omitted ]
Message 8 in thread
I did exactly that. But it doesn't fix the problem. The backround is not transparent.
To see this, change the setColor function of the palette to Qt::green, but keep your fill call.
I don't need a blue background, I need a image with the alpha channel kept from the original.
Scott
> -----Original Message-----
> From: Sebastien Emonet [mailto:emonet@xxxxxxxxxxxxxxxxxxx]
> Sent: Thursday, December 07, 2006 3:06 AM
> To: Scott Aron Bloom; qt-interest@xxxxxxxxxxxxx
> Subject: AW: Help in custom painting an image to a pixmap
>
> Maybe it's a Misunderstanding...
>
> After creating your QImage (and before painting on it) use the fill
> function to init the image:
>
> img.fill(255);
>
> or replace your function by this one:
>
> QPixmap getMergedPixmaps( const QPixmap & lhs, const QPixmap & rhs )
> {
> int width = lhs.width() + rhs.width() + 1;
> int height = qMax( lhs.height(), rhs.height() );
>
> QImage img( width, height, QImage::Format_RGB32 );//retVal =
> QPixmap( width, height );
> img.fill(255);
> QPainter painter( &img );
>
> painter.drawPixmap( 0, 0, lhs.width(), lhs.height(), lhs );
> painter.drawPixmap( lhs.width() + 1 , 0, rhs.width(),
> rhs.height(), rhs );
> return QPixmap::fromImage( img );
> }
> -----Ursprüngliche Nachricht-----
> Von: Scott Aron Bloom [mailto:scott@xxxxxxxxxxxx]
> Gesendet: Donnerstag, 7. Dezember 2006 11:56
> An: Sebastien Emonet; qt-interest@xxxxxxxxxxxxx
> Betreff: RE: Help in custom painting an image to a pixmap
>
> That just sets the background to blue for the merged image..
>
> Blue was just a overly simplified example... In reality, the background
> is set by the customer, and can also be a gradient, or a background
> image... Thus the need for the transparency...
>
> Scott
>
> > -----Original Message-----
> > From: Sebastien Emonet [mailto:emonet@xxxxxxxxxxxxxxxxxxx]
> > Sent: Thursday, December 07, 2006 2:48 AM
> > To: Scott Aron Bloom; qt-interest@xxxxxxxxxxxxx
> > Subject: AW: Help in custom painting an image to a pixmap
> >
> > Try to fill the QImage before painting on it.
> >
> > ...
> > QImage img( width, height, QImage::Format_RGB32 );//retVal =
> > QPixmap( width, height );
> >
> > img.fill(255);
> > ...
> >
> > it should solve your problem
> >
> > Sébastien
> >
> > -----Ursprüngliche Nachricht-----
> > Von: Scott Aron Bloom [mailto:scott@xxxxxxxxxxxx]
> > Gesendet: Donnerstag, 7. Dezember 2006 11:35
> > An: Scott Aron Bloom; Sebastien Emonet; qt-interest@xxxxxxxxxxxxx
> > Betreff: 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/
> >
--
[ signature omitted ]
Message 9 in thread
Oki Sorry!
And this:
QImage alpha(img);
alpha.fill(0);
img.setAlphaChannel(alpha);
-----Ursprüngliche Nachricht-----
Von: Scott Aron Bloom [mailto:scott@xxxxxxxxxxxx]
Gesendet: Donnerstag, 7. Dezember 2006 12:15
An: Sebastien Emonet; qt-interest@xxxxxxxxxxxxx
Betreff: RE: Help in custom painting an image to a pixmap
I did exactly that. But it doesn't fix the problem. The backround is
not transparent.
To see this, change the setColor function of the palette to Qt::green,
but keep your fill call.
I don't need a blue background, I need a image with the alpha channel
kept from the original.
Scott
> -----Original Message-----
> From: Sebastien Emonet [mailto:emonet@xxxxxxxxxxxxxxxxxxx]
> Sent: Thursday, December 07, 2006 3:06 AM
> To: Scott Aron Bloom; qt-interest@xxxxxxxxxxxxx
> Subject: AW: Help in custom painting an image to a pixmap
>
> Maybe it's a Misunderstanding...
>
> After creating your QImage (and before painting on it) use the fill
> function to init the image:
>
> img.fill(255);
>
> or replace your function by this one:
>
> QPixmap getMergedPixmaps( const QPixmap & lhs, const QPixmap & rhs )
> {
> int width = lhs.width() + rhs.width() + 1;
> int height = qMax( lhs.height(), rhs.height() );
>
> QImage img( width, height, QImage::Format_RGB32 );//retVal =
> QPixmap( width, height );
> img.fill(255);
> QPainter painter( &img );
>
> painter.drawPixmap( 0, 0, lhs.width(), lhs.height(), lhs );
> painter.drawPixmap( lhs.width() + 1 , 0, rhs.width(),
> rhs.height(), rhs );
> return QPixmap::fromImage( img );
> }
> -----Ursprüngliche Nachricht-----
> Von: Scott Aron Bloom [mailto:scott@xxxxxxxxxxxx]
> Gesendet: Donnerstag, 7. Dezember 2006 11:56
> An: Sebastien Emonet; qt-interest@xxxxxxxxxxxxx
> Betreff: RE: Help in custom painting an image to a pixmap
>
> That just sets the background to blue for the merged image..
>
> Blue was just a overly simplified example... In reality, the
background
> is set by the customer, and can also be a gradient, or a background
> image... Thus the need for the transparency...
>
> Scott
>
> > -----Original Message-----
> > From: Sebastien Emonet [mailto:emonet@xxxxxxxxxxxxxxxxxxx]
> > Sent: Thursday, December 07, 2006 2:48 AM
> > To: Scott Aron Bloom; qt-interest@xxxxxxxxxxxxx
> > Subject: AW: Help in custom painting an image to a pixmap
> >
> > Try to fill the QImage before painting on it.
> >
> > ...
> > QImage img( width, height, QImage::Format_RGB32 );//retVal =
> > QPixmap( width, height );
> >
> > img.fill(255);
> > ...
> >
> > it should solve your problem
> >
> > Sébastien
> >
> > -----Ursprüngliche Nachricht-----
> > Von: Scott Aron Bloom [mailto:scott@xxxxxxxxxxxx]
> > Gesendet: Donnerstag, 7. Dezember 2006 11:35
> > An: Scott Aron Bloom; Sebastien Emonet; qt-interest@xxxxxxxxxxxxx
> > Betreff: 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/
> >
--
[ signature omitted ]
Message 10 in thread
That was it... I have to set the alpha before the painting on the image.
Just to finalize... :)
Here is the getMergedPixmap function for all :)
QPixmap getMergedPixmaps( const QPixmap & lhs, const QPixmap & rhs )
{
int width = lhs.width() + rhs.width() + 1;
int height = qMax( lhs.height(), rhs.height() );
QImage img( width, height, QImage::Format_RGB32 );//retVal = QPixmap( width, height );
QImage alpha( width, height, QImage::Format_Indexed8 );
alpha.fill(0);
img.setAlphaChannel(alpha);
QPainter painter( &img );
painter.drawPixmap( 0, 0, lhs.width(), lhs.height(), lhs );
painter.drawPixmap( lhs.width() + 1 , 0, rhs.width(), rhs.height(), rhs );
painter.end();
return QPixmap::fromImage( img );
}
Thanks again Sebastien
Scott
> -----Original Message-----
> From: Sebastien Emonet [mailto:emonet@xxxxxxxxxxxxxxxxxxx]
> Sent: Thursday, December 07, 2006 3:25 AM
> To: Scott Aron Bloom; qt-interest@xxxxxxxxxxxxx
> Subject: AW: Help in custom painting an image to a pixmap
>
> Oki Sorry!
>
> And this:
>
> QImage alpha(img);
> alpha.fill(0);
> img.setAlphaChannel(alpha);
>
> -----Ursprüngliche Nachricht-----
> Von: Scott Aron Bloom [mailto:scott@xxxxxxxxxxxx]
> Gesendet: Donnerstag, 7. Dezember 2006 12:15
> An: Sebastien Emonet; qt-interest@xxxxxxxxxxxxx
> Betreff: RE: Help in custom painting an image to a pixmap
>
> I did exactly that. But it doesn't fix the problem. The backround is
> not transparent.
>
> To see this, change the setColor function of the palette to Qt::green,
> but keep your fill call.
>
> I don't need a blue background, I need a image with the alpha channel
> kept from the original.
>
> Scott
>
> > -----Original Message-----
> > From: Sebastien Emonet [mailto:emonet@xxxxxxxxxxxxxxxxxxx]
> > Sent: Thursday, December 07, 2006 3:06 AM
> > To: Scott Aron Bloom; qt-interest@xxxxxxxxxxxxx
> > Subject: AW: Help in custom painting an image to a pixmap
> >
> > Maybe it's a Misunderstanding...
> >
> > After creating your QImage (and before painting on it) use the fill
> > function to init the image:
> >
> > img.fill(255);
> >
> > or replace your function by this one:
> >
> > QPixmap getMergedPixmaps( const QPixmap & lhs, const QPixmap & rhs )
> > {
> > int width = lhs.width() + rhs.width() + 1;
> > int height = qMax( lhs.height(), rhs.height() );
> >
> > QImage img( width, height, QImage::Format_RGB32 );//retVal =
> > QPixmap( width, height );
> > img.fill(255);
> > QPainter painter( &img );
> >
> > painter.drawPixmap( 0, 0, lhs.width(), lhs.height(), lhs );
> > painter.drawPixmap( lhs.width() + 1 , 0, rhs.width(),
> > rhs.height(), rhs );
> > return QPixmap::fromImage( img );
> > }
> > -----Ursprüngliche Nachricht-----
> > Von: Scott Aron Bloom [mailto:scott@xxxxxxxxxxxx]
> > Gesendet: Donnerstag, 7. Dezember 2006 11:56
> > An: Sebastien Emonet; qt-interest@xxxxxxxxxxxxx
> > Betreff: RE: Help in custom painting an image to a pixmap
> >
> > That just sets the background to blue for the merged image..
> >
> > Blue was just a overly simplified example... In reality, the
> background
> > is set by the customer, and can also be a gradient, or a background
> > image... Thus the need for the transparency...
> >
> > Scott
> >
> > > -----Original Message-----
> > > From: Sebastien Emonet [mailto:emonet@xxxxxxxxxxxxxxxxxxx]
> > > Sent: Thursday, December 07, 2006 2:48 AM
> > > To: Scott Aron Bloom; qt-interest@xxxxxxxxxxxxx
> > > Subject: AW: Help in custom painting an image to a pixmap
> > >
> > > Try to fill the QImage before painting on it.
> > >
> > > ...
> > > QImage img( width, height, QImage::Format_RGB32 );//retVal =
> > > QPixmap( width, height );
> > >
> > > img.fill(255);
> > > ...
> > >
> > > it should solve your problem
> > >
> > > Sébastien
> > >
> > > -----Ursprüngliche Nachricht-----
> > > Von: Scott Aron Bloom [mailto:scott@xxxxxxxxxxxx]
> > > Gesendet: Donnerstag, 7. Dezember 2006 11:35
> > > An: Scott Aron Bloom; Sebastien Emonet; qt-interest@xxxxxxxxxxxxx
> > > Betreff: 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/
> > >
>
> --
> 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/
--
[ signature omitted ]
Message 11 in thread
As an fyi...
img.fill( Qt::transparent ) can be used instead of the
Alpha image...
Scott
> -----Original Message-----
> From: Scott Aron Bloom [mailto:scott@xxxxxxxxxxxx]
> Sent: Thursday, December 07, 2006 3:46 AM
> To: Sebastien Emonet; qt-interest@xxxxxxxxxxxxx
> Subject: RE: Help in custom painting an image to a pixmap
>
> That was it... I have to set the alpha before the painting on the image.
>
> Just to finalize... :)
>
> Here is the getMergedPixmap function for all :)
>
> QPixmap getMergedPixmaps( const QPixmap & lhs, const QPixmap & rhs )
> {
> int width = lhs.width() + rhs.width() + 1;
> int height = qMax( lhs.height(), rhs.height() );
>
> QImage img( width, height, QImage::Format_RGB32 );//retVal =
> QPixmap( width, height );
>
> QImage alpha( width, height, QImage::Format_Indexed8 );
> alpha.fill(0);
> img.setAlphaChannel(alpha);
>
> QPainter painter( &img );
>
> painter.drawPixmap( 0, 0, lhs.width(), lhs.height(), lhs );
> painter.drawPixmap( lhs.width() + 1 , 0, rhs.width(), rhs.height(),
> rhs );
> painter.end();
>
> return QPixmap::fromImage( img );
> }
>
> Thanks again Sebastien
>
> Scott
>
> > -----Original Message-----
> > From: Sebastien Emonet [mailto:emonet@xxxxxxxxxxxxxxxxxxx]
> > Sent: Thursday, December 07, 2006 3:25 AM
> > To: Scott Aron Bloom; qt-interest@xxxxxxxxxxxxx
> > Subject: AW: Help in custom painting an image to a pixmap
> >
> > Oki Sorry!
> >
> > And this:
> >
> > QImage alpha(img);
> > alpha.fill(0);
> > img.setAlphaChannel(alpha);
> >
> > -----Ursprüngliche Nachricht-----
> > Von: Scott Aron Bloom [mailto:scott@xxxxxxxxxxxx]
> > Gesendet: Donnerstag, 7. Dezember 2006 12:15
> > An: Sebastien Emonet; qt-interest@xxxxxxxxxxxxx
> > Betreff: RE: Help in custom painting an image to a pixmap
> >
> > I did exactly that. But it doesn't fix the problem. The backround is
> > not transparent.
> >
> > To see this, change the setColor function of the palette to Qt::green,
> > but keep your fill call.
> >
> > I don't need a blue background, I need a image with the alpha channel
> > kept from the original.
> >
> > Scott
> >
> > > -----Original Message-----
> > > From: Sebastien Emonet [mailto:emonet@xxxxxxxxxxxxxxxxxxx]
> > > Sent: Thursday, December 07, 2006 3:06 AM
> > > To: Scott Aron Bloom; qt-interest@xxxxxxxxxxxxx
> > > Subject: AW: Help in custom painting an image to a pixmap
> > >
> > > Maybe it's a Misunderstanding...
> > >
> > > After creating your QImage (and before painting on it) use the fill
> > > function to init the image:
> > >
> > > img.fill(255);
> > >
> > > or replace your function by this one:
> > >
> > > QPixmap getMergedPixmaps( const QPixmap & lhs, const QPixmap & rhs )
> > > {
> > > int width = lhs.width() + rhs.width() + 1;
> > > int height = qMax( lhs.height(), rhs.height() );
> > >
> > > QImage img( width, height, QImage::Format_RGB32 );//retVal =
> > > QPixmap( width, height );
> > > img.fill(255);
> > > QPainter painter( &img );
> > >
> > > painter.drawPixmap( 0, 0, lhs.width(), lhs.height(), lhs );
> > > painter.drawPixmap( lhs.width() + 1 , 0, rhs.width(),
> > > rhs.height(), rhs );
> > > return QPixmap::fromImage( img );
> > > }
> > > -----Ursprüngliche Nachricht-----
> > > Von: Scott Aron Bloom [mailto:scott@xxxxxxxxxxxx]
> > > Gesendet: Donnerstag, 7. Dezember 2006 11:56
> > > An: Sebastien Emonet; qt-interest@xxxxxxxxxxxxx
> > > Betreff: RE: Help in custom painting an image to a pixmap
> > >
> > > That just sets the background to blue for the merged image..
> > >
> > > Blue was just a overly simplified example... In reality, the
> > background
> > > is set by the customer, and can also be a gradient, or a background
> > > image... Thus the need for the transparency...
> > >
> > > Scott
> > >
> > > > -----Original Message-----
> > > > From: Sebastien Emonet [mailto:emonet@xxxxxxxxxxxxxxxxxxx]
> > > > Sent: Thursday, December 07, 2006 2:48 AM
> > > > To: Scott Aron Bloom; qt-interest@xxxxxxxxxxxxx
> > > > Subject: AW: Help in custom painting an image to a pixmap
> > > >
> > > > Try to fill the QImage before painting on it.
> > > >
> > > > ...
> > > > QImage img( width, height, QImage::Format_RGB32 );//retVal =
> > > > QPixmap( width, height );
> > > >
> > > > img.fill(255);
> > > > ...
> > > >
> > > > it should solve your problem
> > > >
> > > > Sébastien
> > > >
> > > > -----Ursprüngliche Nachricht-----
> > > > Von: Scott Aron Bloom [mailto:scott@xxxxxxxxxxxx]
> > > > Gesendet: Donnerstag, 7. Dezember 2006 11:35
> > > > An: Scott Aron Bloom; Sebastien Emonet; qt-interest@xxxxxxxxxxxxx
> > > > Betreff: 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/
> > > >
> >
> > --
> > 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/
>
> --
> 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/
--
[ signature omitted ]
Message 12 in thread
The "direct fill" also works but you have to contruct a QImage with
alpha channel QImage::Format_ARGB32
QImage img( width, height, QImage::Format_ARGB32 );
img.fill(0);
-----Ursprüngliche Nachricht-----
Von: Scott Aron Bloom [mailto:scott@xxxxxxxxxxxx]
Gesendet: Donnerstag, 7. Dezember 2006 12:15
An: Sebastien Emonet; qt-interest@xxxxxxxxxxxxx
Betreff: RE: Help in custom painting an image to a pixmap
I did exactly that. But it doesn't fix the problem. The backround is
not transparent.
To see this, change the setColor function of the palette to Qt::green,
but keep your fill call.
I don't need a blue background, I need a image with the alpha channel
kept from the original.
Scott
> -----Original Message-----
> From: Sebastien Emonet [mailto:emonet@xxxxxxxxxxxxxxxxxxx]
> Sent: Thursday, December 07, 2006 3:06 AM
> To: Scott Aron Bloom; qt-interest@xxxxxxxxxxxxx
> Subject: AW: Help in custom painting an image to a pixmap
>
> Maybe it's a Misunderstanding...
>
> After creating your QImage (and before painting on it) use the fill
> function to init the image:
>
> img.fill(255);
>
> or replace your function by this one:
>
> QPixmap getMergedPixmaps( const QPixmap & lhs, const QPixmap & rhs )
> {
> int width = lhs.width() + rhs.width() + 1;
> int height = qMax( lhs.height(), rhs.height() );
>
> QImage img( width, height, QImage::Format_RGB32 );//retVal =
> QPixmap( width, height );
> img.fill(255);
> QPainter painter( &img );
>
> painter.drawPixmap( 0, 0, lhs.width(), lhs.height(), lhs );
> painter.drawPixmap( lhs.width() + 1 , 0, rhs.width(),
> rhs.height(), rhs );
> return QPixmap::fromImage( img );
> }
> -----Ursprüngliche Nachricht-----
> Von: Scott Aron Bloom [mailto:scott@xxxxxxxxxxxx]
> Gesendet: Donnerstag, 7. Dezember 2006 11:56
> An: Sebastien Emonet; qt-interest@xxxxxxxxxxxxx
> Betreff: RE: Help in custom painting an image to a pixmap
>
> That just sets the background to blue for the merged image..
>
> Blue was just a overly simplified example... In reality, the
background
> is set by the customer, and can also be a gradient, or a background
> image... Thus the need for the transparency...
>
> Scott
>
> > -----Original Message-----
> > From: Sebastien Emonet [mailto:emonet@xxxxxxxxxxxxxxxxxxx]
> > Sent: Thursday, December 07, 2006 2:48 AM
> > To: Scott Aron Bloom; qt-interest@xxxxxxxxxxxxx
> > Subject: AW: Help in custom painting an image to a pixmap
> >
> > Try to fill the QImage before painting on it.
> >
> > ...
> > QImage img( width, height, QImage::Format_RGB32 );//retVal =
> > QPixmap( width, height );
> >
> > img.fill(255);
> > ...
> >
> > it should solve your problem
> >
> > Sébastien
> >
> > -----Ursprüngliche Nachricht-----
> > Von: Scott Aron Bloom [mailto:scott@xxxxxxxxxxxx]
> > Gesendet: Donnerstag, 7. Dezember 2006 11:35
> > An: Scott Aron Bloom; Sebastien Emonet; qt-interest@xxxxxxxxxxxxx
> > Betreff: 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/
> >
--
[ signature omitted ]
Message 13 in thread
I read qt.conf doc and want to create one qt.conf file
<http://doc.trolltech.com/4.2/qt-conf.html>.
Can someone send me a qt.conf example please to help me to create my
first one.
I know thereius the doc to help but with an example it's better.
I'm developing on windows platform and visual.net ide.
thank you,
Veronique.
Message 14 in thread
On 08.12.06 12:14:04, veronique.lefrere@xxxxxx wrote:
> I read qt.conf doc and want to create one qt.conf file
> <http://doc.trolltech.com/4.2/qt-conf.html>.
> Can someone send me a qt.conf example please to help me to create my first one.
> I know thereius the doc to help but with an example it's better.
Did you really read that page fully? There are examples on that exact
page.
Andreas
--
[ signature omitted ]
Message 15 in thread
:-[ :-[ 8-)
no,it's clear now that I did not scoll the end of page.
Than you for the patience and so the answer...
have a nice week end!
Veronique.
Andreas Pakulat a écrit :
>On 08.12.06 12:14:04, veronique.lefrere@xxxxxx wrote:
>
>
>>I read qt.conf doc and want to create one qt.conf file
>><http://doc.trolltech.com/4.2/qt-conf.html>.
>>Can someone send me a qt.conf example please to help me to create my first one.
>>I know thereius the doc to help but with an example it's better.
>>
>>
>
>Did you really read that page fully? There are examples on that exact
>page.
>
>Andreas
>
>
>