コード例 #1
0
 public override object GetPinValue(Pin pin, PinRequest request)
 {
     if (pin == outputPin)
     {
         Size       sz  = (request is BitmapPinRequest) ? (request as BitmapPinRequest).DesiredSize : new Size(256, 256);
         Bitmap     bmp = new Bitmap(sz.Width, sz.Height, PixelFormat.Format32bppArgb);
         BitmapData bd  = bmp.LockBits(new Rectangle(0, 0, sz.Width, sz.Height), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
         CBlend.Noise(bd.Scan0, (UInt32)(bd.Stride * bd.Height), oMask, aMask);
         bmp.UnlockBits(bd);
         return(bmp);
     }
     return(null);
 }
コード例 #2
0
 public override object GetPinValue(Pin pin, PinRequest request)
 {
     if (pin == outputPin)
     {
         Size       sz  = (request is BitmapPinRequest) ? ((BitmapPinRequest)request).DesiredSize : size;
         Color      c   = colorPin.Read <Color>();
         Bitmap     bmp = new Bitmap(sz.Width, sz.Height, PixelFormat.Format32bppArgb);
         Rectangle  r   = bmp.GetEntireRect();
         BitmapData bd  = bmp.LockBits(r, ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
         CBlend.Clear(bd.Scan0, (UInt32)(bd.Stride * bd.Height), (uint)c.ToArgb(), 0xFFFFFFFF);
         bmp.UnlockBits(bd);
         return(bmp);
     }
     return(null);
 }
コード例 #3
0
ファイル: BitmapChannelRemap.cs プロジェクト: akx/kohina
 public override object GetPinValue(Pin pin, PinRequest request)
 {
     if (pin == outputPin)
     {
         Bitmap bmp = inputPin.Read <Bitmap>(request);
         if (bmp == null)
         {
             return(null);
         }
         bmp = bmp.ResizeIfNeeded(
             (request is BitmapPinRequest) ? (request as BitmapPinRequest).DesiredSize : bmp.Size
             );
         Rectangle  r     = new Rectangle(0, 0, bmp.Width, bmp.Height);
         BitmapData bData = bmp.LockBits(r, ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
         CBlend.CRemap(bData.Scan0, (UInt32)(bData.Stride * bData.Height), mask);
         bmp.UnlockBits(bData);
         return(bmp);
     }
     return(null);
 }
コード例 #4
0
ファイル: BitmapXBlender.cs プロジェクト: akx/kohina
        public override object GetPinValue(Pin pin, PinRequest request)
        {
            if (pin == outputPin)
            {
                Bitmap bmp1 = input1Pin.Read <Bitmap>(request);
                Bitmap bmp2 = input2Pin.Read <Bitmap>(request);
                if (bmp1 == null && bmp2 == null)
                {
                    return(null);
                }
                if (bmp2 == null)
                {
                    return(bmp1);
                }
                if (bmp1 == null)
                {
                    return(bmp2);
                }
                Size sz = (request is BitmapPinRequest) ? (request as BitmapPinRequest).DesiredSize : new Size(
                    Math.Min(bmp1.Size.Width, bmp2.Size.Width),
                    Math.Min(bmp1.Size.Height, bmp2.Size.Height)
                    );
                bmp1 = bmp1.ResizeIfNeeded(sz);
                bmp2 = bmp2.ResizeIfNeeded(sz);
                Rectangle  r      = new Rectangle(0, 0, sz.Width, sz.Height);
                double     mix    = mixPin.Read <double>(request);
                BitmapData b1Data = bmp1.LockBits(r, ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
                BitmapData b2Data = bmp2.LockBits(r, ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);

                CBlend.Blend(blendMode, b1Data.Scan0, b2Data.Scan0, (UInt32)(b1Data.Stride * b1Data.Height), (float)mix, useSrcAlpha);
                bmp1.UnlockBits(b1Data);
                bmp2.UnlockBits(b2Data);
                bmp2.Dispose();
                return(bmp1);
            }
            return(null);
        }