From d81e988045ed8d82ddc0893647f69cc540d30e07 Mon Sep 17 00:00:00 2001 From: Baptiste Lesquoy Date: Mon, 4 Nov 2024 21:22:52 +0700 Subject: [PATCH] [GS] adds the possibility to set the format for send_image_to_websocket --- .../gama/extension/image/ImageOperators.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/gama.extension.image/src/gama/extension/image/ImageOperators.java b/gama.extension.image/src/gama/extension/image/ImageOperators.java index 461aaaaf89..ff5eb0317f 100644 --- a/gama.extension.image/src/gama/extension/image/ImageOperators.java +++ b/gama.extension.image/src/gama/extension/image/ImageOperators.java @@ -186,15 +186,28 @@ public static String imgToBase64String(final GamaImage img, final String formatN @operator ( value = "send_image_to_websocket", can_be_const = false) - @doc ("Send the given image to the websocket using Base64.") + @doc ("Send the given image to the websocket in Base64 using the given format.") @no_test - public static GamaImage sendImageWebsocket(final IScope scope, final GamaImage image) { + public static GamaImage sendImageWebsocket(final IScope scope, final GamaImage image, final String format) { + PlatformAgent pa = GAMA.getPlatformAgent(); - pa.sendMessage(scope, imgToBase64String(image, "png"), GamaServerMessage.Type.SimulationImage); + pa.sendMessage(scope, imgToBase64String(image, format), GamaServerMessage.Type.SimulationImage); return image; } + + + @operator ( + value = "send_image_to_websocket", + can_be_const = false) + @doc ("Send the given image to the websocket using Base64 assuming the format is png.") + @no_test + public static GamaImage sendImageWebsocket(final IScope scope, final GamaImage image) { + return sendImageWebsocket(scope, image, "png"); + } + + /** * Grayscale. *