I am trying to use Bitmap data type from .net in an extension I am trying to create. The closest thing to it that I can find in outsystems is Binary(byte array) . But if I use byte array my logic fails. 


Any pointers if I can actually use Bitmap/Image as an input/output type for a function I am trying to implement in this extension ?

Hi Tushar,

Did you try to pass the data as data type object?

You can use the ToObject() function in OutSytems to pass the data as object to your extension.

Regards,

Daniel

Daniël Kuhlmann wrote:

Hi Tushar,

Did you try to pass the data as data type object?

You can use the ToObject() function in OutSytems to pass the data as object to your extension.

Regards,

Daniel


I tried that Daniel. Didn't work for me.  Somewhere in the implementation I had to do a Binary(byte array) to Object kind of thing where my logic breaks. 

I strongly feel that since OS is built on top of .Net it should somehow allow use of these generic types in the extensions.


Anyways thanks for your help  Daniël !

Cheers

Hi Tushar,

So you tried and you didn't get it working wit data type Object. 

I would not rule out that your code could be made working.

Maybe if you share the extension and a sample OML using the extension action, the community can help make it work.

Regards,

Daniel

Hi Tushar,

An image is binary data, and so the Binary Data type should be adequate. If something fails, it's likely due to a bug somewhere, rather than a problem with Binary Data.

That said, like Daniel wrote, there's the Object type to encapsulate more complex C#-type objects. You can't do anything with them, but you can pass them in and out of Extension Actions, and inside the Extension you can cast them back to whatever they're supposed to be.

Appreciate your responses Kilian &  Daniël . I am trying to implement a image steganography extension. You might already be aware , but just to explain, trying to hide text inside a image and then extract it back. The issue is, the library I am using expected Bitmap as an input type and Gives an output in the same format. What I want to do is, get an user to upload an image and sent it through to the extension as bitmap instead of binary.  The text will be mashed in the image and sent back in bitmap format. And so on. 


I tried modifying the complete logic to use binary(byte array) instead. Problem is, once I mash up the string with the binary for the image, it cannot be reconstructed into an image/bitmap. It errors out in .Net. 


Will clean up the extension a bit and attach then for better advice, Thanks 


Cheers

Hi Tushar,

If the user uploads the original image, it will, by definition, be of type Binary Data, representing the content of the uploaded file, byte for byte. If all you want to do is add something to that image and return it, you'll need to convert the image to a Bitmap (using Image.FromStream, using MemoryStream(byte[]) with the Binary Data as input), then when you're done manipulating it, converting it back to whatever format you want using Bitmap.Save() to a Stream, and passing the resulting byte[] stream back as Binary Data.