/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { // Declare variables IGH_Goo Z = null; IGH_Goo Y = null; // Access the input parameters if (!DA.GetData(0, ref Z)) { return; } if (!DA.GetData(1, ref Y)) { return; } wObject X = new wObject(); mFilters F = new mFilters(); mSequence S = new mSequence(); Bitmap A = new Bitmap(10, 10); if (Z != null) { Z.CastTo(out A); } if (Y != null) { Y.CastTo(out X); } if (X.SubType == "Filters") { S.AddFilter((mFilters)X.Element); } else if (X.SubType == "Filter") { S.AddFilter((mFilter)X.Element); } F = S; Bitmap B = new mApplySequence(A, F).ModifiedBitmap; DA.SetData(0, B); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { // Declare variables IGH_Goo Z = null; int M = 0; int AX = 1; int AY = 1; int CW = 800; int CH = 600; Rectangle3d Rc = new Rectangle3d(Plane.WorldXY, 800, 600); Color C = Color.Transparent; // Access the input parameters if (!DA.GetData(0, ref Z)) { return; } Bitmap A = new Bitmap(10, 10); if (Z != null) { Z.CastTo(out A); } mFilters Filter = new mFilters(); switch (ModeIndex) { case 0: //Rectangle if (!DA.GetData(1, ref C)) { return; } if (!DA.GetData(2, ref Rc)) { return; } Filter = new mCropRectangle((int)Rc.X.T0, (int)Rc.Y.T0, (int)Rc.Width, (int)Rc.Height, C); break; case 1: //Region if (!DA.GetData(1, ref C)) { return; } if (!DA.GetData(2, ref AX)) { return; } if (!DA.GetData(3, ref AY)) { return; } if (!DA.GetData(4, ref CW)) { return; } if (!DA.GetData(5, ref CH)) { return; } Filter = new mCropCanvas(AX, AY, CW, CH, A.Width, A.Height, C); break; case 2: //Shrink if (!DA.GetData(1, ref C)) { return; } Filter = new mShrinkToColor(C); break; case 3: //Resize if (!DA.GetData(1, ref M)) { return; } if (!DA.GetData(2, ref CW)) { return; } if (!DA.GetData(3, ref CH)) { return; } switch (M) { case 0: Filter = new mResizeBicubic(CW, CH); break; case 1: Filter = new mResizeBilinear(CW, CH); break; case 2: Filter = new mResizeNearistNeighbor(CW, CH); break; } break; } Bitmap B = new mApplySequence(A, Filter).ModifiedBitmap; wObject W = new wObject(Filter, "Macaw", Filter.Type); DA.SetData(0, B); DA.SetData(1, W); }