[orx-boofcv] Add colorBuffer resize
This commit is contained in:
committed by
Edwin Jakobs
parent
51b8c38230
commit
4a24cb5fea
26
orx-boofcv/src/demo/kotlin/DemoResize01.kt
Normal file
26
orx-boofcv/src/demo/kotlin/DemoResize01.kt
Normal file
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
12
orx-boofcv/src/main/kotlin/Distortion.kt
Normal file
12
orx-boofcv/src/main/kotlin/Distortion.kt
Normal file
@@ -0,0 +1,12 @@
|
||||
package org.openrndr.boofcv.binding
|
||||
|
||||
import boofcv.abst.distort.FDistort
|
||||
import boofcv.struct.image.ImageBase
|
||||
|
||||
fun <T : ImageBase<out ImageBase<*>>?> ImageBase<T>.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
|
||||
}
|
||||
Reference in New Issue
Block a user