Exemplo n.º 1
0
 public D3D11BlendState(D3D11GraphicsDevice graphicsDevice, bool isBlendEnabled,
                        Blend sourceBlend, Blend destinationBlend, BlendOperation blendOperation,
                        Blend sourceAlphaBlend, Blend destinationAlphaBlend, BlendOperation blendOperationAlpha)
 {
     _graphicsDevice   = graphicsDevice;
     _nativeBlendState = CreateBlendState(isBlendEnabled, sourceBlend, destinationBlend, blendOperation, sourceAlphaBlend, destinationAlphaBlend, blendOperationAlpha);
 }
Exemplo n.º 2
0
 public static extern BlendMode ComposeCustomBlendMode(
     BlendFactor srcColorFactor,
     BlendFactor dstColorFactor,
     BlendOperation colorOperation,
     BlendFactor srcAlphaFactor,
     BlendFactor dstAlphaFactor,
     BlendOperation alphaOperation);
Exemplo n.º 3
0
        public BlendState(bool blendEnabled,
            BlendOperation blendOperation, BlendOperation alphaBlendOperation,
            BlendOption sourceBlend, BlendOption destinationBlend,
            BlendOption sourceAlphhaBlend, BlendOption destinationAlphaBlend)
        {
            RenderTargetBlendDescription targetDesc = new RenderTargetBlendDescription()
            {
                AlphaBlendOperation = alphaBlendOperation,
                BlendOperation = blendOperation,
                DestinationAlphaBlend = destinationAlphaBlend,
                SourceAlphaBlend = sourceAlphhaBlend,
                SourceBlend = sourceBlend,
                DestinationBlend = destinationBlend,
                IsBlendEnabled = blendEnabled,
                RenderTargetWriteMask = ColorWriteMaskFlags.All
            };

            BlendStateDescription desc = new BlendStateDescription()
            {
                IndependentBlendEnable = false,
            };

            desc.RenderTarget[0] = targetDesc;

            NativeBlendState = new SharpDX.Direct3D11.BlendState(GraphicManager.Device, desc);

        }
Exemplo n.º 4
0
 public static extern InteropBool ResourceFactory_CreateBlendState(
     IntPtr failReason,
     DeviceHandle deviceHandle,
     InteropBool enableBlending,
     BlendOperation blendOperation,
     IntPtr outBlendStateHandle
     );
Exemplo n.º 5
0
        private void PlatformSpecificInitialization()
        {
            mColorOperation = ColorOperation.Texture;
            mBlendOperation = BlendOperation.Regular;


            // This is needed because SpriteChains may
            // use particle Sprites which can screw up
            mVertices[0].TextureCoordinate.X = 0;
            mVertices[0].TextureCoordinate.Y = 0;
            mVertices[0].Scale = new Vector2(-1, 1);

            mVertices[1].TextureCoordinate.X = 1;
            mVertices[1].TextureCoordinate.Y = 0;
            mVertices[1].Scale = new Vector2(1, 1);

            mVertices[2].TextureCoordinate.X = 1;
            mVertices[2].TextureCoordinate.Y = 1;
            mVertices[2].Scale = new Vector2(1, -1);

            mVertices[3].TextureCoordinate.X = 0;
            mVertices[3].TextureCoordinate.Y = 1;
            mVertices[3].Scale = new Vector2(-1, -1);

            CustomBehavior = null;
        }
Exemplo n.º 6
0
        internal static BlendEquationMode BlendOperationToOgl(BlendOperation bo)
        {
            switch (bo)
            {
            case BlendOperation.Add:
                return(BlendEquationMode.FuncAdd);

                break;

            case BlendOperation.Subtract:
                return(BlendEquationMode.FuncSubtract);

                break;

            case BlendOperation.ReverseSubtract:
                return(BlendEquationMode.FuncReverseSubtract);

                break;

            case BlendOperation.Minimum:
                return(BlendEquationMode.Min);

                break;

            case BlendOperation.Maximum:
                return(BlendEquationMode.Max);

                break;

            default:
                throw new ArgumentOutOfRangeException("bo");
            }
        }
Exemplo n.º 7
0
 public override void RGBAlphaBlendEquation(BlendEquation BlendEquationRGB, BlendEquation BlendEquationAlpha)
 {
     BlendOp      = blendOps[(int)BlendEquationRGB];
     BlendOpAlpha = blendOps[(int)BlendEquationAlpha];
     device.SetRenderState(RenderState.BlendOperation, (int)BlendOp);
     device.SetRenderState(RenderState.BlendOperationAlpha, (int)BlendOpAlpha);
 }
Exemplo n.º 8
0
        public RenderBreak(int itemNumber, Texture2D texture,
                           ColorOperation colorOperation,
                           BlendOperation blendOperation, TextureAddressMode textureAddressMode)
        {
#if DEBUG
            ObjectCausingBreak = null;
#endif
            LayerName = Renderer.CurrentLayerName;


            PrimitiveType = PrimitiveType.TriangleList;
            ItemNumber    = itemNumber;

            if (texture != null && texture.IsDisposed)
            {
                throw new ObjectDisposedException("Cannot create render break with disposed Texture2D");
            }

            mTexture               = texture;
            ColorOperation         = colorOperation;
            BlendOperation         = blendOperation;
            TextureAddressMode     = textureAddressMode;
            TextureFilter          = FlatRedBallServices.GraphicsOptions.TextureFilter;
            _originalTextureFilter = TextureFilter.Linear;

#if MONOGAME
            Red   = 0;
            Green = 0;
            Blue  = 0;
#endif
        }
Exemplo n.º 9
0
 /// <summary>
 /// <p>Create a blend-state object that encapsulates blend state for the output-merger stage.</p>
 /// </summary>
 /// <param name="device">The  <see cref="DirectXDevice"/>.</param>
 /// <param name="sourceBlend">The source blend.</param>
 /// <param name="destinationBlend">The destination blend.</param>
 /// <param name="blendOperation">The blend operation.</param>
 /// <param name="sourceAlphaBlend">The source alpha blend.</param>
 /// <param name="destinationAlphaBlend">The destination alpha blend.</param>
 /// <param name="alphaBlendOperation">The alpha blend operation.</param>
 /// <param name="renderTargetWriteMask">The render target write mask.</param>
 /// <param name="mask">The mask.</param>
 /// <returns>A new <see cref="BlendState" /> instance.</returns>
 /// <msdn-id>ff476500</msdn-id>
 ///   <unmanaged>HRESULT ID3D11Device::CreateBlendState([In] const D3D11_BLEND_DESC* pBlendStateDesc,[Out, Fast] ID3D11BlendState** ppBlendState)</unmanaged>
 ///   <unmanaged-short>ID3D11Device::CreateBlendState</unmanaged-short>
 /// <remarks><p>An application can create up to 4096 unique blend-state objects. For each object created, the runtime checks to see if a previous object  has the same state. If such a previous object exists, the runtime will return a reference to previous instance instead of creating a duplicate object.</p></remarks>
 public static BlendState New(DirectXDevice device, BlendOption sourceBlend, BlendOption destinationBlend,
                              BlendOperation blendOperation, BlendOption sourceAlphaBlend, BlendOption destinationAlphaBlend,
                              BlendOperation alphaBlendOperation, ColorWriteMaskFlags renderTargetWriteMask = ColorWriteMaskFlags.All,
                              int mask = -1)
 {
     return(New(device, sourceBlend, destinationBlend, blendOperation, sourceAlphaBlend, destinationAlphaBlend,
                alphaBlendOperation, renderTargetWriteMask, Color.White, mask));
 }
