Skip to content

Commit 290b4a7

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 185ba37 + ac3da81 commit 290b4a7

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/main/kotlin/gli_/misc.kt

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ import kool.lib.toByteArray
55
import kool.pos
66
import org.lwjgl.BufferUtils
77
import java.awt.image.BufferedImage
8+
import java.io.File
89
import java.net.URI
910
import java.nio.ByteBuffer
1011
import java.nio.file.Path
1112
import java.nio.file.Paths
13+
import javax.imageio.ImageIO
1214

1315
infix fun Int.has(b: Int) = (this and b) != 0
1416
infix fun Int.hasnt(b: Int) = (this and b) == 0
@@ -35,12 +37,20 @@ operator fun Array<dx.Format>.get(index: Format): dx.Format =
3537
get(index.i - Format.FIRST.i)
3638

3739
fun BufferedImage.flipY() {
38-
lateinit var scanline1: Any
39-
lateinit var scanline2: Any
40+
var scanline1: Any? = null
41+
var scanline2: Any? = null
4042
for (i in 0 until height / 2) {
4143
scanline1 = raster.getDataElements(0, i, width, 1, scanline1)
4244
scanline2 = raster.getDataElements(0, height - i - 1, width, 1, scanline2)
4345
raster.setDataElements(0, i, width, 1, scanline2)
4446
raster.setDataElements(0, height - i - 1, width, 1, scanline1)
4547
}
46-
}
48+
}
49+
50+
//fun main() {
51+
// val file = File("C:\\Users\\elect\\Pictures\\1.png")
52+
// println(file.exists() && file.canRead())
53+
// val image = ImageIO.read(file)
54+
// image.flipY()
55+
// ImageIO.write(image, "png", File("flipped.png"))
56+
//}

0 commit comments

Comments
 (0)