We’re creating a web application that will display contour areas as bitmaps in a browser interface.
We already have an extensive Delphi library that can generate contours, and can draw them onto a TCanvas. We’d like to be able to re-use that code as much as possible.
So we’ve created a COM object in Delphi, and use that to generate contours. I’ve added a reference to that COM object in my ASP.Net project, so I can access it from .Net code. So far, this seems to work out nicely.
The problem I’m running into now, is getting the generated TBitmap to the ASP.Net side of things, as fast as possible.
There are some scenarios I can think of, but I’m running into problems on each of them:
Saving the bitmap to stream (as PNG), and return an
IStreaminterface. Problem is that the COM object wizard doesn’t seem to acceptIStreamas return value for a function. Also, I don’t know if .Net will know what to do with it, but I hope the Interop wrapper will take care of that.Saving the bitmap to stream (as PNG), and return a byte array. What return type should I use then? I’m guessing
SAFEARRAY(byte)(the wizard accepts that, at least), but a) how do I create a SAFEARRAY on the Delphi side, and b) how do I read that in .Net?Somehow converting the
TBitmapto anIPictureinterface, and returning that. IPicture, at least, seems to be supported by the COM object wizard. Here I don’t really know how to convert the TBitmap to an IPicture (except saving it to stream, and creating an IPicture from that stream, which seems a bit silly since the .Net code will have to stream it out to the browser anyway). Again, I have no idea how .Net will handle theIPicture, though I hope it will map it to a regularImageobject, which can then be written out via theResponseobject.
So my question is: what would be the best way to go forward, in terms of performance, and how to solve the problems indicated?