Exemplo n.º 10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BlendState"/> class.
 /// </summary>
 /// <param name="src">The SRC.</param>
 /// <param name="dst">The DST.</param>
 /// <param name="op">The op.</param>
 /// <param name="srcAlpha">The SRC alpha.</param>
 /// <param name="dstAlpha">The DST alpha.</param>
 /// <param name="opAlpha">The op alpha.</param>
 public BlendState(BlendOperand src, BlendOperand dst, BlendOperation op,
                   BlendOperand srcAlpha, BlendOperand dstAlpha, BlendOperation opAlpha)
     : this(src, dst, op)
 {
     srcAlphaBlend = srcAlpha;
     dstAlphaBlend = dstAlpha;
     opAlphaBlend  = opAlpha;
 }
Exemplo n.º 11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BlendState"/> class.
        /// </summary>
        /// <param name="src">The SRC.</param>
        /// <param name="dst">The DST.</param>
        /// <param name="op">The operation.</param>
        public BlendState(BlendOperand src, BlendOperand dst, BlendOperation op)
            : this()
        {
            blendEnable[0] = true;

            srcBlend = src;
            dstBlend = dst;
            opBlend  = op;
        }
Exemplo n.º 12
0
 /// <summary>
 /// <p>Create a blend-state object that encapsulates blend state for the output-merger stage.</p>
 /// </summary>
 /// <param name="device">The  <see cref="DirectXDevice"/>.</param>
 /// <param name="sourceBlend">The source blend.</param>
 /// <param name="destinationBlend">The destination blend.</param>
 /// <param name="blendOperation">The blend operation.</param>
 /// <param name="sourceAlphaBlend">The source alpha blend.</param>
 /// <param name="destinationAlphaBlend">The destination alpha blend.</param>
 /// <param name="alphaBlendOperation">The alpha blend operation.</param>
 /// <param name="renderTargetWriteMask">The render target write mask.</param>
 /// <param name="blendFactor">The blend factor.</param>
 /// <param name="mask">The mask.</param>
 /// <returns>A new <see cref="BlendState"/> instance.</returns>
 /// <msdn-id>ff476500</msdn-id>
 ///   <unmanaged>HRESULT ID3D11Device::CreateBlendState([In] const D3D11_BLEND_DESC* pBlendStateDesc,[Out, Fast] ID3D11BlendState** ppBlendState)</unmanaged>
 ///   <unmanaged-short>ID3D11Device::CreateBlendState</unmanaged-short>
 /// <remarks><p>An application can create up to 4096 unique blend-state objects. For each object created, the runtime checks to see if a previous object  has the same state. If such a previous object exists, the runtime will return a reference to previous instance instead of creating a duplicate object.</p></remarks>
 public static BlendState New(DirectXDevice device, BlendOption sourceBlend, BlendOption destinationBlend,
                              BlendOperation blendOperation, BlendOption sourceAlphaBlend, BlendOption destinationAlphaBlend,
                              BlendOperation alphaBlendOperation, ColorWriteMaskFlags renderTargetWriteMask, Color4 blendFactor,
                              int mask = -1)
 {
     return(New(device,
                new RenderTargetBlendDescription(true, sourceBlend, destinationBlend, blendOperation, sourceAlphaBlend,
                                                 destinationAlphaBlend, alphaBlendOperation, renderTargetWriteMask), blendFactor, mask));
 }
Exemplo n.º 13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BlendState"/> class.
 /// </summary>
 /// <param name="src">The SRC.</param>
 /// <param name="dst">The DST.</param>
 /// <param name="op">The op.</param>
 /// <param name="srcAlpha">The SRC alpha.</param>
 /// <param name="dstAlpha">The DST alpha.</param>
 /// <param name="opAlpha">The op alpha.</param>
 /// <param name="alphaToCov">if set to <c>true</c> alpha to coverage is used.</param>
 /// <param name="write">The write.</param>
 /// <param name="Sample">The Sample.</param>
 public BlendState(BlendOperand src, BlendOperand dst, BlendOperation op,
                   BlendOperand srcAlpha, BlendOperand dstAlpha, BlendOperation opAlpha,
                   bool alphaToCov, WriteMask write, byte sample)
     : this(src, dst, op, srcAlpha, dstAlpha, opAlpha)
 {
     alphaToCoverage = alphaToCov;
     writeMasks[0]   = write;
     sampleMask      = sample;
 }
Exemplo n.º 14
0
 public BlendState(BlendOperation blendOperation)
     : base(
         CreateBlendState(blendOperation),
         ResourceUsage.Immutable,
         BLEND_STATE_SIZE_BYTES
         )
 {
     BlendOperation = blendOperation;
 }
Exemplo n.º 15
0
        public RenderBreak(int itemNumber, Sprite sprite)
        {
#if DEBUG
            ObjectCausingBreak = sprite;
#endif
            LayerName              = Renderer.CurrentLayerName;
            ItemNumber             = itemNumber;
            PrimitiveType          = PrimitiveType.TriangleList;
            _originalTextureFilter = TextureFilter.Linear;

            if (sprite != null)
            {
                if (sprite.Texture != null && sprite.Texture.IsDisposed)
                {
                    throw new ObjectDisposedException("The Sprite with the name \"" + sprite.Name +
                                                      "\" references a disposed texture of the name " + sprite.Texture.Name +
                                                      ".  If you're using Screens you may have forgotten to remove a Sprite that was " +
                                                      "added in the Screen.");
                }

                mTexture = sprite.Texture;

                ColorOperation = sprite.ColorOperation;
                BlendOperation = sprite.BlendOperation;
                TextureFilter  = sprite.TextureFilter.HasValue ? sprite.TextureFilter.Value : FlatRedBallServices.GraphicsOptions.TextureFilter;

                if (sprite.Texture == null)
                {
                    // requirement for reach profile - this shouldn't impact anything
                    TextureAddressMode = Microsoft.Xna.Framework.Graphics.TextureAddressMode.Clamp;
                }
                else
                {
                    TextureAddressMode = sprite.TextureAddressMode;
                }


                Red   = sprite.Red;
                Green = sprite.Green;
                Blue  = sprite.Blue;
            }
            else
            {
                Red   = 0;
                Green = 0;
                Blue  = 0;

                mTexture = null;

                ColorOperation = ColorOperation.Texture;

                BlendOperation     = BlendOperation.Regular;
                TextureAddressMode = TextureAddressMode.Clamp;
                TextureFilter      = FlatRedBallServices.GraphicsOptions.TextureFilter;
            }
        }
