Skip to content
This repository has been archived by the owner on Aug 29, 2020. It is now read-only.

Commit

Permalink
Merge pull request #103 from Deledrius/jpegcruft
Browse files Browse the repository at this point in the history
Remove old JPEG fallback code in screenshot function.
  • Loading branch information
Hoikas committed Jan 16, 2017
2 parents 91e1fc9 + c21bde9 commit 316dece
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions Python/ki/__init__.py
Expand Up @@ -1157,30 +1157,22 @@ def OnScreenCaptureDone(self, image):
self.takingAPicture = False

# Save the image to the filesystem.
if "saveAsPNG" in dir(image):
preferredExtension = "png"
else:
preferredExtension = "jpg"

basePath = os.path.join(PtGetUserPath(), kImages.Directory)
if not PtCreateDir(basePath):
PtDebugPrint(u"xKI.OnScreenCaptureDone(): Unable to create \"{}\" directory. Image not saved to disk.".formatZ(basePath))
return

imageList = glob.iglob(os.path.join(basePath, "{}[0-9][0-9][0-9][0-9].{}".format(kImages.FileNameTemplate, preferredExtension)))
imageList = glob.iglob(os.path.join(basePath, "{}[0-9][0-9][0-9][0-9].png".format(kImages.FileNameTemplate)))
imageNumbers = [int(os.path.basename(img)[7:-4]) for img in imageList] + [0]
missingNumbers = set(range(1, max(imageNumbers))).difference(set(imageNumbers))
if len(missingNumbers) > 0:
firstMissing = min(missingNumbers)
else:
firstMissing = max(imageNumbers) + 1
tryName = os.path.join(basePath, U"{}{:04d}.{}".format(kImages.FileNameTemplate, firstMissing, preferredExtension))
tryName = os.path.join(basePath, U"{}{:04d}.png".format(kImages.FileNameTemplate, firstMissing))

PtDebugPrint(u"xKI.OnScreenCaptureDone(): Saving image to \"{}\".".format(tryName), level=kWarningLevel)
if "saveAsPNG" in dir(image):
image.saveAsPNG(tryName)
else:
image.saveAsJPEG(tryName, 90)
image.saveAsPNG(tryName)

## Called by Plasma when the player list has been updated.
# This makes sure that everything is updated and refreshed.
Expand Down

0 comments on commit 316dece

Please sign in to comment.