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-ImageID,
INPUT-OUTPUT Integer-Data AS UNSIGNED-BYTE BY-POINTER,
INPUT-OUTPUT Integer-Length BY-POINTER,
Integer-ImageFormat,
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,
Derek
OpenEdge Version 11.6 (32-bit)
Did you try just passing an integer? I think that should work.
Of course I meant an integer variable.
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,
{&DocumentFormatPNG},
6).
and
CO-GdPictureImaging:SaveAsByteArray(INPUT IN-sigImageId,
INPUT-OUTPUT IN-data,
INPUT-OUTPUT IN-length,
{&DocumentFormatPNG},
6).
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?
Can you try
DEFINE VAR ImageBytes AS "System.Byte[]" no-undo.
BTW, GDPicture has a .NET version available.
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.
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 ).
System.Runtime.InteropServices.Marshal:FreeHGlobal(ImagePtr);
If you get lucky, ImageBytes should have your image.