Search code examples
c#javaimageikvmimage-conversion

How to convert from java.awt.image.BufferedImage/PDXObjectImage to System.Drawing.Image?


I am using IKVM in a C# application so that I can use PDFBox to extract information from PDFs. Using PDFBox, I am able to extract images into PDXObjectImage. I need to get this PDXObjectImage into a System.Drawing.Image or System.Drawing.Bitmap. PDXObjectImage is easily converted to a java.awt.image.BufferedImage using pdxImage.getRGBImage(), but I don't know where to go from there.

I looked into it and saw that I could convert byte-by-byte, but I am too new to image programming to know how to do that. Any code snippets would be incredibly appreciated.

Thank you for your time!


Solution

  • If you are in C# code then you can use the method getBitmap() on java.awt.image.BufferedImage. This return a System.Drawing.Bitmap.

    You can not call this method if you are on the Java side because it is hide. If you are in Java Code then only .NET refection should work.