Basic Examples (2)
Generate a compressed box representation of an image:
Display boxes as formatted:
Compare to ToBoxes:
Convert an expression to its box representation:
Check the size:
Compare to ToBoxes:
Check the appearance of both:
Scope (5)
Use the second argument of ToCompressedBoxes to choose the format type:
Using a single argument is equivalent to choosing StandardForm:
Compare to TraditionalForm:
Reduce the box size of large Iconize expressions:
Check the size:
Compare to ToBoxes:
Use Unevaluated to yield behavior like MakeBoxes instead of ToBoxes:
Without Unevaluated, the given expr will evaluate:
The boxes produced by ToCompressedBoxes can be smaller than ToBoxes even when raster boxes are not involved:
Check the display form:
Applications (2)
Compress data stored in a DynamicModule:
Define custom formatting for a function using MakeBoxes:
ToCompressedBoxes uses the new formatting automatically:
Properties and Relations (2)
ToCompressedBoxes will be equivalent to ToBoxes when there is nothing to compress:
Boxes produced by ToCompressedBoxes will usually round-trip to other formats without significant changes in size:
Convert to a String and back:
The size is unchanged:
ToBoxes will yield NumericArray objects in rasters, which are efficient when packed:
However, these will not round trip as well as the boxes produced by ToCompressedBoxes since GraphicsBox prevents evaluation:
The size increased by a factor of 32:
Both forms are equivalent when passed to the front end for display:
Possible Issues (1)
ToCompressedBoxes trades time for space:
Neat Examples (1)
Define formatting for a symbol that uses compressed boxes automatically: