Seite 1 von 1
[QT3] Halbtransparentes Bild
Verfasst: 23. Januar 2008 08:28
von flownfluid
Hallo zusammen,
leider muss ich was in QT3.3 proggen und ich komme nicht mehr weiter. Ich muss unter Linux ein halbtransparenten Button erstellen.
Kann mir da jemand eine Idee oder eine Anregung geben?
Vielen Dank und gruss
Re: [QT3] Halbtransparentes Bild
Verfasst: 23. Januar 2008 09:44
von patrik08
flownfluid hat geschrieben:Hallo zusammen,
leider muss ich was in QT3.3 proggen und ich komme nicht mehr weiter. Ich muss unter Linux ein halbtransparenten Button erstellen.
Kann mir da jemand eine Idee oder eine Anregung geben?
Vielen Dank und gruss
Ich mache barcode streifen transparent auf diese weise... da weiss nicht gut ist im hindergrund....
QPixmap Glabel = xxxx
QPixmap weiss_transparent = setColorize(Glabel,Qt::black,Qt::white);
vieleicht kannst du was damit begreifen..... wie die einzelne pixel transparent machen... im .setHsv..
Code: Alles auswählen
/////////////// take QPixmap elevate luminance color gtr and render color toalpha transparent /////
static inline QPixmap setColorize( QPixmap in , QColor gtr , QColor toalpha )
{
QImage base = in.toImage().convertToFormat(QImage::Format_ARGB32_Premultiplied);
int sepiaH, sepiaS, sepiaL,saphaH, saphaS, saphaL;
gtr.getHsv( &sepiaH, &sepiaS, &sepiaL );
toalpha.getHsv( &saphaH, &saphaS, &saphaL );
int x, y, pixelLuminance,C_red,C_green,C_blue;
bool makealphas = toalpha.isValid();
QColor sepiaColor; /* manipolator */
uchar* scanLine;
QRgb* rgb;
for( y=0; y<base.height(); y++) {
scanLine = base.scanLine(y);
////////QRgb *scanread_pics = reinterpret_cast<QRgb *>(base.scanLine(y));
for (int x = 0; x < base.width() ; x++){
rgb = ((QRgb*)scanLine+x);
pixelLuminance = (int) (0.2125*qRed(*rgb) + 0.7154*qGreen(*rgb) + 0.0721*qBlue(*rgb));
if (QColor( *rgb ).name() == toalpha.name() ) {
sepiaColor.setHsv( sepiaH, sepiaS, sepiaL ,0); /* make transparent alpha 0!!! */
} else {
sepiaColor.setHsv( sepiaH, sepiaS, pixelLuminance , 255 ); /* normal color */
}
*rgb = sepiaColor.rgba();
}
}
/* tester base.save("xxxxxxx.png","PNG"); */
return QPixmap::fromImage(base);
}