Skip to content
Advertisement

Overlaying Images in a QLabel for Onion Skinning

I’m trying to produce an onion skin effect using a QLabel in PyQt. In the simplified example below, three images are loaded in and drawn to the label using QPainter.

JavaScript

Ideally, the last image would show as fully opaque, with earlier images having an increasingly higher transparency. Instead, I’m getting an output where all three images blend together equally. This seems like a simple problem to fix, but my ‘Google Fu’ hasn’t yielded much this time around.

Edit

Here are the image files. They seem have automatically been converted to .jpg unfortunately. If there’s a better way to include them please let me know.

frame_1

frame_2

frame_3

Edit 2

After some experimentation I’ve decided to compromise and allow some ‘blending’ of the base image. I’m working with raw images from a camera device, so the background of each image is always going to be non-transparent.

In case anyone is interested here is the code:

JavaScript

Advertisement

Answer

Since the OP does not provide the images then the problem can be caused by:

  • The order of how opacity is set.
  • The background color of the image is not transparent.

For my demo I will use this gif and since the background is not transparent (which would be ideal) then I will apply a mask when I paint each image.

JavaScript

enter image description here

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement