SebastianLie / pe

0 stars 0 forks source link

bg does not allow .tiff images and throws wrong exception #8

Open SebastianLie opened 4 years ago

SebastianLie commented 4 years ago

image.png

bg image in question:

image.png

Image type was not specified in lengthy user guide.

nus-pe-bot commented 4 years ago

Team's Response

Hi, thank you for pointing out this bug.

The bug is reproduced exactly as described, and the following are identified to be causes:

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/):

  1. Create a new ImageInputStream of the image to be set using ImageIO.createImageInputStream(file).
  2. Obtain an Iterator of ImageReader objects that can read the image using ImageIO.getImageReaders.
  3. Retrieve an ImageReader from the iterator and get the image’s format name using ImageReader.getFormatName().
  4. If the image does not have format name “bmp”, “JPEG”, “png” or “gif”, then display the user an error message indicating that file formats can only be one of these four types.

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.