Results 1 to 7 of 7

Thread: transparency in colormap, still don't get it!

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2009
    Posts
    92
    Thanks
    7
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: transparency in colormap, still don't get it!

    well, as far as I can see the code does not deal with alpha levels in those functions. Everything is done for RGB values only (using the dev trunc code), adding of color stops, interpolating between stops etc. The effect I see is that what should be transparent is black. I'll see if I can experiments with the code a bit.
    But if I add some alpha provision, then also the rendering should do that and that is a bit deeper in the code...

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,325
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: transparency in colormap, still don't get it!

    Quote Originally Posted by qt_gotcha View Post
    well, as far as I can see the code does not deal with alpha levels in those functions.
    Yes, so the first interpolated value will be an opaque value close to ( 0, 0, 0 ). This is probably not what you want, but does it explain what you see ?

    What about overloading QwtLinearColorMap instead of using transparency for the stops:

    Qt Code:
    1. class YourColorMap: public QwtLinearColorMap
    2. {
    3. virtual QRgb rgb( const QwtInterval &interval, double value ) const
    4. {
    5. if ( value == ... )
    6. return qRgba( 0, 0, 0, 0 );
    7.  
    8. return QwtLinearColorMap::rgb( interval, value );
    9. };
    To copy to clipboard, switch view to plain text mode 

    Uwe

  3. The following user says thank you to Uwe for this useful post:

    qt_gotcha (29th January 2013)

  4. #3
    Join Date
    Jun 2012
    Posts
    173
    Thanks
    48
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: transparency in colormap, still don't get it!

    Where u able to get the transparency in colormap ???
    please let us know how you did that.

    Thank you so much.

  5. #4
    Join Date
    Jun 2014
    Posts
    17
    Thanks
    1
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: transparency in colormap, still don't get it!

    Hi all,

    also interesting of spectrograms transparency. This solution (Uwe's idea above) works:
    Qt Code:
    1. class QwtTransparentLinearColorMap : public QwtLinearColorMap
    2. {
    3. typedef QwtLinearColorMap Base;
    4.  
    5. public:
    6. virtual QRgb rgb(const QwtInterval& interval, double value) const
    7. {
    8. QRgb result = Base::rgb(interval, value);
    9. result = (result & 0x00FFFFFF) | 0x7F000000; // semi-transparent
    10. return result;
    11. }
    12. };
    To copy to clipboard, switch view to plain text mode 

  6. #5
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,325
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: transparency in colormap, still don't get it!

    Note that there is also: QwtPlotRasterItem::setAlpha(). The advantage of using this is that you can modify the alpha value without having to re-render the image. Advantage of your code is, that the alpha value is part of the cached image and when drawing the image from the cache the cycle for updating the alpha value can be avoided.

    So when you need to do something like with the slider of the spectrogram example QwtPlotRasterItem::setAlpha(), might be better. Otherwise your code might be faster ( if this matters ).

    Uwe

Similar Threads

  1. Transparency with QWinWidget
    By martian in forum Qt Programming
    Replies: 7
    Last Post: 28th February 2015, 06:13
  2. How to add colormap from files?
    By centroid in forum Qwt
    Replies: 3
    Last Post: 3rd August 2010, 08:02
  3. Replies: 1
    Last Post: 26th October 2008, 18:39
  4. Transparency ... Again
    By EricF in forum Qt Programming
    Replies: 4
    Last Post: 1st December 2007, 19:52
  5. transparency
    By roms18 in forum Qt Programming
    Replies: 2
    Last Post: 16th February 2006, 19:38

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
  •  
Qt is a trademark of The Qt Company.