Mercurial > cgi-bin > hgweb.cgi > ImagePrep
comparison src/name/blackcap/imageprep/RotateDialog.kt @ 16:2bb46da74667
Detect unsupported file types on input.
author | David Barts <n5jrn@me.com> |
---|---|
date | Mon, 20 Jul 2020 12:56:07 -0700 |
parents | 3feeb953d9ae |
children | 5fa5d15b4a7b |
comparison
equal
deleted
inserted
replaced
15:fad32eda667f | 16:2bb46da74667 |
---|---|
144 Application.mainFrame.useWaitCursor() | 144 Application.mainFrame.useWaitCursor() |
145 swingWorker<Pair<BufferedImage?, IOException?>> { | 145 swingWorker<Pair<BufferedImage?, IOException?>> { |
146 inBackground { | 146 inBackground { |
147 try { | 147 try { |
148 val imageIn = ImageIO.read(input) /* IOException */ | 148 val imageIn = ImageIO.read(input) /* IOException */ |
149 if (imageIn == null) | |
150 throw IOException("Unsupported file type.") | |
149 val ratio = Settings.maxDimension.toDouble() / max(imageIn.width, imageIn.height).toDouble() | 151 val ratio = Settings.maxDimension.toDouble() / max(imageIn.width, imageIn.height).toDouble() |
150 if (ratio >= 1.0) { | 152 if (ratio >= 1.0) { |
151 Pair(null, null) | 153 Pair(null, null) |
152 } else { | 154 } else { |
153 val nWidth = (imageIn.width * ratio).toInt() | 155 val nWidth = (imageIn.width * ratio).toInt() |