What is the fastest way to copy the alpha values of pixels between 2 images of the same dimensions? That is:
Qt Code:
copyAlphaChannel(image1, image2);To copy to clipboard, switch view to plain text mode
where image1.size() == image2.size().
What is the fastest way to copy the alpha values of pixels between 2 images of the same dimensions? That is:
Qt Code:
copyAlphaChannel(image1, image2);To copy to clipboard, switch view to plain text mode
where image1.size() == image2.size().
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.
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?
Never mind, I've helped myself with CompositionMode_SourceIn, seems to work ok and fast.
Bookmarks