pencil2d / pencil

Pencil2D is an easy, intuitive tool to make 2D hand-drawn animations. Pencil2D is open source and cross-platform.
http://pencil2d.org
GNU General Public License v2.0
1.47k stars 273 forks source link

Frames imported with Movie Video Import produce alpha channel artifacts #1641

Closed Jose-Moreno closed 3 years ago

Jose-Moreno commented 3 years ago

Issue Summary

Manipulating the imported frames will cause visual artefacts to the alpha channel transformed by the move tool in the area surrounded by the rectangular marquee causing a "black fill" (usual color representation for transparency / alpha values).

I've already tested this with all the other import options and only the movie video options does this.

There are three components that seem to be related to this:

  1. The movie video import feature. It could be an FFMPEG incorrectly configurated flag or a specific problem with the exact format conversion.
  2. The selection & move tools. Transforming the image is the only way to bring this issue forth.
  3. Image cache. After doing some experiments I've also seen that the image cache for the produced artifact can be affected via deleting the "fill"

Note: it's also unexpected that I can undo the "glitch" all the time.

Expected Results

Having no visual glitch nor incorrect alpha channel information for any imported image either bitmap or vector.

Video or Image Reference

https://youtu.be/HAaUtoLCfLU

Steps to reproduce

  1. Import a movie video
  2. Create a selection that covers part of the image and part of the transparent canvas (the bg color of the canvas doesn't matter)
  3. use the move tool to transform the image
  4. Notice the transparent part became filled with black.

System Information

Nightly Build May 11 2021

commit: 7ba6e71f81eb6337af4cb378284b7e72ea160f79 date: 2021-05-11_07:39:53

Operating System: Windows 10 Version 2009 CPU Architecture: x86_64 Qt Version: 5.15.2

scribblemaniac commented 3 years ago

I have found the issue. From https://doc.qt.io/qt-5/qimage.html#copy:

In areas beyond this image, pixels are set to 0. For 32-bit RGB images, this means black; for 32-bit ARGB images, this means transparent black; for 8-bit images, this means the color with index 0 in the color table which can be anything; for 1-bit images, this means Qt::color0.

This is happening because the images produces by movie export are RGB images, not ARGB images. At the very least we will have to add some checks to BitmapImage::copy and call QImage::convertToFormat if the format is not ARGB and the rectangle extends beyond the image bounds.

scribblemaniac commented 3 years ago

@Jose-Moreno When you get a chance can you test to confirm that this has been fixed for you in the latest nightly build?

Jose-Moreno commented 3 years ago

@Jose-Moreno When you get a chance can you test to confirm that this has been fixed for you in the latest nightly build?

@scribblemaniac Will do, thank you for notifying me 🙇

Jose-Moreno commented 3 years ago

@scribblemaniac Sorry it took me so long. After following the issue steps I can no longer reproduce this. I also tried saving and reloading like last time I had this problem and it didn't appear, so I'd say it's positively fixed. Thanks a lot!