Skip to content

Commit

Permalink
ColormapPanel: Use correct texture size for padded colormap
Browse files Browse the repository at this point in the history
  • Loading branch information
skalarproduktraum committed Aug 7, 2024
1 parent 99b96b4 commit 5fc60bf
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/main/kotlin/graphics/scenery/volumes/ColormapPanel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,8 @@ class ColormapPanel(val target:Volume?): JPanel() {
repaint()

if(width > 0 && height > 0) {
target?.colormap = Colormap.fromBuffer(toBuffer(), width, height)
val bi = toImage()
target?.colormap = Colormap.fromBuffer(Image.bufferedImageToRGBABuffer(bi), bi.width, bi.height)
}
}

Expand All @@ -310,10 +311,6 @@ class ColormapPanel(val target:Volume?): JPanel() {
return bufferedImage
}

private fun toBuffer(): ByteBuffer {
return Image.bufferedImageToRGBABuffer(toImage())
}

private fun pointAtMouse(e: MouseEvent) =
colorPoints.firstOrNull { (e.x - (width * it.position)).absoluteValue < height / 2 }

Expand All @@ -325,9 +322,7 @@ class ColormapPanel(val target:Volume?): JPanel() {
val h = height
val pointList = colorPoints.sortedBy { it.position }


// background Gradient
//paintBackgroundGradient(pointList, g2d)
val img = toImage()
g2d.drawImage(img, 0, 0, this)

Expand Down

0 comments on commit 5fc60bf

Please sign in to comment.