Tuesday, March 09, 2010

Custom Quartz Composer Patches: How to include a shared library

I have been struggling a little bit to make my "DataMatrixDecoder" patch load libdmtx as a shared library.

Actually it is pretty simple:
instead of the @executable_path, the install name needs to contain @loader_path.

Here some tools that can help you to make things work and check that things worked out the intended way (credits go to Mac OS X Hacking Tools):
1) install_name_tool to change recorded install names of a mach-o-binary.

2) lipo: to check if the universal binary magic worked out e.g.:
orion:Release wimpi$ lipo -detailed_info QuartzDM.plugin/Contents/MacOS/QuartzDM 
Fat header in: QuartzDM.plugin/Contents/MacOS/QuartzDM
fat_magic 0xcafebabe
nfat_arch 3
architecture x86_64
    cputype CPU_TYPE_X86_64
    cpusubtype CPU_SUBTYPE_X86_64_ALL
    offset 4096
    size 18872
    align 2^12 (4096)
architecture i386
    cputype CPU_TYPE_I386
    cpusubtype CPU_SUBTYPE_I386_ALL
    offset 24576
    size 21460
    align 2^12 (4096)
architecture ppc7400
    cputype CPU_TYPE_POWERPC
    cpusubtype CPU_SUBTYPE_POWERPC_7400
    offset 49152
    size 21956
    align 2^12 (4096)
3) otool to check and display info about the mach-o-binary like it's dependencies. e.g.
orion:Release wimpi$ otool -L QuartzDM.plugin/Contents/MacOS/QuartzDM 
QuartzDM.plugin/Contents/MacOS/QuartzDM:
 /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa (compatibility version 1.0.0, current version 15.0.0)
 /System/Library/Frameworks/Quartz.framework/Versions/A/Quartz (compatibility version 1.0.0, current version 1.0.0)
 @loader_path/libdmtx.dylib (compatibility version 1.0.0, current version 1.0.0)
 /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 123.0.0)
 /usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 227.0.0)
 /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 550.0.0)
 /System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices (compatibility version 1.0.0, current version 38.0.0)
 /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 751.0.0)

Monday, March 08, 2010

DataMatrix in Quartz Composer

A while ago I was working on a project proposal for a digitally supported library. The idea was not only to provide digitalized content and metadata, but also to link the physical items (books, tapes etc.) with the digital catalog.

For the link between the physical items and their digital entries, I proposed to tag the items with DataMatrix Codes (2D Barcodes, see DataMatrix@Wikipedia) that store a computer readable unique reference.

Given that the proposal for the terminals was to use iMacs, I put together a piece of software that would allow to grab the barcodes directly from the built-in webcam.

To make it versatile, I developed a simple Quartz Composer Plugin that provides a "DataMatrixDecoder" patch, based on libdmtx.

The result in a simple composition (above), with the viewer (below); the patch is marked with a red dashed oval:


It is versatile, because these compositions can - for example - be embedded into Cocoa applications :


Unfortunately the proposal never turned into a project, but if anybody is interested, don't hesitate to contact me.

Edit 09/03/10:
I have packaged a binary distribution under a Creative Commons Non-Commercial License, which can be downloaded here (RapidShare). Enjoy.