How to convert JPEG binary data into 8-bit/256-color Bitmap binary data in ABAP
Hi ABAP Gurus --
The overview of the technical requirement:
- Convert JPEG rawstring/binary data received from mobile devices (e.g. iPad photo) stored in a SAP z-table into BMP (IGS is used for conversion)
- Load the BMP in BDS programmatically (modified se78 code is used here)
- Call a Smartforms which will take in an internal table containing the BDS details of the images. The smartform will display single image per page.
- Convert the smartform into PDF and send it as an email attachment.
- Everything is done programmatically. No external/manual image conversion possible.
- All logic is wrapped into an RFC function module which is used by the mobile device via SUP.
- Client system is ECC 6
- Adobe Document Services (ADS) is not available
Bad image resolution from the 256-color bitmap on the forms.
Findings from prior research work:
- SAP has a limitation of 256 colors for BDS and Smartforms. This results in some loss in image quality.
- The IGS converter has a fixed color bit depth of 24bit for BMP/TIFF data
- Image resolution is not a problem if the image is converted to 8-bit BMP via image conversion program (e.g. Paint) before loading it to BDS (se78). Image on the form looks fine if this is done.
- There is minimal degradation to image quality if the image loaded to BDS has a bit depth of 8 (256 colors).
How to convert a JPEG binary data/rawstring (or BMP 24-bit) into an 8-bit BMP data in ABAP?