Pownylover / PxCT

Pixelcanvas.io tempalte helper
MIT License
0 stars 1 forks source link

Transparent pixels count as good pixels #2

Open TheDarkTiger opened 1 year ago

TheDarkTiger commented 1 year ago

Problem: Transparent pixels count as good pixels. Thus, models with a lot of transparent pixels appear to be half finished, when in reality, its almost erased.

Normal behavior: Transparent pixels should not be counted as good or bad pixels, just ignored in the pixel count.

TheDarkTiger commented 1 year ago

I unfortunately can't compile the project on my computer despite having installed Visual Studio 2019 with a version higher than 16.0.30804.86 (as stated on PxCT.sln), and .net5 (as stated on PxCT.csproj). I also tried a bit with Visual Studio Code without success. I also never did C#, so it's not easy to debug.

Anyway, from the code reading, I understod that you made a typo in "MainViewModel.cs", line 473. You indeed count the total pixel number in "pixelCount", and you check for the transparency in order not to include the transparent pixels in the count (and that's exactly what should be done). The only problem is that you use the canvas itself as a source "currentColorId" (which never have any transparent pixels) instead of the template "targetColorId".

So, I think changing line 473 from pixelCount += currentColorId != -1 ? 1 : 0; to pixelCount += targetColorId != -1 ? 1 : 0; should solve the issue.

What do you think?