Daenyth/Cockatrice — pull request #256 by pliu037 (2014-08-04 21:17:50+00:00)
Title: Handle PNGs (with option to add support for other formats)

Fixes #249.
Before:
Would download image file and save with .jpg extension regardless of actual format of the downloaded image.
Would attempt to load each image as a JPG, including PNGs saved with .jpg extensions, which would cause the load to fail, and Cockatrice to redownload the image.
Fix:
Checks the most significant bytes of the downloaded image file (contains a signature identifying the format) to determine the format and saves the image with the appropriate extension (defaults to .jpg).
Attempts to load each image first as a JPG, then as a PNG ("card name".full.png is now supported).
Can easily add support for more image formats by adding additional format checks for when downloading/saving the image and additional if statements at loading.

P.S.: To be honest, we may not even require checking in picsPath/setName/ (i.e.:
if (!image.load(QString("%1/%2/%3.full.jpg").arg(picsPath).arg(setName).arg(correctedName)))
if (!image.load(QString("%1/%2/%3.full.png").arg(picsPath).arg(setName).arg(correctedName))) )
since people using custom images can place those images in the CUSTOM folder whereas people using the default images will have all of those images in picsPath/downloadedPics/setName/ instead.