diff --git a/orx-boofcv/src/demo/kotlin/DemoResize01.kt b/orx-boofcv/src/demo/kotlin/DemoResize01.kt new file mode 100644 index 00000000..cd5991c4 --- /dev/null +++ b/orx-boofcv/src/demo/kotlin/DemoResize01.kt @@ -0,0 +1,26 @@ +import org.openrndr.application +import org.openrndr.boofcv.binding.* +import org.openrndr.color.ColorRGBa +import org.openrndr.draw.loadImage + + +fun main() { + application { + program { + // Load an image, convert to BoofCV format using orx-boofcv + val input = loadImage("demo-data/images/image-001.png").toPlanarU8() + + val scaled = input.resize(0.5).toColorBuffer() + val scaled2 = input.resize(0.25).toColorBuffer() + val scaled3 = input.resize(0.1).toColorBuffer() + + extend { + drawer.clear(ColorRGBa.BLACK) + drawer.translate(0.0, (height - scaled.bounds.height) / 2.0) + drawer.image(scaled) + drawer.image(scaled2, scaled.bounds.width, scaled.bounds.height - scaled2.height) + drawer.image(scaled3, scaled.bounds.width + scaled2.bounds.width, scaled.bounds.height - scaled3.height) + } + } + } +} \ No newline at end of file diff --git a/orx-boofcv/src/main/kotlin/Distortion.kt b/orx-boofcv/src/main/kotlin/Distortion.kt new file mode 100644 index 00000000..c9f91d2b --- /dev/null +++ b/orx-boofcv/src/main/kotlin/Distortion.kt @@ -0,0 +1,12 @@ +package org.openrndr.boofcv.binding + +import boofcv.abst.distort.FDistort +import boofcv.struct.image.ImageBase + +fun >?> ImageBase.resize(scaleX: Double, scaleY: Double = scaleX): T { + val scaled = this.createNew((this.width * scaleX).toInt(), (this.height * scaleY).toInt()) + + FDistort(this, scaled).scaleExt().apply() + + return scaled +} \ No newline at end of file