fix crash bug on black rectangle.

Hi.
ByakuGallery is very useful for me.
Thank you, Thank you!!

In some cases, the crash bug occurs.
I had to add a test case to bug.
And add a code for fix it.
Please review my code.