Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to convert JPEG binary data into 8-bit/256-color Bitmap binary data in ABAP

Former Member
0 Kudos

Hi ABAP Gurus --

The overview of the technical requirement:

  1. 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)
  2. Load the BMP in BDS programmatically  (modified se78 code is used here)
  3. 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.
  4. Convert the smartform into PDF and send it as an email attachment.

Note:

  • 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

Problem:

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).

Question:

How to convert a JPEG binary data/rawstring (or BMP 24-bit) into an 8-bit BMP data in ABAP?

1 ACCEPTED SOLUTION

Former Member
0 Kudos

I don't see anything in SAP that does this.  However, that's not to say that it cannot be done.  For instance, I have a program that reads in a binary file, like .xlsx or .mp3, and calls a web service, via proxy, with a method to convert xstring (created from my binary table upload) to a PDF, returning an xstring that I put back into a binary table (type table of tbl1024). 

Perhaps that's an alternative that you could explore, if you have software accessible somewhere on the servers available by connection that will do the conversion.  I think that there should be software which you can get for server that will do the conversion for you, and give you the converted xstring or binary table back.

7 REPLIES 7

Former Member
0 Kudos

I don't see anything in SAP that does this.  However, that's not to say that it cannot be done.  For instance, I have a program that reads in a binary file, like .xlsx or .mp3, and calls a web service, via proxy, with a method to convert xstring (created from my binary table upload) to a PDF, returning an xstring that I put back into a binary table (type table of tbl1024). 

Perhaps that's an alternative that you could explore, if you have software accessible somewhere on the servers available by connection that will do the conversion.  I think that there should be software which you can get for server that will do the conversion for you, and give you the converted xstring or binary table back.

0 Kudos

Thanks for the response, Break Point.  However, we are limited at what we can install in the system so we had to find ways around it within SAP. 

Former Member
0 Kudos

Solved.  Thanks to Thomas Jung's article:

http://scn.sap.com/people/thomas.jung/blog/2007/09/05/abap-bitmap-image-processing-class

I reused the transform_grayscale method after converting the JPEG to BMP 24-bit via IGS class.  This method will result in an 8-bit BMP.  The BMP is then loaded to se78 programmatically and the resulting image resolution is just what we were looking for.  It appears just as good on the resulting PDF (from Smartforms).

0 Kudos

Hello, could you please give me the source code part where you convert the jpeg to bmp?

I need to convert a xml file intro bmp to load it to se78 programmatically.

I managed to convert the xml to binary using  SCMS_XSTRING_TO_BINARY FM.

Thnx.

0 Kudos

Hello Dennis Carpio,

first of all thank you very much for this thread!

Do you mean with "reused" transform_grayscale that you modified this method to get a 8-bit Bitmap in color or your requirement is not to use colored graphics?

Best regards

Manuel Nonnenmacher

Former Member
0 Kudos

Hi everybody, I know this post is very old but I need solve this issue too. Someone could publish or send me the source or the algorithm for reuse the grayscale method ?

Thank a lot!!

Jose

0 Kudos

The code is present in Thomas Jung's blog. See the links at the bottom of blog.

You can install the code using SAPlink Project.