Top Description Fields Constructors Methods
org.apache.poi.hpsf

public final Class Thumbnail

extends Object
Class Inheritance
Imports
org.apache.poi.util.IOUtils, .LittleEndian

Class to manipulate data in the Clipboard Variant (VT_CF) format.

See Also
SummaryInformation#getThumbnail(), Clipboard Operations

Field Summary

Modifier and TypeField and Description
private byte[]
_thumbnailData

A byte[] to hold a thumbnail image in (VT_CF) format.

public static final int
CF_BITMAP

Clipboard Format - Bitmap

public static final int
CF_DIB

Clipboard Format - Device Independent Bitmap

public static final int
CF_ENHMETAFILE

Clipboard Format - Enhanced Windows metafile format

public static final int
CF_METAFILEPICT

Clipboard Format - Windows metafile format.

public static final int
CFTAG_FMTID

Clipboard Format Tag - Format ID

A GUID containing a format identifier (FMTID).

public static final int
CFTAG_MACINTOSH

Clipboard Format Tag - Macintosh clipboard format

A DWORD indicating a Macintosh clipboard format value

public static final int
CFTAG_NODATA

Clipboard Format Tag - No Data

A DWORD indicating No data.

public static final int
CFTAG_WINDOWS

Clipboard Format Tag - Windows clipboard format

A DWORD indicating a built-in Windows clipboard format value

private static final int
private static int
public static final int
OFFSET_CF

Offset in bytes where the Clipboard Format starts in the byte[] returned by SummaryInformation#getThumbnail()

This is only valid if the Clipboard Format Tag is CFTAG_WINDOWS

public static final int
OFFSET_CFTAG

Offset in bytes where the Clipboard Format Tag starts in the byte[] returned by SummaryInformation#getThumbnail()

public static final int
OFFSET_WMFDATA

Offset in bytes where the Windows Metafile (WMF) image data starts in the byte[] returned by SummaryInformation#getThumbnail()

There is only WMF data at this point in the byte[] if the Clipboard Format Tag is CFTAG_WINDOWS and the Clipboard Format is CF_METAFILEPICT.

Constructor Summary

AccessConstructor and Description
public
Thumbnail()

Default Constructor.

public
Thumbnail(final byte[]
The thumbnail data
thumbnailData
)

Creates a Thumbnail instance and initializes with the specified image bytes.

Method Summary

Modifier and TypeMethod and Description
public long

Returns:

a flag indicating the Clipboard Format
getClipboardFormat
()

Returns an int representing the Clipboard Format

Will throw an exception if the Thumbnail's Clipboard Format Tag is not CFTAG_WINDOWS.

public long

Returns:

A flag indicating the Clipboard Format Tag
getClipboardFormatTag
()

Returns an int representing the Clipboard Format Tag

Possible return values are:

public static int

Returns:

the max record length allowed for SubRecord
getMaxRecordLength
()

public byte[]

Returns:

The thumbnail value
getThumbnail
()

Returns the thumbnail as a byte[] in VT_CF format.

public byte[]

Returns:

A WMF image of the Thumbnail
getThumbnailAsWMF
()

Returns the Thumbnail as a byte[] of WMF data if the Thumbnail's Clipboard Format Tag is CFTAG_WINDOWS and its Clipboard Format is CF_METAFILEPICT

This byte[] is in the traditional WMF file, not the clipboard-specific version with special headers.

public static void
setMaxRecordLength(int
the max record length allowed for SubRecord
length
)

public void
setThumbnail(final byte[]
The new thumbnail value
thumbnail
)

Sets the Thumbnail's underlying byte[] in VT_CF format.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_thumbnailDataback to summary
private byte[] _thumbnailData

A byte[] to hold a thumbnail image in (VT_CF) format.

CF_BITMAPback to summary
public static final int CF_BITMAP

Clipboard Format - Bitmap

CF_DIBback to summary
public static final int CF_DIB

Clipboard Format - Device Independent Bitmap

CF_ENHMETAFILEback to summary
public static final int CF_ENHMETAFILE

Clipboard Format - Enhanced Windows metafile format

CF_METAFILEPICTback to summary
public static final int CF_METAFILEPICT

Clipboard Format - Windows metafile format. This is the recommended way to store thumbnails in Property Streams.

Note

This is not the same format used in regular WMF images. The clipboard version of this format has an extra clipboard-specific header.

