figToImStream

Stream figure as byte array encoded in specified format

Description

example

output = figToImStream creates a signed byte array with the PNG data for the current figure. The size and position of the printed output depends on the figure's PaperPosition[mode] properties.

example

output = figToImStream (Name,Value) creates a byte array with the image data for the specified figure. You can specify the encoding format for the image and if the byte array is signed or unsigned. The size and position of the printed output depends on the figure's PaperPosition[mode] properties.

Examples

Convert current figure to a signed PNG formatted byte array

surf(peaks)
bytes = figToImStream

Convert a specific figure to a bitmap stored in an unsigned byte array

f = figure;
surf(peaks);
bytes = figToImStream('figHandle',f,...
                      'imageFormat','bmp',...
                      'outputType','uint8');

Input Arguments

collapse all

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: 'figHandle', f, 'imageFormat', 'bmp', 'outputType', 'uint8' specifies the figure f is streamed into an unsigned byte array as a bitmap.

Figure to stream, specified as the comma-separated pair consisting of 'figHandle' and a figure handle.

Encoding format, specified as the comma-separated pair consisting of 'imageFormat' and one of these values:

  • png — encode the image using the Portable Network Graphics (PNG) format

  • jpg — encode the image using the JPEG format

  • bmp — encode the image as a bitmap

  • gif — encode the image using the Graphics Interchange Format (GIF)

Type of bytes to store the image stream, specified as the comma-separated pair consisting of 'outputType' and one of these values:

  • int8 — use a signed byte array

  • uint8 — use an unsigned byte array

Output Arguments

collapse all

Encoded figure data returned as a byte array.

Introduced in R2009b