I have a question about using Javonet. In the .NET code I have a method that returns a System.DrawingImage and I have to obtain it on my Java side of code. So when I issue a "get" of the attribute by Javonet API, it returns an NObject. Here is the example:
.NET code:
...
namespace ImageTest
{
public class FileReader
{
public byte[] GetByteArray(string filename)
{
return System.IO.File.ReadAllBytes(filename);
}
public System.Drawing.Image GetImage(string filename)
{
byte[] b = GetByteArray(filename);
using (var ms = new System.IO.MemoryStream(b, false))
{
return Image.FromStream(ms);
}
}
}
}
Java code
...
public Image getImage(String fileName) {
NObject res = null;
try {
res = item.get(propName); // Casting NObject to Image is not allowed!
} catch (JavonetException jex) {
jex.printStackTrace();
}
return res; // Wrong: an Image object must be returned!
}
I have to cast 'res' to Image or ImageIcon or something similar in Java. Any suggestion? Have I to get it as byte array or something else or there is another mechanism on Javonet?