Exemplo n.º 16
0
 public static ShapeData CreatePrism(Vector3 center, Vector3 size, BlendOperation blend)
 {
     return(new ShapeData
     {
         shapeType = (int)ShapeType.Prism,
         operation = (int)blend,
         position = center,
         size = size,
     });
 }
Exemplo n.º 17
0
 public static ShapeData CreateSphere(Vector3 center, float radius, BlendOperation blend)
 {
     return(new ShapeData
     {
         shapeType = (int)ShapeType.Sphere,
         operation = (int)blend,
         position = center,
         size = new Vector4(radius, 0f),
     });
 }
Exemplo n.º 18
0
		private static float DoBlendOperation(BlendOperation blendFunction, float left, float right)
		{
			switch (blendFunction)
			{
				case BlendOperation.Add:
					return left + right;
				default:
					throw new NotSupportedException();
			}
		}
Exemplo n.º 19
0
 public void Load(BinaryReader reader)
 {
     AlphaBlendOperation   = (BlendOperation)reader.ReadByte();
     BlendOperation        = (BlendOperation)reader.ReadByte();
     ColourWriteMask       = (ColorWriteMaskFlags)reader.ReadByte();
     DestinationAlphaBlend = (BlendOption)reader.ReadByte();
     DestinationBlend      = (BlendOption)reader.ReadByte();
     SourceAlphaBlend      = (BlendOption)reader.ReadByte();
     SourceBlend           = (BlendOption)reader.ReadByte();
 }
Exemplo n.º 20
0
        public BlendMode(bool enabled)
        {
            Enabled           = enabled;
            SourceFactor      = BlendFactor.SourceAlpha;
            DestinationFactor = BlendFactor.InvSourceAlpha;
            Operation         = BlendOperation.Add;

            SourceAlphaFactor      = BlendFactor.SourceAlpha;
            DestinationAlphaFactor = BlendFactor.InvSourceAlpha;
            AlphaOperation         = BlendOperation.Add;
        }
