Results 1 to 5 of 5

Thread: Changing brightness & contrast of image with alpha channel

  1. #1
    Join Date
    Jan 2011
    Posts
    16
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Changing brightness & contrast of image with alpha channel

    I have the ability to change the brightness & contrast of my grayscale images by changing the 256 entries of the color map (setColorTable()). However, setColorTable() has no effect on an image that hasAlphaChannel(). In the case of hasAlphaChannel() and before setColorTable(), colorTable() returns a valid vector and all of the alpha components are set to opaque even though the image is clearly displayed with transparent. After calling setColorTable(), the colorTable() has the updated values, but the image looks the same. I am sure this is something simple and thank you in advance for your help.

  2. #2
    Join Date
    Jul 2010
    Location
    Indonesia
    Posts
    83
    Thanked 17 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Maemo/MeeGo

    Default Re: Changing brightness & contrast of image with alpha channel

    That only works in case of monochrome and 8-bit images. You may use pixel() and setPixel() to manipulate RGB or RGBA image instead of colorTable() and setColorTable().

  3. #3
    Join Date
    Jan 2011
    Posts
    16
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Changing brightness & contrast of image with alpha channel

    The images that works on is gray-8 with 256 "colors". The images that it does not work on is gray-8+alpha which still only has 256 "colors". I would think that it still apply the color map before and'ing with the alpha mask before or'ing to the scene (basically, not exactly). Getting and setting pixels would be way too expensive as they are rather large images. Thank you for your reply and I hope to hear more ideas soon.

  4. #4
    Join Date
    Jul 2010
    Location
    Indonesia
    Posts
    83
    Thanked 17 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Maemo/MeeGo

    Default Re: Changing brightness & contrast of image with alpha channel

    If the format is QImage::Format_Indexed8 (8-bit indexed), setColorTable() work perfectly no matter the image has alpha channel or not.

  5. #5
    Join Date
    Jan 2011
    Posts
    16
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Changing brightness & contrast of image with alpha channel

    The images that work were created with PNG_COLOR_TYPE_GRAY and the ones that do not PNG_COLOR_TYPE_GRAY_ALPHA. In terms of what Qt sees:
    SIMILARITIES: allGray=isGrayScale=true, colorCount=numColors=256
    DIFFERENCES (respectively): hasAlphaChannel = false & true, bitPlaneCount = 8 & 32, format = Format_Indexed8 & Format_ARGB32

    So, I am wondering if it is possible to have Format_Indexed8 with 8 bitPlaneCount, yet hasAlphaChannel (not just an alpha within the color map).

Similar Threads

  1. QGLWidget renderPixmap and alpha channel
    By omega in forum Newbie
    Replies: 1
    Last Post: 12th September 2015, 01:55
  2. alpha channel problems
    By codebehind in forum Qt Programming
    Replies: 2
    Last Post: 28th February 2010, 22:24
  3. contrast, transparency, brightness...
    By Noxxik in forum Qt Programming
    Replies: 6
    Last Post: 28th February 2009, 22:29
  4. Image brightness/contrast adjustments
    By striker303 in forum Qt Programming
    Replies: 2
    Last Post: 8th September 2008, 08:29
  5. SVG to alpha channel QPixmaps?
    By WinchellChung in forum Newbie
    Replies: 5
    Last Post: 24th August 2007, 21:07

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.