Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for java.awt.image.RenderedImage #366

Merged
merged 1 commit into from May 13, 2019

Conversation

Projects
None yet
2 participants
@sbrunk
Copy link
Member

commented May 12, 2019

Includes BufferedImage (which implements RenderedImage) as done back in #35.

Usage example with EvilPlot (or as gist):

interp.repositories() ++= Seq(
  coursier.MavenRepository("https://dl.bintray.com/cibotech/public")
)
import $ivy.`com.cibo::evilplot-repl:0.6.3`

import com.cibo.evilplot.plot._
import com.cibo.evilplot.plot.aesthetics.DefaultTheme._
import com.cibo.evilplot.numeric.Point

val data = Seq.tabulate(100) { i =>
  Point(i.toDouble, scala.util.Random.nextDouble())
}

val plot = ScatterPlot(data)
  .xAxis()
  .yAxis()
  .frame()
  .xLabel("x")
  .yLabel("y")
  .render()

Image.fromRenderedImage(plot.asBufferedImage, Image.PNG)

@sbrunk sbrunk added the enhancement label May 12, 2019

Show resolved Hide resolved modules/scala/jupyter-api/src/main/scala/almond/display/Image.scala Outdated
@@ -108,14 +111,27 @@ final class Image private (

object Image extends Display.Builder[Array[Byte], Image] {

def fromRenderedImage(image: RenderedImage, format: Format = JPG): Image = {

This comment has been minimized.

Copy link
@alexarchambault

alexarchambault May 12, 2019

Member

Better add two overloads with no actual default values (one accepting both args, one accepting one arg calling the former), to make it easier to accept extra args in the future, while preserving binary compatibility.

This comment has been minimized.

Copy link
@sbrunk

sbrunk May 12, 2019

Author Member

Without a default value we could also overload Image.apply here. Do you have a preference on this?

This comment has been minimized.

Copy link
@sbrunk

sbrunk May 12, 2019

Author Member

Using to overloads now as suggested. Kept fromRenderedImage for now because it feels more consistent with from and fromFile in Builder.

None,
None,
contentOrUrl,
width = None,

This comment has been minimized.

Copy link
@alexarchambault

@sbrunk sbrunk force-pushed the sbrunk:renderedimage branch from 550d191 to 3f2d1f3 May 12, 2019

@alexarchambault

This comment has been minimized.

Copy link
Member

commented May 13, 2019

Merging, thanks!

@alexarchambault alexarchambault merged commit 2eff48d into almond-sh:master May 13, 2019

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@sbrunk sbrunk deleted the sbrunk:renderedimage branch May 13, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.