Pencil: Strange dot on the center of canvas

Created on 12 Jun 2016  路  16Comments  路  Source: pencil2d/pencil

I have this captured from my PC.
2016-06-12 2

It happens when I open the program. I did nothing on canvas.
Maybe it's because I built on latest compiler and library. But just in case.

My build:
Pencil2D Nightly Build Jun 10 2016
Run & built with Qt Creator 4.0.0
Compiler MSVC 2015 64bit-Release with Qt 5.6.0
Windows 10 64bits

Most helpful comment

@chchwy @feeef I would say we should have a check function for BitmapImage(). Just like how QImage with QImage::isNull(). I think it might be easier to manage/debug the class in future.

Also I'm willing to spend my spare time to fix these bugs, since I'm starting to use Pencil2D to draw animated pictures heavily. :grinning:

All 16 comments

@hankofficer Yes, this has been reported pre-emptively in the past here: http://www.pencil2d.org/forums/topic/question-function-or-purpose-of-color-square-in-canvas/

We really don't know what is it though, but we know that It has been present ever since older versions. We thought it might be some kind of graphical initialization test, but it is unsure what that really is. No one has had the time to figure it out to be honest, but now that you report it here I think it's fair to mark it as a bug, since we've had reports from other people that claim the square is appearing in their exported images, so it IS a problem. Thank you for taking the time to report!

Hi, while working on the mypaint implementation I have found where this bug was from. The first instance of the empty canvas is a 1x1 pixel image that is not filled with a transparent color so it shows a random pixel in the middle of the screen. It should be very easy to fix and I will try to get a moment to fix it on the current code as soon as I can.

You can ignore my previous message. Unfortunately, it is more complicated than I thought. Mix quick fix didn't work so I will have to investigate more about this bug.

@feeef Okay! Thanks for the effort. I think I will try my luck this weekend. xD

Also it seems the dot is drawn on the canvas when using brush tool, it can be copied with selection tool.

Thanks @hankofficer !
It is why I guessed that some qimage or qpixmap may be displayed without being correctly initialized somewhere in the rendering process.

If you don't use "fill()" on a qimage after creating it, it will have random pixels.

The dot can be deleted by clearing the frame too, so it behaves like any other part of the drawing... for what that's worth.

It was indeed caused by 1x1 pixel image. :)

At first I think it might be hard to fixed because I have to set image to NULL, all functions using that class would need to check NULL first before use it. Luckily I found that empty QImage() generated a null image saved me from all these troubles. xD

Well done @hankofficer ! You just fixed a very annoying bug! Thanks for that! :)

Good job! @hankofficer

But I'm afraid that the null image may cause other problems, many operation on null image will fail in silence, so we have to check QImage.isNull(), that's why it's a 1x1 pixel image at starting.

Maybe we need more work on this issue to confirm that everything is fine with null image.

@chchwy That's what I'm afraid of too, but it's for the sake of good practice. I'm kinda like "if it would crash the program, then so be it." and planned to add all NULL check. xD
Also I have roughly tested the result and I haven't noticed any fatal bug that could crash the program yet.

Anyway, I think a common class like BitmapImage() should be carefully planned and should not be changed constantly. ^^

@chchwy , @hankofficer the good practice would be to keep the qimage initialized as it was but to fill it with transparent color :
mImage = new QImage( 1, 1, QImage::Format_ARGB32_Premultiplied ); mImage.fill(Qt::transparent);

@feeef Awesome. Though I prefer initializing it to null image (It's more sensible to me. ^^;), this can reduce the impact to other functions.

@chchwy @hankofficer @feeef I think it's great that there is a discussion happening on this topic, but from the messages I'm seeing there are various ways of approaching this issue, I suggest to you all that you clearly state some advantages and disadvantages for each approach and then we all choose and vote based on logical statements how to solve this.

I hope we can see more of these discussions on every part of the software inner works, because something I've noticed is that people wrote code in the past without a clear guide, and later on others would change it without having second thoughts on the overall functionality of the program, that's why there are so many broken things in Pencil.

So I propose we organize the code to make it the most efficient solution as possible. Thank you all for sharing your thoughts and hard work! Can't wait to have more people joining to help in an organized manner :smile:

My proposition was just to be safer in term of not breaking anything else but I agree with your point of view @hankofficer and I trust you to fix this bug the right way!

@hankofficer I agree with you that a 1x1 pixel image is not sensible, but QImage's null image sometimes fail silently, it's even worse than a real null pointer, because the program doesn't crash, everything looks fine and continues running.

I'm not sure that Qt has fixed the issue in recent versions or not, I'll write a series unit tests to check about it.

@chchwy @feeef I would say we should have a check function for BitmapImage(). Just like how QImage with QImage::isNull(). I think it might be easier to manage/debug the class in future.

Also I'm willing to spend my spare time to fix these bugs, since I'm starting to use Pencil2D to draw animated pictures heavily. :grinning:

Was this page helpful?
0 / 5 - 0 ratings