Results 1 to 7 of 7

Thread: contrast, transparency, brightness...

  1. #1
    Join Date
    Feb 2009
    Posts
    53
    Thanks
    5

    Default contrast, transparency, brightness...

    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

  2. #2
    Join Date
    Feb 2009
    Posts
    53
    Thanks
    5

    Default Re: contrast, transparency, brightness...

    nobody gives me hint? please

  3. #3
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: contrast, transparency, brightness...

    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

  4. #4
    Join Date
    Feb 2009
    Posts
    53
    Thanks
    5

    Default Re: contrast, transparency, brightness...

    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

  5. #5
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: contrast, transparency, brightness...

    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

  6. #6
    Join Date
    Feb 2009
    Posts
    53
    Thanks
    5

    Default Re: contrast, transparency, brightness...

    Quote Originally Posted by aamer4yu View Post
    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

  7. #7
    Join Date
    Feb 2009
    Posts
    53
    Thanks
    5

    Default Re: contrast, transparency, brightness...

    I am in this situation...
    Qt Code:
    1. QImage image = item->brush().textureImage();
    2. QVector<QRgb> rgbvector = image.colorTable();
    3.  
    4. QVector<QColor> colors(0);
    5. QVector<QRgb> rgbvector2(0);
    6. foreach(QRgb pixel, rgbvector){
    7. colors.append(pixel);
    8. }
    9. foreach(QColor color, colors){
    10. color.setAlpha(value);
    11. rgbvector2.append(color.rgba());
    12. }
    13. image.setColorTable(rgbvector2);
    14.  
    15. item->setBrush(QBrush(image));
    To copy to clipboard, switch view to plain text mode 
    but anything changes. It is some mistake in this code or in another? thanks for reaction

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.