Working with MATLAB Figure
and Image Data
Front-End Web Developer
| Role | Knowledge Base | Responsibilities |
Front-end
Web developer | | As service consumer, manages presentation and usability Creates front-end applications Integrates MATLAB code with language-specific frameworks
and environments Integrates WebFigures with the rest of the Web page
|
For More Comprehensive Examples
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 MATLAB Application Deployment Web Example Guide.
Back to Top
Working with Figures
Getting a Figure From a Deployed Component
For information about how to retrieve a figure from a deployed
component, see Deploying a Java Component Over the Web
Back to Top
Working with Images
Getting Encoded Image Bytes from an Image in a Component
Java
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);
}
}
Getting a Buffered Image in a Component
Java
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();
}
}
Back to Top
 | Creating and Modifying a MATLAB Figure | | Creating Scalable Web Applications Using RMI |  |
Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
Get the Interactive Kit