Have a look at the "fpimage" package in the packages (installed default with FPC). Directory fpc/packages/fcl-image/src in the source

It has abstract image types, readers etc.