PDA

View Full Version : contrast, transparency, brightness...



Noxxik
27th February 2009, 19:27
Hi could someone help me, how I can set contrast, transparency, brightness, etc. of my QGraphicsItem or QPixmap or QImage, which are used as bruch of QGraphicsItem.
Thanks a lot

Noxxik
28th February 2009, 14:23
nobody gives me hint? please

aamer4yu
28th February 2009, 19:55
Transparency is easy,,, just use QColor(r,g,b,a); a is for aplha, meaning how much transparent pixel shud be.

As for brightness, contrast,,, there was some example, probably on Qt Labs -> Dojo . am not able to find the link,, but will post if i find it. You can search for it meanwhile , may be u find it :)

Noxxik
28th February 2009, 20:13
for transparency and QColor(r,g,b,a); I thought, that QColor is usable only for colors. So if it is usable for QPixmap and QImage too, It is great :) I can try it
And If you find this link you will be my God :)

aamer4yu
28th February 2009, 20:41
Transparency is easy,,, just use QColor(r,g,b,a); a is for aplha, meaning how much transparent pixel shud be.
Sorry about this, I looked up Qimage and found it uses QRgb in setPixel :(

However transparency is still easy... you can use QGraphicsItem::setOpacity :)

Noxxik
28th February 2009, 21:51
Sorry about this, I looked up Qimage and found it uses QRgb in setPixel :(

However transparency is still easy... you can use QGraphicsItem::setOpacity :)but QGraphicsItem::setOpacity it is not, only QPainter::setOpacity and I am trying QImage::colorTable now, but I dont know, if it is OK :eek:

Noxxik
28th February 2009, 22:29
I am in this situation...

QImage image = item->brush().textureImage();
QVector<QRgb> rgbvector = image.colorTable();

QVector<QColor> colors(0);
QVector<QRgb> rgbvector2(0);
foreach(QRgb pixel, rgbvector){
colors.append(pixel);
}
foreach(QColor color, colors){
color.setAlpha(value);
rgbvector2.append(color.rgba());
}
image.setColorTable(rgbvector2);

item->setBrush(QBrush(image));
but anything changes. It is some mistake in this code or in another? thanks for reaction