use of System.Drawing.Imaging.EncoderParameters in Progress

Posted by DenDuze on 14-Dec-2016 03:50

I want to use the System.Drawing.Imaging.EncoderParameters into some Progress code but whatever I try I always get an error (what error depends on how I try it)
with the following code

define variable oEncoderParameters as System.Drawing.Imaging.EncoderParameters no-undo.
define variable oEncoderParameter  as System.Drawing.Imaging.EncoderParameter  no-undo.
define variable v-PCcompress as integer no-undo.

assign oEncoderParameter = new System.Drawing.Imaging.EncoderParameter(System.Drawing.Imaging.Encoder:Quality, v-PCcompress)
             oEncoderParameters          = new System.Drawing.Imaging.EncoderParameters(0).
assign oEncoderParameters:param  = oEncoderParameter.

I get the error 'You cannot assign a scalar value into a .NET array object'
I also tried to use assign oEncoderParameters[1]:param  = oEncoderParameter. but that gives also an error.

The code I've taken this from is:

EncoderParameters encoder_params = new EncoderParameters(1);
encoder_params.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, compression);

I need the oEncoderParameters because that's a needed input parameter to some other .net method.

Someone that can give me a hint?
I already found the thread https://community.progress.com/community_groups/openedge_development/f/19/t/1087 but I think that that is no solution for this.

Regards

Posted by Mike Fechner on 14-Dec-2016 04:04

Accoring to the MSDN, the Param property is an array of EncoreParameter objects. Not a single reference.
 
So this compiles for me:
 
 
define variable oEncoderParameters as System.Drawing.Imaging.EncoderParameters no-undo.
define variable oEncoderParameter  as System.Drawing.Imaging.EncoderParameter  no-undo.
define variable v-PCcompress as integer no-undo.
 
 
DEFINE VARIABLE oArray AS System.Drawing.Imaging.EncoderParameter  EXTENT 1 .
 
assign oEncoderParameter = new System.Drawing.Imaging.EncoderParameter(System.Drawing.Imaging.Encoder:Quality, v-PCcompress)
             oEncoderParameters          = new System.Drawing.Imaging.EncoderParameters(0).
 
oArray[1] = oEncoderParameter .
 
assign oEncoderParameters:param  = oArray .
 

All Replies

Posted by Mike Fechner on 14-Dec-2016 04:04

Accoring to the MSDN, the Param property is an array of EncoreParameter objects. Not a single reference.
 
So this compiles for me:
 
 
define variable oEncoderParameters as System.Drawing.Imaging.EncoderParameters no-undo.
define variable oEncoderParameter  as System.Drawing.Imaging.EncoderParameter  no-undo.
define variable v-PCcompress as integer no-undo.
 
 
DEFINE VARIABLE oArray AS System.Drawing.Imaging.EncoderParameter  EXTENT 1 .
 
assign oEncoderParameter = new System.Drawing.Imaging.EncoderParameter(System.Drawing.Imaging.Encoder:Quality, v-PCcompress)
             oEncoderParameters          = new System.Drawing.Imaging.EncoderParameters(0).
 
oArray[1] = oEncoderParameter .
 
assign oEncoderParameters:param  = oArray .
 

Posted by DenDuze on 14-Dec-2016 04:10

Hi Mike,

Aha, that's the way to do something like this!

Thanks this will help me in multiple situations because I had similar problems in the past (but then I had some workaround what I do not have in this case).

Thanks a lot

regards

This thread is closed