Java Reference
In-Depth Information
private void decode() {
try {
if ( isSupported() ) {
VisualTagConnection conn =
(VisualTagConnection)Connector.open("vtag://");
data = conn.readVisualTag(image, imageClass, sym);
conn.close();
}
}
catch (IOException ioe) { ... }
catch (VisualTagCodingException ce) { ... }
}
private void encode() {
try {
if ( isSupported() ) {
ImageProperties props =
SymbologyManager.getImageProperties(sym);
VisualTagConnection conn =
(VisualTagConnection)Connector.open("vtag://");
image = (Image)conn.generateVisualTag(data, imageClass, props);
conn.close();
}
}
catch (ContactlessException ce) {…}
catch (IOException ioe) {…}
catch (VisualTagCodingException ce) {…}
}
}
On creation, this helper accepts either an image object (such as that obtained using
the MMAPI, as I show you in Chapter 16) or an array of bytes representing a byte stream,
and it creates the corresponding representation as either an array of bytes or an encoded
QR Code. If you obtain an encoded QR Code, you will receive the data as an instance of
the Image class. The isSupported method handles the discovery of supported symbologies
and image representations, querying the SymbologyManager for its list of supported sym-
bologies and image classes. (When the code finds a matching image class, I copy it to the
imageClass instance variable, because the method for generating a visual tag takes a Class
instance, not the name of a class.)
 
Search WWH ::




Custom Search