File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1313 O> bitmap:copy-to-pcolors image true
1414 O> set pcolors map [ p -> [pcolor] of p ] (sort patches)
1515 O> set base64 bitmap:to-base64 image
16- substring base64 0 49 => "iVBORw0KGgoAAAANSUhEUgAAAEAAAAAwCAYAAAChS3wfAAAnc "
16+ substring base64 0 49 => "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEA "
1717 O> set image bitmap:from-base64 base64
1818 O> bitmap:copy-to-pcolors image true
1919 pcolors = map [ p -> [pcolor] of p ] (sort patches) => true
Original file line number Diff line number Diff line change @@ -128,8 +128,12 @@ public String getAgentClassString() {
128128
129129 public Object report (Argument args [], Context context )
130130 throws ExtensionException , LogoException {
131- String base64 = args [0 ].getString ();
132- byte [] bytes = Base64 .getDecoder ().decode (base64 );
131+ String [] splits = args [0 ].getString ().split ("," );
132+ if (splits .length != 2 ) {
133+ throw new ExtensionException ("Base 64 string must start with a preamble like 'data:image/png;base64,...'" );
134+ }
135+ String base64 = splits [1 ];
136+ byte [] bytes = Base64 .getDecoder ().decode (base64 );
133137 try {
134138 BufferedImage image = ImageIO .read (new ByteArrayInputStream (bytes ));
135139 return new LogoBitmap (image );
@@ -159,7 +163,8 @@ public Object report(Argument args[], Context context)
159163
160164 try {
161165 ImageIO .write (image , "png" , baos );
162- return Base64 .getEncoder ().encodeToString (baos .toByteArray ());
166+ String base64 = Base64 .getEncoder ().encodeToString (baos .toByteArray ());
167+ return "data:image/png;base64," + base64 ;
163168 }
164169 catch (final IOException ex ) {
165170 throw new ExtensionException (ex );
You can’t perform that action at this time.
0 commit comments