background image
C H A P T E R 1 2
Special-Purpose Objects for Data Storage and Retrieval
Using Special-Purpose Data Storage Objects
12-9
The
NewVBO
and
NewCompressedVBO
store methods create virtual binary
objects. Both methods require that you specify the class of the binary object to be
created, as well as the store on which VBO data is to reside.
The following code fragment uses the store method
NewVBO
to create a new,
uncompressed, "blank" virtual binary object on the default store:
// create new uncompressed VBO of size 5 KB and class 'samples
local binData := GetDefaultStore():NewVBO('samples,5000);
Another way to create an uncompressed VBO is to pass
nil
as the
values of the companderName and companderData parameters to the
NewCompressedVBO
method, as the following code fragment shows:
// create new uncompressed VBO of size 5 KB and class 'samples
local binData := GetDefaultStore():NewCompressedVBO('samples, 5000,
nil, nil);
When you create a compressed VBO, you need to specify how the system is to
expand and compress data moved to and from the store associated with the VBO.
The system provides two compressor-expanders (also known as companders),
which compress and expand raw binary data on demand. The companderName
parameter to the
NewCompressedVBO
method indicates the compander to be used
for that particular VBO's data.
The Lempel-Ziv compander is a suitable for most data types; its use is specified by
passing the string
"TLZStoreCompander"
as the value of the companderName
parameter to the
NewCompressedVBO
method. The pixel map compander is
specialized for use with pixel map data; its use is specified by passing the string
"TPixelMapCompander"
as the value of the companderName parameter to the
NewCompressedVBO
method.
W A R N I N G
The pixel map compander makes certain assumptions about the
data passed to it; do not use it for any kind of data other than pixel
maps. For more information, see the description of the
NewCompressedVBO
method (page 9-75) in
Newton
Programmer's Reference
.
Because both of the companders provided by the current implementation of the
system initialize themselves automatically, you must always pass
nil
as the value
of the companderArgs parameter to the
NewCompressedVBO
method.
To create a new compressed VBO, specify a compander and a store in the arguments
to the
NewCompressedVBO
method, as shown in the following example:
// create new compressed VBO of size 5 KB and class 'pixMap
local binData := GetDefaultStore():NewCompressedVBO('pixMap,
5000,"TPixelMapCompander", nil);
© 2007-2024, o7 studio » при воспроизведении материала сайта ссылка обязательна