CFTAG_FMTIDback to summary
public static final int CFTAG_FMTID

Clipboard Format Tag - Format ID

A GUID containing a format identifier (FMTID). This is rarely used.

CFTAG_MACINTOSHback to summary
public static final int CFTAG_MACINTOSH

Clipboard Format Tag - Macintosh clipboard format

A DWORD indicating a Macintosh clipboard format value

CFTAG_NODATAback to summary
public static final int CFTAG_NODATA

Clipboard Format Tag - No Data

A DWORD indicating No data. This is rarely used.

CFTAG_WINDOWSback to summary
public static final int CFTAG_WINDOWS

Clipboard Format Tag - Windows clipboard format

A DWORD indicating a built-in Windows clipboard format value

DEFAULT_MAX_RECORD_LENGTHback to summary
private static final int DEFAULT_MAX_RECORD_LENGTH
MAX_RECORD_LENGTHback to summary
private static int MAX_RECORD_LENGTH
OFFSET_CFback to summary
public static final int OFFSET_CF

Offset in bytes where the Clipboard Format starts in the byte[] returned by SummaryInformation#getThumbnail()

This is only valid if the Clipboard Format Tag is CFTAG_WINDOWS

OFFSET_CFTAGback to summary
public static final int OFFSET_CFTAG

Offset in bytes where the Clipboard Format Tag starts in the byte[] returned by SummaryInformation#getThumbnail()

OFFSET_WMFDATAback to summary
public static final int OFFSET_WMFDATA

Offset in bytes where the Windows Metafile (WMF) image data starts in the byte[] returned by SummaryInformation#getThumbnail()

There is only WMF data at this point in the byte[] if the Clipboard Format Tag is CFTAG_WINDOWS and the Clipboard Format is CF_METAFILEPICT.

Note

The byte[] that starts at OFFSET_WMFDATA and ends at getThumbnail().length - 1 forms a complete WMF image. It can be saved to disk with a .wmf file type and read using a WMF-capable image viewer.

Constructor Detail

Thumbnailback to summary
public Thumbnail()

Default Constructor. If you use it then one you'll have to add the thumbnail byte[] from SummaryInformation#getThumbnail() to do any useful manipulations, otherwise you'll get a NullPointerException.

Thumbnailback to summary
public Thumbnail(final byte[] thumbnailData)

Creates a Thumbnail instance and initializes with the specified image bytes.

Parameters
thumbnailData:byte[]

The thumbnail data

Method Detail

getClipboardFormatback to summary
public long getClipboardFormat() throws HPSFException

Returns an int representing the Clipboard Format

Will throw an exception if the Thumbnail's Clipboard Format Tag is not CFTAG_WINDOWS.

Possible return values are:

Returns:long

a flag indicating the Clipboard Format

Exceptions
HPSFException:
if the Thumbnail isn't CFTAG_WINDOWS
getClipboardFormatTagback to summary
public long getClipboardFormatTag()

Returns an int representing the Clipboard Format Tag

Possible return values are:

Returns:long

A flag indicating the Clipboard Format Tag

getMaxRecordLengthback to summary
public static int getMaxRecordLength()
Returns:int

the max record length allowed for SubRecord

getThumbnailback to summary
public byte[] getThumbnail()

Returns the thumbnail as a byte[] in VT_CF format.

Returns:byte[]

The thumbnail value

See Also
SummaryInformation#getThumbnail()
getThumbnailAsWMFback to summary
public byte[] getThumbnailAsWMF() throws HPSFException

Returns the Thumbnail as a byte[] of WMF data if the Thumbnail's Clipboard Format Tag is CFTAG_WINDOWS and its Clipboard Format is CF_METAFILEPICT

This byte[] is in the traditional WMF file, not the clipboard-specific version with special headers.

See http://www.wvware.com/caolan/ora-wmf.html for more information on the WMF image format.

Returns:byte[]

A WMF image of the Thumbnail

Exceptions
HPSFException:
if the Thumbnail isn't CFTAG_WINDOWS and CF_METAFILEPICT
setMaxRecordLengthback to summary
public static void setMaxRecordLength(int length)
Parameters
length:int

the max record length allowed for SubRecord

setThumbnailback to summary
public void setThumbnail(final byte[] thumbnail)

Sets the Thumbnail's underlying byte[] in VT_CF format.

Parameters
thumbnail:byte[]

The new thumbnail value

See Also
SummaryInformation#getThumbnail()