IIRC, there's a code in either LCL of FPCRes manager to write and well as extract icon files from .icns.
.icns could be found in a bundle (.app) directory.
.icns is a very simple storage file that just keeps all images together.
Images 64x64 has a simple bitmap-like format. Images larger than 64x64 are just PNGs.
If you need to extract an application of an arbitrary bundle, you should first inspect the bundles info.plist file. It actually points to the .icns file name (if multiple .icns) file is present.
Also, NSImage (cocoa) and CGImage (CoreGraphics, works in Carbon) should be to read the file and extract it as bitmap or convert it to any other desired format.