The easiest way to do this is at the COS level. The image XObject is a COS stream object. The Stream Dictionary holds entries that give the number of rows and the width of a row in pixels. Other entries describe the color model in use and the line and row progression.
For more information about image XObjects, see Section 8.9.5, “Image Dictionaries,” in the ISO 32000 Reference, page 206.
Use this information to form the header of an image in a standard form. The content of the bitmap can then be read usingCOSStreamOpenStm() and read with ASStmRead(). Formatting this information into a standard image format is the responsibility of your application.