Exemplo n.º 21
0
        private static float DoBlendOperation(BlendOperation blendFunction, float left, float right)
        {
            switch (blendFunction)
            {
            case BlendOperation.Add:
                return(left + right);

            default:
                throw new NotSupportedException();
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="RenderTargetBlendDescription" /> struct.
 /// </summary>
 /// <param name="isBlendEnabled">The is blend enabled.</param>
 /// <param name="sourceBlend">The source blend.</param>
 /// <param name="destinationBlend">The destination blend.</param>
 /// <param name="blendOperation">The blend operation.</param>
 /// <param name="sourceAlphaBlend">The source alpha blend.</param>
 /// <param name="destinationAlphaBlend">The destination alpha blend.</param>
 /// <param name="alphaBlendOperation">The alpha blend operation.</param>
 /// <param name="renderTargetWriteMask">The render target write mask.</param>
 public RenderTargetBlendDescription(bool isBlendEnabled, BlendOption sourceBlend, BlendOption destinationBlend, BlendOperation blendOperation, BlendOption sourceAlphaBlend, BlendOption destinationAlphaBlend, BlendOperation alphaBlendOperation, ColorWriteMaskFlags renderTargetWriteMask)
 {
     IsBlendEnabled        = isBlendEnabled;
     SourceBlend           = sourceBlend;
     DestinationBlend      = destinationBlend;
     BlendOperation        = blendOperation;
     SourceAlphaBlend      = sourceAlphaBlend;
     DestinationAlphaBlend = destinationAlphaBlend;
     AlphaBlendOperation   = alphaBlendOperation;
     RenderTargetWriteMask = renderTargetWriteMask;
 }
Exemplo n.º 23
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RenderTargetBlendDescription" /> struct.
 /// </summary>
 /// <param name="isBlendEnabled">The is blend enabled.</param>
 /// <param name="sourceBlend">The source blend.</param>
 /// <param name="destinationBlend">The destination blend.</param>
 /// <param name="blendOperation">The blend operation.</param>
 /// <param name="sourceAlphaBlend">The source alpha blend.</param>
 /// <param name="destinationAlphaBlend">The destination alpha blend.</param>
 /// <param name="alphaBlendOperation">The alpha blend operation.</param>
 /// <param name="renderTargetWriteMask">The render target write mask.</param>
 public RenderTargetBlendDescription(bool isBlendEnabled, BlendOption sourceBlend, BlendOption destinationBlend, BlendOperation blendOperation, BlendOption sourceAlphaBlend, BlendOption destinationAlphaBlend, BlendOperation alphaBlendOperation, ColorWriteMaskFlags renderTargetWriteMask)
 {
     IsBlendEnabled = isBlendEnabled;
     SourceBlend = sourceBlend;
     DestinationBlend = destinationBlend;
     BlendOperation = blendOperation;
     SourceAlphaBlend = sourceAlphaBlend;
     DestinationAlphaBlend = destinationAlphaBlend;
     AlphaBlendOperation = alphaBlendOperation;
     RenderTargetWriteMask = renderTargetWriteMask;
 }
Exemplo n.º 24
0
        /// <summary>
        /// Set current blending state
        /// </summary>
        /// <param name="operation">Blend Operation</param>
        /// <param name="source">Source Option</param>
        /// <param name="destination">Destination Option</param>
        public void SetBlend(BlendOperation operation, BlendOption source, BlendOption destination)
        {
            Utilities.Dispose(ref _blendState);
            BlendStateDescription description = BlendStateDescription.Default();

            description.RenderTarget[0].BlendOperation   = operation;
            description.RenderTarget[0].SourceBlend      = source;
            description.RenderTarget[0].DestinationBlend = destination;
            description.RenderTarget[0].IsBlendEnabled   = true;
            _blendState = new BlendState(Device, description);
        }
Exemplo n.º 25
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BlendDescription"/> struct.
 /// </summary>
 /// <param name="sourceBlend">Specifies the first RGB data source and includes an optional preblend operation.</param>
 /// <param name="destinationBlend">Specifies the second RGB data source and includes an optional preblend operation.</param>
 /// <param name="blendOperation">Specifies how to combine the RGB data sources.</param>
 /// <param name="sourceBlendAlpha">Specifies the first alpha data source and includes an optional preblend operation. Blend options that end in Color are not allowed.</param>
 /// <param name="destinationBlendAlpha">Specifies the second alpha data source and includes an optional preblend operation. Blend options that end in Color are not allowed.</param>
 /// <param name="blendOperationAlpha">Specifies how to combine the alpha data sources.</param>
 public BlendDescription(
     Blend sourceBlend, Blend destinationBlend, BlendOperation blendOperation,
     Blend sourceBlendAlpha, Blend destinationBlendAlpha, BlendOperation blendOperationAlpha)
 {
     SourceBlend           = sourceBlend;
     DestinationBlend      = destinationBlend;
     BlendOperation        = blendOperation;
     SourceBlendAlpha      = sourceBlendAlpha;
     DestinationBlendAlpha = destinationBlendAlpha;
     BlendOperationAlpha   = blendOperationAlpha;
     BlendFactor           = new Color4(1.0f, 1.0f, 1.0f, 1.0f);
 }
Exemplo n.º 26
0
        /*
         *              destImage - image that will be used as background
         *              destX, destY - define position on destination image where to start applying blend operation
         *              destWidth, destHeight - width and height of the area to apply blending
         *              srcImage - image to use as foreground (source of blending)
         *              srcX, srcY - starting position of the source image
         */
        public static void BlendImages(Image destImage, int destX, int destY, int destWidth, int destHeight,
                                       Image srcImage, int srcX, int srcY, BlendOperation BlendOp)
        {
            if (destImage == null)
            {
                throw new Exception("Destination image must be provided");
            }

            if (destImage.Width < destX + destWidth || destImage.Height < destY + destHeight)
            {
                throw new Exception("Destination image is smaller than requested dimentions");
            }

            if (srcImage == null)
            {
                throw new Exception("Source image must be provided");
            }

            if (srcImage.Width < srcX + destWidth || srcImage.Height < srcY + destHeight)
            {
                throw new Exception("Source image is smaller than requested dimentions");
            }

            Bitmap   tempBmp = null;
            Graphics gr      = Graphics.FromImage(destImage);

            gr.CompositingMode = CompositingMode.SourceCopy;

            switch (BlendOp)
            {
            case BlendOperation.Blend_Overlay:
                tempBmp = PerChannelProcess(ref destImage, destX, destY, destWidth, destHeight,
                                            ref srcImage, srcX, srcY, new PerChannelProcessDelegate(BlendOverlay));
                break;

            case BlendOperation.Blend_Difference:
                tempBmp = PerChannelProcess(ref destImage, destX, destY, destWidth, destHeight,
                                            ref srcImage, srcX, srcY, new PerChannelProcessDelegate(BlendDifference));
                break;
            }



            if (tempBmp != null)
            {
                gr.DrawImage(tempBmp, 0, 0, tempBmp.Width, tempBmp.Height);
                tempBmp.Dispose();
                tempBmp = null;
            }

            gr.Dispose();
            gr = null;
        }
Exemplo n.º 27
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BlendDescription"/> struct.
 /// </summary>
 /// <param name="sourceBlend">Specifies the first RGB data source and includes an optional preblend operation.</param>
 /// <param name="destinationBlend">Specifies the second RGB data source and includes an optional preblend operation.</param>
 /// <param name="blendOperation">Specifies how to combine the RGB data sources.</param>
 /// <param name="sourceBlendAlpha">Specifies the first alpha data source and includes an optional preblend operation. Blend options that end in Color are not allowed.</param>
 /// <param name="destinationBlendAlpha">Specifies the second alpha data source and includes an optional preblend operation. Blend options that end in Color are not allowed.</param>
 /// <param name="blendOperationAlpha">Specifies how to combine the alpha data sources.</param>
 public BlendDescription(
     Blend sourceBlend, Blend destinationBlend, BlendOperation blendOperation,
     Blend sourceBlendAlpha, Blend destinationBlendAlpha, BlendOperation blendOperationAlpha)
 {
     SourceBlend           = sourceBlend;
     DestinationBlend      = destinationBlend;
     BlendOperation        = blendOperation;
     SourceBlendAlpha      = sourceBlendAlpha;
     DestinationBlendAlpha = destinationBlendAlpha;
     BlendOperationAlpha   = blendOperationAlpha;
     BlendFactor           = default;
 }
Exemplo n.º 28
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BlendDescription"/> struct.
 /// </summary>
 /// <param name="sourceBlend">Specifies the first RGB data source and includes an optional preblend operation.</param>
 /// <param name="destinationBlend">Specifies the second RGB data source and includes an optional preblend operation.</param>
 /// <param name="blendOperation">Specifies how to combine the RGB data sources.</param>
 /// <param name="sourceBlendAlpha">Specifies the first alpha data source and includes an optional preblend operation. Blend options that end in Color are not allowed.</param>
 /// <param name="destinationBlendAlpha">Specifies the second alpha data source and includes an optional preblend operation. Blend options that end in Color are not allowed.</param>
 /// <param name="blendOperationAlpha">Specifies how to combine the alpha data sources.</param>
 /// <param name="blendFactor">Parameters to the blend operations. The blend must use <see cref="Blend.BlendFactor"/> for this to be used.</param>
 public BlendDescription(
     Blend sourceBlend, Blend destinationBlend, BlendOperation blendOperation,
     Blend sourceBlendAlpha, Blend destinationBlendAlpha, BlendOperation blendOperationAlpha,
     RawColor4 blendFactor)
 {
     SourceBlend           = sourceBlend;
     DestinationBlend      = destinationBlend;
     BlendOperation        = blendOperation;
     SourceBlendAlpha      = sourceBlendAlpha;
     DestinationBlendAlpha = destinationBlendAlpha;
     BlendOperationAlpha   = blendOperationAlpha;
     BlendFactor           = blendFactor;
 }
Exemplo n.º 29
0
        private static unsafe BlendStateResourceHandle CreateBlendState(BlendOperation blendOperation)
        {
            BlendStateResourceHandle outResourceHandle;

            InteropUtils.CallNative(NativeMethods.ResourceFactory_CreateBlendState,
                                    RenderingModule.Device,
                                    (InteropBool)(blendOperation != BlendOperation.None),
                                    blendOperation,
                                    (IntPtr)(&outResourceHandle)
                                    ).ThrowOnFailure();

            return(outResourceHandle);
        }
Exemplo n.º 30
0
 public void SetDefaults()
 {
     AlphaToCoverageEnable = false;
     BlendEnable           = false;
     SrcBlend       = Blend.One;
     DestBlend      = Blend.Zero;
     BlendOp        = BlendOperation.Add;
     SrcBlendAlpha  = Blend.One;
     DestBlendAlpha = Blend.Zero;
     BlendOpAlpha   = BlendOperation.Add;
     WriteMask      = new ColorWrite(true, true, true, true);
     BlendFactor    = new Color4(1, 1, 1, 1);
 }
Exemplo n.º 31
0
        private void Update(EvaluationContext context)
        {
            Output.Value = new RenderTargetBlendDescription(BlendEnabled.GetValue(context),
                                                            SourceBlend.GetValue(context),
                                                            DestinationBlend.GetValue(context),
                                                            BlendOperation.GetValue(context),
                                                            SourceAlphaBlend.GetValue(context),
                                                            DestinationAlphaBlend.GetValue(context),
                                                            AlphaBlendOperation.GetValue(context),
                                                            ColorWriteMaskFlags.All);
            // todo: add color write mask input, enum is byte so input edit needs adjustment
//                                                            RenderTargetWriteMask.GetValue(context));
        }
 public RenderTargetBlendDesc_NativeInterop(ref RenderTargetBlendDesc desc)
 {
     blendingEnabled        = (byte)(desc.blendingEnabled ? 1 : 0);
     logicOperationEnabled  = (byte)(desc.logicOperationEnabled ? 1 : 0);
     alphaBlendingSeparated = (byte)(desc.alphaBlendingSeparated ? 1 : 0);
     sourceFactor           = desc.sourceFactor;
     destinationFactor      = desc.destinationFactor;
     operation              = desc.operation;
     sourceAlphaFactor      = desc.sourceAlphaFactor;
     destinationAlphaFactor = desc.destinationAlphaFactor;
     alphaOperation         = desc.alphaOperation;
     logicalOperation       = desc.logicalOperation;
     writeMask              = desc.writeMask;
 }
Exemplo n.º 33
0
        public RenderBreak(int itemNumber, Text text, int textureIndex)
        {
#if DEBUG
            ObjectCausingBreak = text;
#endif
            LayerName = Renderer.CurrentLayerName;


#if WINDOWS_PHONE || MONOGAME
            if (text.ColorOperation != Graphics.ColorOperation.Texture)
            {
                Red   = text.Red;
                Green = text.Green;
                Blue  = text.Blue;
            }
            else
            {
                Red   = 1;
                Green = 1;
                Blue  = 1;
            }
#endif

            ItemNumber = itemNumber;

            PrimitiveType          = PrimitiveType.TriangleList;
            TextureFilter          = FlatRedBallServices.GraphicsOptions.TextureFilter;
            _originalTextureFilter = TextureFilter.Linear;

            if (text != null)
            {
                if (text.Font.Texture != null && text.Font.Texture.IsDisposed)
                {
                    throw new ObjectDisposedException("Cannot create render break with disposed Texture2D");
                }

                mTexture = text.Font.Textures[textureIndex];

                ColorOperation     = text.ColorOperation;
                BlendOperation     = text.BlendOperation;
                TextureAddressMode = TextureAddressMode.Clamp;
            }
            else
            {
                mTexture           = null;
                ColorOperation     = ColorOperation.None;
                BlendOperation     = BlendOperation.Regular;
                TextureAddressMode = TextureAddressMode.Clamp;
            }
        }
Exemplo n.º 34
0
 public static BlendFunc BlendFunc(BlendOperation blendOperation)
 {
     switch (blendOperation)
     {
         case BlendOperation.Add: return ObjectGL.GL42.BlendFunc.Add;
         case BlendOperation.Subtract: return ObjectGL.GL42.BlendFunc.Subtract;
         case BlendOperation.ReverseSubtract: return ObjectGL.GL42.BlendFunc.ReverseSubract;
         case BlendOperation.Minimum: return ObjectGL.GL42.BlendFunc.Min;
         case BlendOperation.Maximum: return ObjectGL.GL42.BlendFunc.Max;
         default: throw new ArgumentOutOfRangeException("blendOperation");
     }
 }
Exemplo n.º 35
0
        private void PlatformSpecificInitialization()
        {

            mColorOperation = ColorOperation.Texture;
            mBlendOperation = BlendOperation.Regular;


            // This is needed because SpriteChains may
            // use particle Sprites which can screw up 
            mVertices[0].TextureCoordinate.X = 0;
            mVertices[0].TextureCoordinate.Y = 0;
            mVertices[0].Scale = new Vector2(-1, 1);

            mVertices[1].TextureCoordinate.X = 1;
            mVertices[1].TextureCoordinate.Y = 0;
            mVertices[1].Scale = new Vector2(1, 1);

            mVertices[2].TextureCoordinate.X = 1;
            mVertices[2].TextureCoordinate.Y = 1;
            mVertices[2].Scale = new Vector2(1, -1);

            mVertices[3].TextureCoordinate.X = 0;
            mVertices[3].TextureCoordinate.Y = 1;
            mVertices[3].Scale = new Vector2(-1, -1);

            CustomBehavior = null;
        }
Exemplo n.º 36
0
        /*
            destImage - image that will be used as background
            destX, destY - define position on destination image where to start applying blend operation
            destWidth, destHeight - width and height of the area to apply blending
            srcImage - image to use as foreground (source of blending)
            srcX, srcY - starting position of the source image
        */
        public void BlendImages(Image destImage, int destX, int destY, int destWidth, int destHeight, 
								Image srcImage, int srcX, int srcY, BlendOperation BlendOp)
        {
            if( destImage == null )
                throw new Exception("Destination image must be provided");

            if( destImage.Width < destX + destWidth || destImage.Height< destY + destHeight )
                throw new Exception("Destination image is smaller than requested dimentions");

            if( srcImage == null )
                throw new Exception("Source image must be provided");

            if( srcImage.Width < srcX + destWidth || srcImage.Height< srcY + destHeight )
                throw new Exception("Source image is smaller than requested dimentions");

            Bitmap tempBmp = null;
            Graphics gr = Graphics.FromImage(destImage);
            gr.CompositingMode = CompositingMode.SourceCopy;

            switch( BlendOp )
            {
                case BlendOperation.SourceCopy:
                    gr.DrawImage(srcImage, new Rectangle(destX, destY, destWidth, destHeight),
                            srcX, srcY, destWidth, destHeight, GraphicsUnit.Pixel);
                    break;

                case BlendOperation.ROP_MergePaint:
                    tempBmp = PerChannelProcess(ref destImage, destX, destY, destWidth, destHeight,
                                ref srcImage, srcX, srcY, new PerChannelProcessDelegate(MergePaint));
                    break;

                case BlendOperation.ROP_NOTSourceErase:
                    tempBmp = PerChannelProcess(ref destImage, destX, destY, destWidth, destHeight,
                        ref srcImage, srcX, srcY, new PerChannelProcessDelegate(NOTSourceErase));
                    break;

                case BlendOperation.ROP_SourceAND:
                    tempBmp = PerChannelProcess(ref destImage, destX, destY, destWidth, destHeight,
                        ref srcImage, srcX, srcY, new PerChannelProcessDelegate(SourceAND));
                    break;

                case BlendOperation.ROP_SourceErase:
                    tempBmp = PerChannelProcess(ref destImage, destX, destY, destWidth, destHeight,
                        ref srcImage, srcX, srcY, new PerChannelProcessDelegate(SourceErase));
                    break;

                case BlendOperation.ROP_SourceInvert:
                    tempBmp = PerChannelProcess(ref destImage, destX, destY, destWidth, destHeight,
                        ref srcImage, srcX, srcY, new PerChannelProcessDelegate(SourceInvert));
                    break;

                case BlendOperation.ROP_SourcePaint:
                    tempBmp = PerChannelProcess(ref destImage, destX, destY, destWidth, destHeight,
                        ref srcImage, srcX, srcY, new PerChannelProcessDelegate(SourcePaint));
                    break;

                case BlendOperation.Blend_Darken:
                    tempBmp = PerChannelProcess(ref destImage, destX, destY, destWidth, destHeight,
                        ref srcImage, srcX, srcY, new PerChannelProcessDelegate(BlendDarken));
                    break;

                case BlendOperation.Blend_Multiply:
                    tempBmp = PerChannelProcess(ref destImage, destX, destY, destWidth, destHeight,
                        ref srcImage, srcX, srcY, new PerChannelProcessDelegate(BlendMultiply));
                    break;

                case BlendOperation.Blend_Screen:
                    tempBmp = PerChannelProcess(ref destImage, destX, destY, destWidth, destHeight,
                        ref srcImage, srcX, srcY, new PerChannelProcessDelegate(BlendScreen));
                    break;

                case BlendOperation.Blend_Lighten:
                    tempBmp = PerChannelProcess(ref destImage, destX, destY, destWidth, destHeight,
                        ref srcImage, srcX, srcY, new PerChannelProcessDelegate(BlendLighten));
                    break;

                case BlendOperation.Blend_HardLight:
                    tempBmp = PerChannelProcess(ref destImage, destX, destY, destWidth, destHeight,
                        ref srcImage, srcX, srcY, new PerChannelProcessDelegate(BlendHardLight));
                    break;

                case BlendOperation.Blend_Difference:
                    tempBmp = PerChannelProcess(ref destImage, destX, destY, destWidth, destHeight,
                        ref srcImage, srcX, srcY, new PerChannelProcessDelegate(BlendDifference));
                    break;

                case BlendOperation.Blend_PinLight:
                    tempBmp = PerChannelProcess(ref destImage, destX, destY, destWidth, destHeight,
                        ref srcImage, srcX, srcY, new PerChannelProcessDelegate(BlendPinLight));
                    break;

                case BlendOperation.Blend_Overlay:
                    tempBmp = PerChannelProcess(ref destImage, destX, destY, destWidth, destHeight,
                        ref srcImage, srcX, srcY, new PerChannelProcessDelegate(BlendOverlay));
                    break;

                case BlendOperation.Blend_Exclusion:
                    tempBmp = PerChannelProcess(ref destImage, destX, destY, destWidth, destHeight,
                        ref srcImage, srcX, srcY, new PerChannelProcessDelegate(BlendExclusion));
                    break;

                case BlendOperation.Blend_SoftLight:
                    tempBmp = PerChannelProcess(ref destImage, destX, destY, destWidth, destHeight,
                        ref srcImage, srcX, srcY, new PerChannelProcessDelegate(BlendSoftLight));
                    break;

                case BlendOperation.Blend_ColorBurn:
                    tempBmp = PerChannelProcess(ref destImage, destX, destY, destWidth, destHeight,
                        ref srcImage, srcX, srcY, new PerChannelProcessDelegate(BlendColorBurn));
                    break;

                case BlendOperation.Blend_ColorDodge:
                    tempBmp = PerChannelProcess(ref destImage, destX, destY, destWidth, destHeight,
                        ref srcImage, srcX, srcY, new PerChannelProcessDelegate(BlendColorDodge));
                    break;

                case BlendOperation.Blend_Hue:
                    tempBmp = RGBProcess(ref destImage, destX, destY, destWidth, destHeight,
                        ref srcImage, srcX, srcY, new RGBProcessDelegate(BlendHue));
                    break;

                case BlendOperation.Blend_Saturation:
                    tempBmp = RGBProcess(ref destImage, destX, destY, destWidth, destHeight,
                        ref srcImage, srcX, srcY, new RGBProcessDelegate(BlendSaturation));
                    break;

                case BlendOperation.Blend_Color:
                    tempBmp = RGBProcess(ref destImage, destX, destY, destWidth, destHeight,
                        ref srcImage, srcX, srcY, new RGBProcessDelegate(BlendColor));
                    break;

                case BlendOperation.Blend_Luminosity:
                    tempBmp = RGBProcess(ref destImage, destX, destY, destWidth, destHeight,
                        ref srcImage, srcX, srcY, new RGBProcessDelegate(BlendLuminosity));
                    break;
            }

            if( tempBmp != null )
            {
                gr.DrawImage(tempBmp, 0, 0, tempBmp.Width, tempBmp.Height);
                tempBmp.Dispose();
                tempBmp = null;
            }

            gr.Dispose();
            gr = null;
        }
Exemplo n.º 37
0
 public static BlendOperationSave TranslateBlendOperation(BlendOperation operation)
 {
     switch (operation)
     {
         case BlendOperation.Add:
             return BlendOperationSave.ADD;
         case BlendOperation.Modulate:
             return BlendOperationSave.MODULATE;
         case BlendOperation.Modulate2X:
             return BlendOperationSave.MODULATE2X;
         case BlendOperation.Regular:
             return BlendOperationSave.REGULAR;
         default:
             return BlendOperationSave.REGULAR;
     }
 }
Exemplo n.º 38
0
 /// <summary>
 /// <p>Create a blend-state object that encapsulates blend state for the output-merger stage.</p>
 /// </summary>
 /// <param name="device">The  <see cref="GraphicsDevice"/>.</param>
 /// <param name="sourceBlend">The source blend.</param>
 /// <param name="destinationBlend">The destination blend.</param>
 /// <param name="blendOperation">The blend operation.</param>
 /// <param name="sourceAlphaBlend">The source alpha blend.</param>
 /// <param name="destinationAlphaBlend">The destination alpha blend.</param>
 /// <param name="alphaBlendOperation">The alpha blend operation.</param>
 /// <param name="renderTargetWriteMask">The render target write mask.</param>
 /// <param name="mask">The mask.</param>
 /// <returns>A new <see cref="BlendState" /> instance.</returns>
 /// <msdn-id>ff476500</msdn-id>
 ///   <unmanaged>HRESULT ID3D11Device::CreateBlendState([In] const D3D11_BLEND_DESC* pBlendStateDesc,[Out, Fast] ID3D11BlendState** ppBlendState)</unmanaged>
 ///   <unmanaged-short>ID3D11Device::CreateBlendState</unmanaged-short>
 /// <remarks><p>An application can create up to 4096 unique blend-state objects. For each object created, the runtime checks to see if a previous object  has the same state. If such a previous object exists, the runtime will return a reference to previous instance instead of creating a duplicate object.</p></remarks>
 public static BlendState New(GraphicsDevice device, BlendOption sourceBlend, BlendOption destinationBlend, BlendOperation blendOperation, BlendOption sourceAlphaBlend, BlendOption destinationAlphaBlend, BlendOperation alphaBlendOperation, ColorWriteMaskFlags renderTargetWriteMask = ColorWriteMaskFlags.All, int mask = -1)
 {
     return New(device, sourceBlend, destinationBlend, blendOperation, sourceAlphaBlend, destinationAlphaBlend, alphaBlendOperation, renderTargetWriteMask, Color.White, mask);            
 }
Exemplo n.º 39
0
 /// <summary>
 /// <p>Create a blend-state object that encapsulates blend state for the output-merger stage.</p>
 /// </summary>
 /// <param name="device">The  <see cref="GraphicsDevice"/>.</param>
 /// <param name="sourceBlend">The source blend.</param>
 /// <param name="destinationBlend">The destination blend.</param>
 /// <param name="blendOperation">The blend operation.</param>
 /// <param name="sourceAlphaBlend">The source alpha blend.</param>
 /// <param name="destinationAlphaBlend">The destination alpha blend.</param>
 /// <param name="alphaBlendOperation">The alpha blend operation.</param>
 /// <param name="renderTargetWriteMask">The render target write mask.</param>
 /// <param name="blendFactor">The blend factor.</param>
 /// <param name="mask">The mask.</param>
 /// <returns>A new <see cref="BlendState"/> instance.</returns>
 /// <msdn-id>ff476500</msdn-id>
 ///   <unmanaged>HRESULT ID3D11Device::CreateBlendState([In] const D3D11_BLEND_DESC* pBlendStateDesc,[Out, Fast] ID3D11BlendState** ppBlendState)</unmanaged>
 ///   <unmanaged-short>ID3D11Device::CreateBlendState</unmanaged-short>
 /// <remarks><p>An application can create up to 4096 unique blend-state objects. For each object created, the runtime checks to see if a previous object  has the same state. If such a previous object exists, the runtime will return a reference to previous instance instead of creating a duplicate object.</p></remarks>
 public static BlendState New(GraphicsDevice device, BlendOption sourceBlend, BlendOption destinationBlend, BlendOperation blendOperation, BlendOption sourceAlphaBlend, BlendOption destinationAlphaBlend, BlendOperation alphaBlendOperation, ColorWriteMaskFlags renderTargetWriteMask, Color4 blendFactor, int mask = -1)
 {
     return New(device, new RenderTargetBlendDescription(true, sourceBlend, destinationBlend, blendOperation, sourceAlphaBlend, destinationAlphaBlend, alphaBlendOperation, renderTargetWriteMask), blendFactor, mask);
 }
Exemplo n.º 40
0
 public void BlendImages(Image destImage, int destX, int destY, BlendOperation BlendOp)
 {
     BlendImages(destImage, destX, destY, destImage.Width - destX, destImage.Height - destY, null, 0, 0, BlendOp);
 }
Exemplo n.º 41
0
 public void BlendImages(Image destImage, BlendOperation BlendOp)
 {
     BlendImages(destImage, 0, 0, destImage.Width, destImage.Height, null, 0, 0, BlendOp);
 }
Exemplo n.º 42
0
 public void BlendImages(Image destImage, int destX, int destY, int destWidth, int destHeight, BlendOperation BlendOp)
 {
     BlendImages(destImage, destX, destY, destWidth, destHeight, null, 0, 0, BlendOp);
 }
 internal static BlendEquationMode BlendOperationToOgl(BlendOperation bo)
 {
     switch (bo)
     {
         case BlendOperation.Add:
             return BlendEquationMode.FuncAdd;
         case BlendOperation.Subtract:
             return BlendEquationMode.FuncSubtract;
         case BlendOperation.ReverseSubtract:
             return BlendEquationMode.FuncReverseSubtract;
         case BlendOperation.Minimum:
             return BlendEquationMode.Min;
         case BlendOperation.Maximum:
             return BlendEquationMode.Max;
         default:
             throw new ArgumentOutOfRangeException("bo");
     }
 }
Exemplo n.º 44
0
 public static void BlendImages(Bitmap destImage, int destX, int destY, int destWidth, int destHeight, BlendOperation blendOp)
 {
     BlendImages(destImage, destX, destY, destWidth, destHeight, null, 0, 0, blendOp);
 }
Exemplo n.º 45
0
 public static void BlendImages(Bitmap destImage, int destX, int destY, BlendOperation blendOp)
 {
     BlendImages(destImage, destX, destY, destImage.Width - destX, destImage.Height - destY, null, 0, 0, blendOp);
 }
Exemplo n.º 46
0
 public static void BlendImages(Bitmap destImage, BlendOperation blendOp)
 {
     BlendImages(destImage, 0, 0, destImage.Width, destImage.Height, null, 0, 0, blendOp);
 }
Exemplo n.º 47
0
        /*
			destImage - image that will be used as background
			destX, destY - define position on destination image where to start applying blend operation
			destWidth, destHeight - width and height of the area to apply blending
			srcImage - image to use as foreground (source of blending)
			srcX, srcY - starting position of the source image
		*/

        public static void BlendImages(Bitmap destImage, int destX, int destY, int destWidth, int destHeight,
                                       Bitmap srcImage, int srcX, int srcY, BlendOperation blendOp)
        {
            if (destImage == null)
                throw new Exception("Destination image must be provided");

            if (destImage.Width < destX + destWidth || destImage.Height < destY + destHeight)
                throw new Exception("Destination image is smaller than requested dimentions");

            if (srcImage == null)
                throw new Exception("Source image must be provided");

            if (srcImage.Width < srcX + destWidth || srcImage.Height < srcY + destHeight)
                throw new Exception("Source image is smaller than requested dimentions");

            Bitmap tempBmp = null;
            using (IGraphics gr = Graphics.FromImage(destImage).G())
            {
                gr.CompositingMode = Compositing.SourceCopy;

                switch (blendOp)
                {
                    case BlendOperation.SourceCopy:
                        gr.DrawImage(srcImage,
                            destX, destY, destWidth, destHeight,
                            srcX, srcY, destWidth, destHeight, 
                            GraphicsUnitType.Pixel);
                        break;

                    case BlendOperation.RopMergePaint:
                        tempBmp = PerChannelProcess(destImage, destX, destY, destWidth, destHeight,
                                                    srcImage, srcX, srcY, MergePaint);
                        break;

                    case BlendOperation.RopNotSourceErase:
                        tempBmp = PerChannelProcess(destImage, destX, destY, destWidth, destHeight,
                                                    srcImage, srcX, srcY, NotSourceErase);
                        break;

                    case BlendOperation.RopSourceAnd:
                        tempBmp = PerChannelProcess(destImage, destX, destY, destWidth, destHeight,
                                                    srcImage, srcX, srcY, SourceAnd);
                        break;

                    case BlendOperation.RopSourceErase:
                        tempBmp = PerChannelProcess(destImage, destX, destY, destWidth, destHeight,
                                                    srcImage, srcX, srcY, SourceErase);
                        break;

                    case BlendOperation.RopSourceInvert:
                        tempBmp = PerChannelProcess(destImage, destX, destY, destWidth, destHeight,
                                                    srcImage, srcX, srcY, SourceInvert);
                        break;

                    case BlendOperation.RopSourcePaint:
                        tempBmp = PerChannelProcess(destImage, destX, destY, destWidth, destHeight,
                                                    srcImage, srcX, srcY, SourcePaint);
                        break;

                    case BlendOperation.BlendDarken:
                        tempBmp = PerChannelProcess(destImage, destX, destY, destWidth, destHeight,
                                                    srcImage, srcX, srcY, BlendDarken);
                        break;

                    case BlendOperation.BlendMultiply:
                        tempBmp = PerChannelProcess(destImage, destX, destY, destWidth, destHeight,
                                                    srcImage, srcX, srcY, BlendMultiply);
                        break;

                    case BlendOperation.BlendScreen:
                        tempBmp = PerChannelProcess(destImage, destX, destY, destWidth, destHeight,
                                                    srcImage, srcX, srcY, BlendScreen);
                        break;

                    case BlendOperation.BlendLighten:
                        tempBmp = PerChannelProcess(destImage, destX, destY, destWidth, destHeight,
                                                    srcImage, srcX, srcY, BlendLighten);
                        break;

                    case BlendOperation.BlendHardLight:
                        tempBmp = PerChannelProcess(destImage, destX, destY, destWidth, destHeight,
                                                    srcImage, srcX, srcY, BlendHardLight);
                        break;

                    case BlendOperation.BlendDifference:
                        tempBmp = PerChannelProcess(destImage, destX, destY, destWidth, destHeight,
                                                    srcImage, srcX, srcY, BlendDifference);
                        break;

                    case BlendOperation.BlendPinLight:
                        tempBmp = PerChannelProcess(destImage, destX, destY, destWidth, destHeight,
                                                    srcImage, srcX, srcY, BlendPinLight);
                        break;

                    case BlendOperation.BlendOverlay:
                        tempBmp = PerChannelProcess(destImage, destX, destY, destWidth, destHeight,
                                                    srcImage, srcX, srcY, BlendOverlay);
                        break;

                    case BlendOperation.BlendExclusion:
                        tempBmp = PerChannelProcess(destImage, destX, destY, destWidth, destHeight,
                                                    srcImage, srcX, srcY, BlendExclusion);
                        break;

                    case BlendOperation.BlendSoftLight:
                        tempBmp = PerChannelProcess(destImage, destX, destY, destWidth, destHeight,
                                                    srcImage, srcX, srcY, BlendSoftLight);
                        break;

                    case BlendOperation.BlendColorBurn:
                        tempBmp = PerChannelProcess(destImage, destX, destY, destWidth, destHeight,
                                                    srcImage, srcX, srcY, BlendColorBurn);
                        break;

                    case BlendOperation.BlendColorDodge:
                        tempBmp = PerChannelProcess(destImage, destX, destY, destWidth, destHeight,
                                                    srcImage, srcX, srcY, BlendColorDodge);
                        break;

                    case BlendOperation.BlendHue:
                        tempBmp = RgbProcess(destImage, destX, destY, destWidth, destHeight,
                                             srcImage, srcX, srcY, BlendHue);
                        break;

                    case BlendOperation.BlendSaturation:
                        tempBmp = RgbProcess(destImage, destX, destY, destWidth, destHeight,
                                             srcImage, srcX, srcY, BlendSaturation);
                        break;

                    case BlendOperation.BlendColor:
                        tempBmp = RgbProcess(destImage, destX, destY, destWidth, destHeight,
                                             srcImage, srcX, srcY, BlendColor);
                        break;

                    case BlendOperation.BlendLuminosity:
                        tempBmp = RgbProcess(destImage, destX, destY, destWidth, destHeight,
                                             srcImage, srcX, srcY, BlendLuminosity);
                        break;
                }

                if (tempBmp != null && tempBmp != destImage)
                {
                    gr.DrawImage(tempBmp, 0, 0, tempBmp.Width, tempBmp.Height);
                    tempBmp.Dispose();
                }
            }
        }
Exemplo n.º 48
0
 public bool SetAlphaMode(BlendOperation Operation, Blend Blend)
 {
     try
     {
         device.RenderState.AlphaBlendEnable = true;
         device.RenderState.BlendOperation = Operation;
         device.RenderState.SourceBlend = Blend;
         device.RenderState.DestinationBlend = Blend;
         return true;
     }
     catch
     {
         return false;
     }
 }