This section contains code snippets intended to demonstrate specific functionality related to working with figure and image data.
To see these snippets in the context of more fully-functional multi-step examples, see the Use MATLAB Compiler SDK Web Example Guide.
For information about how to retrieve a figure from a deployed component, see Implement a WebFigure
public byte[] getByteArrayFromDeployedComponent() { Object[] byteImageOutput = null; MWNumericArray numericImageByteArray = null; try { byteImageOutput = deployment.getImageDataOrientation( 1, //Number Of Outputs 500, //Height 500, //Width 30, //Elevation 30, //Rotation "png" //Image Format ); numericImageByteArray = (MWNumericArray)byteImageOutput[0]; return numericImageByteArray.getByteData(); } finally { MWArray.disposeArray(byteImageOutput); } }
public byte[] getByteArrayFromDeployedComponent() { Object[] byteImageOutput = null; MWNumericArray numericImageByteArray = null; try { byteImageOutput = deployment.getImageDataOrientation( 1, //Number Of Outputs 500, //Height 500, //Width 30, //Elevation 30, //Rotation "png" //Image Format ); numericImageByteArray = (MWNumericArray)byteImageOutput[0]; return numericImageByteArray.getByteData(); } finally { MWArray.disposeArray(byteImageOutput); } } public BufferedImage getBufferedImageFromDeployedComponent() { try { byte[] imageByteArray = getByteArrayFromDeployedComponent() return ImageIO.read (new ByteArrayInputStream(imageByteArray)); } catch(IOException io_ex) { io_ex.printStackTrace(); } }