@@ -41,12 +41,16 @@ import org.jetbrains.kotlinx.dataframe.dataTypes.IMG
41
41
import org.jetbrains.kotlinx.dataframe.impl.codeGen.CodeGenerationReadResult
42
42
import org.jetbrains.kotlinx.dataframe.impl.codeGen.urlCodeGenReader
43
43
import org.jetbrains.kotlinx.dataframe.impl.createStarProjectedType
44
+ import org.jetbrains.kotlinx.dataframe.impl.io.resizeKeepingAspectRatio
45
+ import org.jetbrains.kotlinx.dataframe.impl.io.toBase64
46
+ import org.jetbrains.kotlinx.dataframe.impl.io.toByteArray
44
47
import org.jetbrains.kotlinx.dataframe.impl.renderType
45
48
import org.jetbrains.kotlinx.dataframe.io.DataFrameHtmlData
46
49
import org.jetbrains.kotlinx.dataframe.io.SupportedCodeGenerationFormat
47
50
import org.jetbrains.kotlinx.dataframe.io.supportedFormats
48
51
import org.jetbrains.kotlinx.jupyter.api.*
49
52
import org.jetbrains.kotlinx.jupyter.api.libraries.*
53
+ import java.awt.image.BufferedImage
50
54
import kotlin.reflect.KClass
51
55
import kotlin.reflect.KProperty
52
56
import kotlin.reflect.KType
@@ -55,6 +59,8 @@ import kotlin.reflect.full.isSubtypeOf
55
59
/* * Users will get an error if their Kotlin Jupyter kernel is older than this version. */
56
60
private const val MIN_KERNEL_VERSION = " 0.11.0.198"
57
61
62
+ private const val DEFAULT_HTML_IMG_SIZE = 100
63
+
58
64
internal val newDataSchemas = mutableListOf<KClass <* >>()
59
65
60
66
internal class Integration (
@@ -203,6 +209,19 @@ internal class Integration(
203
209
}
204
210
}
205
211
212
+ notebook.renderersProcessor.registerWithoutOptimizing(
213
+ createRenderer<BufferedImage > {
214
+ val src = buildString {
215
+ append(""" data:image/$DEFAULT_HTML_IMG_SIZE ;base64,""" )
216
+ append(
217
+ it.resizeKeepingAspectRatio(DEFAULT_HTML_IMG_SIZE ).toByteArray().toBase64()
218
+ )
219
+ }
220
+ HTML (""" <img src="$src "/>""" )
221
+ },
222
+ ProcessingPriority .HIGHER
223
+ )
224
+
206
225
with (JupyterHtmlRenderer (config.display, this )) {
207
226
render<DisableRowsLimitWrapper >(
208
227
{ " DataRow: index = ${it.value.rowsCount()} , columnsCount = ${it.value.columnsCount()} " },
0 commit comments