public static MBRunTimePrimitive[] BuildRunTimePrimitives( MBTask task, int width, int height, bool bConstrainProportions ) { //Note, rtpPrimitives only has to contain primitives that we are //changing values for MBRunTimePrimitive[] rtpPrimitives = null; //The task must have at least one runtime paramter if( task != null && task.IsRunTimeSettable ) { //Find the Image sizer primitive in the list of primitives MBPrimitive primitive = null; IEnumerator i = task.mPrimitives.GetEnumerator(); while( i.MoveNext() ) { MBPrimitive obj = (MBPrimitive) i.Current; if( obj.mID == "{82637480-F111-11D2-8181-00104B2A9F09}" ) //id of the imagesizer primitive { primitive = obj; break; } } if( primitive != null ) { rtpPrimitives = new MBRunTimePrimitive[1]; rtpPrimitives[0] = new MBRunTimePrimitive(); rtpPrimitives[0].mID = primitive.mID; //Iterate thru all the parameters, setting the ones we are interested in //In this case, we have to send back the complete list of parameters i = primitive.mParameters.GetEnumerator(); ArrayList arr = new ArrayList(); while( i.MoveNext() ) { MBParameter parameter = (MBParameter) i.Current; MBRunTimeParameter rtpParameter = new MBRunTimeParameter(); rtpParameter.mID = parameter.mID; //get a copy of th default parameters rtpParameter.mElements = new MBParameterElement[ parameter.mElements.Length ]; parameter.mElements.CopyTo( rtpParameter.mElements, 0 ); //The imagesizer has compound parameters, we need the one that contains the //width, height and constrain proportions elements if( rtpParameter.mID == "{04D3C0C0-5597-11D3-81E2-00104B2A9F09}" ) { //Iterate thru the parameters, only changing width, height and constrain proportions IEnumerator j = rtpParameter.mElements.GetEnumerator(); while( j.MoveNext() ) { MBParameterElement element = (MBParameterElement) j.Current; if( element.mName == "Output Width" ) element.mValue = (double) width; else if( element.mName == "Output Height" ) element.mValue = (double) height; else if( element.mName == "Constrain Proportions" ) element.mValue =bConstrainProportions; //we don't need to send format or name element.mFormat = null; element.mName = null; } } arr.Add( rtpParameter ); } rtpPrimitives[0].mParameters = new MBRunTimeParameter[ arr.Count]; arr.CopyTo( rtpPrimitives[0].mParameters, 0 ); } } return rtpPrimitives; }