Skip to content

Commit

Permalink
[GS] adds the possibility to set the format for send_image_to_websocket
Browse files Browse the repository at this point in the history
  • Loading branch information
lesquoyb committed Nov 4, 2024
1 parent 9cb044b commit d81e988
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions gama.extension.image/src/gama/extension/image/ImageOperators.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down

0 comments on commit d81e988

Please sign in to comment.