GdPicture imaging ActiveX - SaveAsByteArray()

Posted by Derek Lord on 20-Dec-2016 11:22

Hello all,

I have exhausted my combination of MEMPTR/RAW combination attempts of code to try and get the method below to work.
Does anyone have any suggestions on what is needed to to get the 'Integer-Data' into a memptr?
I am trying to avoid writing an image to disk and using COPY-LOB back into a memptr.

ABL Syntax from COM Object Viewer

[ Integer-Var = ] <com-handle>: SaveAsByteArray (
   Integer-EncoderParameter ).

VB Example from GdPicture

Dim ImageID As Integer = oGdPictureImaging.CreateGdPictureImageFromFile("test.tif")
Dim ImageBytes As Byte() = Nothing
Dim Length As Integer
oGdPictureImaging.SaveAsByteArray(ImageID, ImageBytes, Length, DocumentFormat.DocumentFormatJPEG, 90)

Many thanks,

OpenEdge Version 11.6 (32-bit)

All Replies

Posted by Laura Stern on 20-Dec-2016 11:33

Did you try just passing an integer?  I think that should work.

Posted by Laura Stern on 20-Dec-2016 11:34

Of course I meant an integer variable.

Posted by Derek Lord on 20-Dec-2016 15:53

I get 'The parameter is incorrect' with an integer.

Tried it like this:

     CO-GdPictureImaging:SaveAsByteArray(INPUT IN-sigImageId,

                                         INPUT-OUTPUT IN-data AS UNSIGNED-BYTE BY-POINTER,

                                         INPUT-OUTPUT IN-length BY-POINTER,




     CO-GdPictureImaging:SaveAsByteArray(INPUT IN-sigImageId,

                                         INPUT-OUTPUT IN-data,

                                         INPUT-OUTPUT IN-length,



Posted by Laura Stern on 21-Dec-2016 07:51

Are you getting "The parameter is incorrect' at runtime?  Is that the exact error message?

The VB code above doesn't even look like valid syntax.  I thought it should be:

Dim ImageBytes() As Byte.  (i.e., parenthesis on the name, not the type - opposite of C# for example)

But in any case, I assume this is supposed to be a byte array.  So did you try an integer array?  

Posted by jquerijero on 22-Dec-2016 12:13

Can you try

DEFINE VAR ImageBytes AS "System.Byte[]" no-undo.

BTW, GDPicture has a .NET version available.

Posted by Derek Lord on 02-Jan-2017 16:21

Passing the variable defined as System.Byte[] gives the following syntax check error:

Cannot pass user defined objects to COM. (12899)

The compiler encountered an attempt to pass a class instance to a COM method. User-defined classes can't used as parameters or attributes of COM objects." " "

As far as I know I cannot embed a .NET control into an ADM smartobect, which is in turn dropped into an ADM smartframe.

Posted by jquerijero on 03-Jan-2017 17:40

How about

DEFINE VAR ImagePtr AS "System.IntPtr" no-undo.

DEFINE VAR ImageBytes AS "System.Byte[]" no-undo

ImageBytes = new "System.Byte[]"(). // check the syntax, not so sure

CO-GdPictureImaging:SaveAsByteArray(ImageId, INPUT-OUTPUT ImagePtr , INPUT-OUTPUT length,  {&DocumentFormatPNG}, 6).

System.Runtime.InteropServices.Marshal:Copy(ImagePtr, ImageBytes , 0, length ).


If you get lucky, ImageBytes should have your image.

This thread is closed