It copmiles and runs fine on my XP machine, but I'm wondering how much of this is platform specific. Can HDC and CreateCompatibleDC be used, or are they specific to Windows?
CreateCompatibleDC, CreateDIBSection and SelectObject are Windows API calls. To make integrating Delphi code easier, lazarus provides cross-platform implementations of several winapi functions, including CreateCompatibleDC and SelectObject, but not CreateDIBSection AFAIK
That implementation is a simple call to a winapi on windows, and on gtk, qt, etc, it's implemented using the native api.
Nevertheless, it's not a perfect implementation, and IMHO you should avoid using this, and instead use LCL components, which would be TCanvas, TBitmap, TFont, TBrush, etc, for drawing.
It's easy to see if your code is cross-platform, just don't use the Windows unit, which only exists on windows. If you need winapi functions add the LclIntf unit instead.
Of course you can write platform specific code that is enclosed by a IFDEF Windows