Results 1 to 4 of 4

Thread: copying the alpha channel

  1. #1
    Join Date
    Jun 2011
    Posts
    56
    Thanks
    7
    Qt products
    Qt4

    Default copying the alpha channel

    What is the fastest way to copy the alpha values of pixels between 2 images of the same dimensions? That is:

    Qt Code:
    1. copyAlphaChannel(image1, image2);
    To copy to clipboard, switch view to plain text mode 

    where image1.size() == image2.size().

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: copying the alpha channel

    It heavily depends on the image format. In a general case unfortunately you have to iterate over pixels, read their values, adjust the alpha of the other picture and store the modified value. Or you can probably use composition modes available for QPainter to draw one image on top of the other however I'm quite certain that operation is going to be slower than the former one.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jun 2011
    Posts
    56
    Thanks
    7
    Qt products
    Qt4

    Default Re: copying the alpha channel

    The docs seem to hint that composition modes are the preferred way to do it. Can you supply a sequence of composition modes I could apply to achieve the copy?

  4. #4
    Join Date
    Jun 2011
    Posts
    56
    Thanks
    7
    Qt products
    Qt4

    Default Re: copying the alpha channel

    Never mind, I've helped myself with CompositionMode_SourceIn, seems to work ok and fast.

Similar Threads

  1. QGLWidget renderPixmap and alpha channel
    By omega in forum Newbie
    Replies: 1
    Last Post: 12th September 2015, 01:55
  2. setting QPixmap's alpha channel
    By ugluk in forum Qt Programming
    Replies: 4
    Last Post: 18th September 2012, 08:08
  3. alpha channel problems
    By codebehind in forum Qt Programming
    Replies: 2
    Last Post: 28th February 2010, 22:24
  4. SVG to alpha channel QPixmaps?
    By WinchellChung in forum Newbie
    Replies: 5
    Last Post: 24th August 2007, 21:07
  5. Alpha channel weirdness with QGLContext
    By renaissanz in forum Qt Programming
    Replies: 2
    Last Post: 15th March 2006, 16:10

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.