Open SebastianLie opened 4 years ago
Hi, thank you for pointing out this bug.
The bug is reproduced exactly as described, and the following are identified to be causes:
javafx.scene.image.Image
are indicated to be bmp
, gif
, jpeg
and png
respectively via https://docs.oracle.com/javase/8/javafx/api/javafx/scene/image/Image.html.reader
method from ImageIO
(used to verify validity of the user’s path) is able to read image streams (of files) from automatically selected ImageReader
s, which could include those able to read streams of files with image format tif
.tif
image is loadable using ImageIO
(and thus passes the validity test), it is unsupported by javafx.scene.image.Image
.Image
does not throw any NullPointerException or IllegalArgumentException when reading in a tif
file.jpg
, gif
or png
as the extension (which had been tested to work), and non-image files with extensions such as pdf
were verified not to work.The solution for the bug fix would be to check for the image format, in addition to existing checks, using the algorithm as follows (with reference to https://examples.javacodegeeks.com/desktop-java/imageio/determine-format-of-an-image/):
ImageInputStream
of the image to be set using ImageIO.createImageInputStream(file)
.Iterator
of ImageReader
objects that can read the image using ImageIO.getImageReaders
.ImageReader
from the iterator and get the image’s format name using ImageReader.getFormatName()
.Additionally, the user guide should also include that only these specific types are allowed for images to be added, for both the display picture and background picture.
The issue described is the same one causing the bug reported in #430.
With regards to the error message, it is an expected exception as the dominant colour of the image you intended to use for bg
was of a light colour that could clash with the yellowish fontcolour
; the program actually scans for and validates this by reading the image as a BufferedImage
rather than a javafx Image
, then scanning the colours pixel by pixel using the ImageAnalyser
class as described in page 29 of our developer guide (https://mynbox.nus.edu.sg/userportal/#/shared/public/lxQFvFSUBbKFFAW1/CS2103-PE/not-zipped/CS2103-T16-1). Thus, the program displays an error indicating for the user to change the fontcolour
first, or change both fontcolour
and bg
simultaneously. This behaviour is clearly explained in the fifth and sixth paragraphs of page 23 in our user guide.
bg image in question:
Image type was not specified in lengthy user guide.