/// <summary> /// The GdiAlphaBlend function displays bitmaps that have transparent or semitransparent pixels. /// </summary> /// <param name="hdcDest">Handle to the destination device context.</param> /// <param name="nXOriginDest">Specifies the x-coordinate, in logical units, /// of the upper-left corner of the destination rectangle</param> /// <param name="nYOriginDest">Specifies the y-coordinate, in logical units, /// of the upper-left corner of the destination rectangle</param> /// <param name="nWidthDest">Specifies the width, in logical units, of the destination rectangle</param> /// <param name="nHeightDest">Specifies the height, in logical units, of the destination rectangle</param> /// <param name="hdcSrc">Handle to the source device context</param> /// <param name="nXOriginSrc">Specifies the x-coordinate, in logical units, of the upper-left corner of the source rectangle</param> /// <param name="nYOriginSrc">Specifies the y-coordinate, in logical units, of the upper-left corner of the source rectangle</param> /// <param name="nWidthSrc">Specifies the width, in logical units, of the source rectangle</param> /// <param name="nHeightSrc">Specifies the height, in logical units, of the source rectangle</param> /// <param name="blendFunction">Specifies the alpha-blending function for source and destination bitmaps, a global alpha value to be /// applied to the entire source bitmap, and format information for the source bitmap. The source and destination blend /// functions are currently limited to AC_SRC_OVER.</param> /// <returns>If the function succeeds, the return value is true. /// If the function fails, the return value is false.</returns> public static bool GdiAlphaBlend(IntPtr hdcDest, int nXOriginDest, int nYOriginDest, int nWidthDest, int nHeightDest, IntPtr hdcSrc, int nXOriginSrc, int nYOriginSrc, int nWidthSrc, int nHeightSrc, BlendFunction blendFunction) { return(Native.GdiAlphaBlend(hdcDest, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest, hdcSrc, nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc, blendFunction)); }
public static void AlphaBlend(IntPtr hdcDest, int nXOriginDest, int nYOriginDest, int nWidthDest, int nHeightDest, IntPtr hdcSrc, int nXOriginSrc, int nYOriginSrc, int nWidthSrc, int nHeightSrc, BlendFunction blendFunction) { if (Environment.OSVersion.Platform == PlatformID.WinCE) { AlphaBlendCE(hdcDest, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest, hdcSrc, nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc, blendFunction); } }
/// <summary> /// The AlphaBlend function displays bitmaps that have transparent or semitransparent pixels. /// </summary> /// <param name="hdcDest">Handle to the destination device context.</param> /// <param name="xoriginDest">Specifies the x-coordinate, in logical units, /// of the upper-left corner of the destination rectangle</param> /// <param name="yoriginDest">Specifies the y-coordinate, in logical units, /// of the upper-left corner of the destination rectangle</param> /// <param name="wDest">Specifies the width, in logical units, of the destination rectangle</param> /// <param name="hDest">Specifies the height, in logical units, of the destination rectangle</param> /// <param name="hdcSrc">Handle to the source device context</param> /// <param name="xoriginSrc">Specifies the x-coordinate, in logical units, of the upper-left corner of the source rectangle</param> /// <param name="yoriginSrc">Specifies the y-coordinate, in logical units, of the upper-left corner of the source rectangle</param> /// <param name="wSrc">Specifies the width, in logical units, of the source rectangle</param> /// <param name="hSrc">Specifies the height, in logical units, of the source rectangle</param> /// <param name="ftn">Specifies the alpha-blending function for source and destination bitmaps, a global alpha value to be /// applied to the entire source bitmap, and format information for the source bitmap. The source and destination blend /// functions are currently limited to AC_SRC_OVER.</param> /// <returns>If the function succeeds, the return value is true. /// If the function fails, the return value is FALSE. </returns> public static bool AlphaBlend(IntPtr hdcDest, int xoriginDest, int yoriginDest, int wDest, int hDest, IntPtr hdcSrc, int xoriginSrc, int yoriginSrc, int wSrc, int hSrc, BlendFunction ftn) { return Native.AlphaBlend(hdcDest, xoriginDest, yoriginDest, wDest, hDest, hdcSrc, xoriginSrc, yoriginSrc, wSrc, hSrc, ftn); }
public BlendState(string name, Blend colorSourceBlend = Blend.One, Blend alphaSourceBlend = Blend.One, Blend colorDestinationBlend = Blend.Zero, Blend alphaDestinationBlend = Blend.Zero, BlendFunction colorBlendFunction = BlendFunction.Add, BlendFunction alphaBlendFunction = BlendFunction.Add, ColorWriteChannels colorWriteChannels = ColorWriteChannels.All, ColorWriteChannels colorWriteChannels1 = ColorWriteChannels.All, ColorWriteChannels colorWriteChannels2 = ColorWriteChannels.All, ColorWriteChannels colorWriteChannels3 = ColorWriteChannels.All) { Name = name; ColorSourceBlend = colorSourceBlend; AlphaSourceBlend = alphaSourceBlend; ColorDestinationBlend = colorDestinationBlend; AlphaDestinationBlend = alphaDestinationBlend; ColorBlendFunction = colorBlendFunction; AlphaBlendFunction = alphaBlendFunction; ColorWriteChannels = colorWriteChannels; ColorWriteChannels1 = colorWriteChannels1; ColorWriteChannels2 = colorWriteChannels2; ColorWriteChannels3 = colorWriteChannels3; BlendFactor = Color.White; MultiSampleMask = unchecked ((int)0xffffffff); }
/// <summary> /// The AlphaBlend function displays bitmaps that have transparent or semitransparent pixels. /// </summary> /// <param name="hdcDest">Handle to the destination device context.</param> /// <param name="xoriginDest">Specifies the x-coordinate, in logical units, /// of the upper-left corner of the destination rectangle</param> /// <param name="yoriginDest">Specifies the y-coordinate, in logical units, /// of the upper-left corner of the destination rectangle</param> /// <param name="wDest">Specifies the width, in logical units, of the destination rectangle</param> /// <param name="hDest">Specifies the height, in logical units, of the destination rectangle</param> /// <param name="hdcSrc">Handle to the source device context</param> /// <param name="xoriginSrc">Specifies the x-coordinate, in logical units, of the upper-left corner of the source rectangle</param> /// <param name="yoriginSrc">Specifies the y-coordinate, in logical units, of the upper-left corner of the source rectangle</param> /// <param name="wSrc">Specifies the width, in logical units, of the source rectangle</param> /// <param name="hSrc">Specifies the height, in logical units, of the source rectangle</param> /// <param name="ftn">Specifies the alpha-blending function for source and destination bitmaps, a global alpha value to be /// applied to the entire source bitmap, and format information for the source bitmap. The source and destination blend /// functions are currently limited to AC_SRC_OVER.</param> /// <returns>If the function succeeds, the return value is true. /// If the function fails, the return value is FALSE. </returns> public static bool AlphaBlend(IntPtr hdcDest, int xoriginDest, int yoriginDest, int wDest, int hDest, IntPtr hdcSrc, int xoriginSrc, int yoriginSrc, int wSrc, int hSrc, BlendFunction ftn) { return(Native.AlphaBlend(hdcDest, xoriginDest, yoriginDest, wDest, hDest, hdcSrc, xoriginSrc, yoriginSrc, wSrc, hSrc, ftn)); }
private void NextBlendFunctionExecute() { if (BlendFunctions.Last() != SelectedBlendFunction) { SelectedBlendFunction = BlendFunctions[BlendFunctions.IndexOf(SelectedBlendFunction) + 1]; } }
public void Redraw() { if (!visible || Paint == null) { return; } if (size != bufferSize) { DisposeBuffer(); CreateBuffer(); } Paint(this, new PaintEventArgs(graphics, new Rectangle(Point.Empty, size))); Point pointSource = Point.Empty; BlendFunction blend = CreateBlendFunction(); NativeMethods.UpdateLayeredWindow(Handle, IntPtr.Zero, IntPtr.Zero, ref size, handleBitmapDC, ref pointSource, 0, ref blend, ULW_ALPHA); // make sure the window is at the right location NativeMethods.SetWindowPos(Handle, IntPtr.Zero, location.X, location.Y, 0, 0, SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSENDCHANGING); }
public D3DBlendState( Device device, bool isBlendEnabled, Blend srcAlpha, Blend destAlpha, BlendFunction alphaBlendFunc, Blend srcColor, Blend destColor, BlendFunction colorBlendFunc, RgbaFloat blendFactor) { _device = device; IsBlendEnabled = isBlendEnabled; SourceAlphaBlend = srcAlpha; DestinationAlphaBlend = destAlpha; AlphaBlendFunction = alphaBlendFunc; SourceColorBlend = srcColor; DestinationColorBlend = destColor; ColorBlendFunction = colorBlendFunc; BlendFactor = blendFactor; var desc = new BlendStateDescription(); desc.RenderTarget[0].SourceAlphaBlend = D3DFormats.VeldridToD3DBlend(SourceAlphaBlend); desc.RenderTarget[0].DestinationAlphaBlend = D3DFormats.VeldridToD3DBlend(DestinationAlphaBlend); desc.RenderTarget[0].AlphaBlendOperation = D3DFormats.VeldridToD3DBlendFunction(AlphaBlendFunction); desc.RenderTarget[0].SourceBlend = D3DFormats.VeldridToD3DBlend(SourceColorBlend); desc.RenderTarget[0].DestinationBlend = D3DFormats.VeldridToD3DBlend(DestinationColorBlend); desc.RenderTarget[0].BlendOperation = D3DFormats.VeldridToD3DBlendFunction(ColorBlendFunction); desc.RenderTarget[0].IsBlendEnabled = isBlendEnabled; desc.RenderTarget[0].RenderTargetWriteMask = ColorWriteMaskFlags.All; _deviceBlendState = new SharpDX.Direct3D11.BlendState(_device, desc); }
public void Update(Bitmap bitmap) { IntPtr screen = NativeMethods.GetDC(IntPtr.Zero); IntPtr memory = NativeMethods.CreateCompatibleDC(screen); IntPtr newHBitmap = IntPtr.Zero; IntPtr oldHBitmap = IntPtr.Zero; try { newHBitmap = bitmap.GetHbitmap(Color.Black); oldHBitmap = NativeMethods.SelectObject(memory, newHBitmap); Point pointSource = Point.Empty; BlendFunction blend = CreateBlendFunction(); NativeMethods.UpdateLayeredWindow(Handle, screen, IntPtr.Zero, ref size, memory, ref pointSource, 0, ref blend, ULW_ALPHA); // make sure the window is at the right location NativeMethods.SetWindowPos(Handle, IntPtr.Zero, location.X, location.Y, 0, 0, SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSENDCHANGING); } finally { if (newHBitmap != IntPtr.Zero) { NativeMethods.SelectObject(memory, oldHBitmap); NativeMethods.DeleteObject(newHBitmap); } NativeMethods.DeleteDC(memory); NativeMethods.ReleaseDC(IntPtr.Zero, screen); } }
public static BlendEquationMode GetBlendEquationMode(this BlendFunction function) { switch (function) { case BlendFunction.Add: return(BlendEquationMode.FuncAdd); #if IOS case BlendFunction.Max: return((BlendEquationMode)All.MaxExt); case BlendFunction.Min: return((BlendEquationMode)All.MinExt); #elif MONOMAC || WINDOWS || LINUX case BlendFunction.Max: return(BlendEquationMode.Max); case BlendFunction.Min: return(BlendEquationMode.Min); #endif case BlendFunction.ReverseSubtract: return(BlendEquationMode.FuncReverseSubtract); case BlendFunction.Subtract: return(BlendEquationMode.FuncSubtract); default: throw new ArgumentException(); } }
[SuppressMessage("Microsoft.Usage", "CA1806:DoNotIgnoreMethodResults")] //, MessageId = "ListMaker.Splash+NativeMethods.ReleaseDC(System.IntPtr,System.IntPtr)")] void UpdateWindow() { IntPtr screenDC = NativeMethods.GetDC(IntPtr.Zero); IntPtr imageDC = NativeMethods.CreateCompatibleDC(screenDC); IntPtr gdiBitmap = IntPtr.Zero; IntPtr oldBitmap = IntPtr.Zero; try { gdiBitmap = autoScrollIcon.GetHbitmap(Color.FromArgb(0)); //Get a GDI handle to the image. oldBitmap = NativeMethods.SelectObject(imageDC, gdiBitmap); //Select the image into the DC, and cache the old bitmap. Size size = autoScrollIcon.Size; //Get the size and location of the form, as integers. Point location = Location; BlendFunction alphaInfo = new BlendFunction { SourceConstantAlpha = 255, AlphaFormat = 1 }; //This struct provides information about the opacity of the form. NativeMethods.UpdateLayeredWindow(Handle, screenDC, ref location, ref size, imageDC, ref Zero, 0, ref alphaInfo, UlwType.Alpha); } finally { NativeMethods.ReleaseDC(IntPtr.Zero, screenDC); //Release the Screen's DC. if (gdiBitmap != IntPtr.Zero) //If we got a GDI btimap, { NativeMethods.SelectObject(imageDC, oldBitmap); //Select the old bitmap into the DC NativeMethods.DeleteObject(gdiBitmap); //Delete the GDI bitmap, } NativeMethods.DeleteDC(imageDC); //And delete the DC. } }
public MainViewModel() { BlendFunctions = new List <BlendFunction> { BlendFunction.Multiply, BlendFunction.Add, BlendFunction.Color, BlendFunction.Colorburn, BlendFunction.Colordodge, BlendFunction.Overlay, BlendFunction.Softlight, BlendFunction.Screen, BlendFunction.Hardlight, BlendFunction.Darken, BlendFunction.Lighten, BlendFunction.Hue, BlendFunction.Exclusion, BlendFunction.Difference, BlendFunction.Pluslighten, }; SelectedBlendFunction = BlendFunction.Multiply; ChooseCommand = new RelayCommand(ChooseExecute, () => CanChoose); SaveCommand = new RelayCommand(SaveExecute, () => FilterApplied); ShareCommand = new RelayCommand(ShareExecute, () => FilterApplied); SwapCommand = new RelayCommand(SwapExecute, () => FilterApplied); PreviousBlendFunctionCommand = new RelayCommand(PreviousBlendFunctionExecute, () => BlendFunctions.First() != SelectedBlendFunction); NextBlendFunctionCommand = new RelayCommand(NextBlendFunctionExecute, () => BlendFunctions.Last() != SelectedBlendFunction); }
private void PreviousBlendFunctionExecute() { if (BlendFunctions.First() != SelectedBlendFunction) { SelectedBlendFunction = BlendFunctions[BlendFunctions.IndexOf(SelectedBlendFunction) - 1]; } }
/// <summary> /// Construct a layer style. /// </summary> /// <param name="blendFunction">Blend function to use when combining the result of this layer with the previous.</param> /// <param name="opacity">The opacity of the layer.</param> /// <param name="maskImageProviderResolver">A lazy resolve func that returns the <see cref="IImageProvider" /> based on context sensitive values such as source image size.</param> /// <param name="targetArea">If non-empty, positions and scales the layer within the bounds of the preceding one. See <see cref="Lumia.Imaging.Compositing.BlendEffect"/>.</param> /// <returns>A layer style.</returns> public LayerStyle(BlendFunction blendFunction, double opacity, Func <LayerContext, MaybeTask <IImageProvider> > maskImageProviderResolver, Rect?targetArea = null) { BlendFunction = blendFunction; Opacity = opacity; TargetArea = targetArea; MaskResolver = maskImageProviderResolver; }
public static BlendEquationMode GetBlendEquationMode(this BlendFunction function) { switch (function) { case BlendFunction.Add: return(BlendEquationMode.FuncAdd); #if IPHONE case BlendFunction.Max: return(BlendEquationMode.MaxExt); case BlendFunction.Min: return(BlendEquationMode.MinExt); #elif MONOMAC case BlendFunction.Max: return(BlendEquationMode.Max); case BlendFunction.Min: return(BlendEquationMode.Min); #endif case BlendFunction.ReverseSubtract: return(BlendEquationMode.FuncReverseSubtract); case BlendFunction.Subtract: return(BlendEquationMode.FuncSubtract); default: throw new NotImplementedException(); } }
/* Private Hashing Functions */ private static StateHash GetBlendHash( BlendFunction alphaBlendFunc, Blend alphaDestBlend, Blend alphaSrcBlend, BlendFunction colorBlendFunc, Blend colorDestBlend, Blend colorSrcBlend, ColorWriteChannels channels, ColorWriteChannels channels1, ColorWriteChannels channels2, ColorWriteChannels channels3, Color blendFactor, int multisampleMask ) { int funcs = ((int)alphaBlendFunc << 4) | ((int)colorBlendFunc); int blendsAndColorWriteChannels = ((int)alphaDestBlend << 28) | ((int)alphaSrcBlend << 24) | ((int)colorDestBlend << 20) | ((int)colorSrcBlend << 16) | ((int)channels << 12) | ((int)channels1 << 8) | ((int)channels2 << 4) | ((int)channels3); unchecked { return(new StateHash( ((ulong)funcs << 32) | ((ulong)blendsAndColorWriteChannels << 0), ((ulong)multisampleMask << 32) | ((ulong)blendFactor.PackedValue << 0) )); } }
/* Private Hashing Functions */ private static StateHash GetBlendHash( BlendFunction alphaBlendFunc, Blend alphaDestBlend, Blend alphaSrcBlend, BlendFunction colorBlendFunc, Blend colorDestBlend, Blend colorSrcBlend, ColorWriteChannels channels, ColorWriteChannels channels1, ColorWriteChannels channels2, ColorWriteChannels channels3, Color blendFactor, int multisampleMask ) { int funcs = ((int)alphaBlendFunc << 4) | ((int)colorBlendFunc); int blendsAndColorWriteChannels = ((int)alphaDestBlend << (32 - 4)) | ((int)alphaSrcBlend << (32 - 8)) | ((int)colorDestBlend << (32 - 12)) | ((int)colorSrcBlend << (32 - 16)) | ((int)channels << (32 - 20)) | ((int)channels1 << (32 - 24)) | ((int)channels2 << (32 - 28)) | ((int)channels3); return(new StateHash( funcs, blendsAndColorWriteChannels, (int)blendFactor.PackedValue, multisampleMask )); }
public override BlendState CreateCustomBlendState( bool isBlendEnabled, Blend srcAlpha, Blend destAlpha, BlendFunction alphaBlendFunc, Blend srcColor, Blend destColor, BlendFunction colorBlendFunc) { return(new D3DBlendState(_device, isBlendEnabled, srcAlpha, destAlpha, alphaBlendFunc, srcColor, destColor, colorBlendFunc)); }
/// <summary> /// Creates a new <see cref="BlendState"/>, used to control blending behavior in the device's output merger. /// with separate factors for alpha and color blending. /// </summary> /// <param name="isBlendEnabled">A value indicating whether blending is enabled in the <see cref="BlendState"/>.</param> /// <param name="srcAlpha">The source alpha blend factor.</param> /// <param name="destAlpha">The destination alpha blend factor.</param> /// <param name="alphaBlendFunc">The alpha blend function.</param> /// <param name="srcColor">The source color blend factor.</param> /// <param name="destColor">The destenation color blend factor.</param> /// <param name="colorBlendFunc">The color blend function.</param> /// <param name="blendFactor">The blend factor to use for parameterized blend states.</param> /// <returns>A new <see cref="BlendState"/>.</returns> public BlendState CreateCustomBlendState( bool isBlendEnabled, Blend srcAlpha, Blend destAlpha, BlendFunction alphaBlendFunc, Blend srcColor, Blend destColor, BlendFunction colorBlendFunc, RgbaFloat blendFactor) { return(CreateCustomBlendStateCore(isBlendEnabled, srcAlpha, destAlpha, alphaBlendFunc, srcColor, destColor, colorBlendFunc, blendFactor)); }
public override void DrawProperties() { var blendContent = new GUIContent("Blend Func", "Select the blend function"); blendFunc = (BlendFunction)EditorGUILayout.EnumPopup(blendContent, blendFunc); _normalize = EditorGUILayout.Toggle("Normalize Result", _normalize); base.DrawProperties(); }
protected override BlendState CreateCustomBlendStateCore( bool isBlendEnabled, Blend srcAlpha, Blend destAlpha, BlendFunction alphaBlendFunc, Blend srcColor, Blend destColor, BlendFunction colorBlendFunc, RgbaFloat blendFactor) { return(new OpenGLBlendState(isBlendEnabled, srcAlpha, destAlpha, alphaBlendFunc, srcColor, destColor, colorBlendFunc, blendFactor)); }
public HeightBrush(int width, int height, float power, int precision, SampleFunction sample = null, BlendFunction blend = null) { Width = width; Height = height; Power = power; Precision = precision; Sample = sample; Blend = blend; }
private BlendState(BlendMode colorSource, BlendMode colorDest, BlendFunction colorFunc, BlendMode alphaSource, BlendMode alphaDest, BlendFunction alphaFunc) { _colorSourceBlend = colorSource; _colorDestinationBlend = colorDest; _colorBlendFunction = colorFunc; _alphaSourceBlend = alphaSource; _alphaDestinationBlend = alphaDest; _alphaBlendFunction = alphaFunc; }
internal ShaderStateAlphaBlendStateBlockBase(BinaryReader binaryReader) { this.blendFunction = (BlendFunction)binaryReader.ReadInt16(); this.blendSrcFactor = (BlendSrcFactor)binaryReader.ReadInt16(); this.blendDstFactor = (BlendDstFactor)binaryReader.ReadInt16(); this.invalidName_ = binaryReader.ReadBytes(2); this.blendColor = binaryReader.ReadColourA1R1G1B1(); this.logicOpFlags = (LogicOpFlags)binaryReader.ReadInt16(); this.invalidName_0 = binaryReader.ReadBytes(2); }
UpdateLayeredWindow( IntPtr hWnd, IntPtr hdcDst, ref Point pptDst, ref Size psize, IntPtr hdcSrc, ref Point pptSrc, UInt32 crKey, ref BlendFunction pblend, UInt32 dwFlags);
private BlendFunction CreateBlendFunction() { BlendFunction blend = new BlendFunction(); blend.BlendOp = AC_SRC_OVER; blend.BlendFlags = 0; blend.SourceConstantAlpha = opacity; blend.AlphaFormat = AC_SRC_ALPHA; return(blend); }
public static extern bool UpdateLayeredWindow( IntPtr hWnd, IntPtr hdcDst, [In] ref Point pptDst, [In] ref Size pSize, IntPtr hdcSrc, [In] ref Point pptSrc, int crKey, [In] ref BlendFunction pBlend, uint dwFlags);
public static extern Int32 AlphaBlend(IntPtr hdcDest, Int32 xDest, Int32 yDest, Int32 cxDest, Int32 cyDest, IntPtr hdcSrc, Int32 xSrc, Int32 ySrc, Int32 cxSrc, Int32 cySrc, BlendFunction blendFunction);
public VkBlendState(bool isBlendEnabled, Blend srcAlpha, Blend destAlpha, BlendFunction alphaBlendFunc, Blend srcColor, Blend destColor, BlendFunction colorBlendFunc, RgbaFloat blendFactor) { IsBlendEnabled = isBlendEnabled; SourceAlphaBlend = srcAlpha; DestinationAlphaBlend = destAlpha; AlphaBlendFunction = alphaBlendFunc; SourceColorBlend = srcColor; DestinationColorBlend = destColor; ColorBlendFunction = colorBlendFunc; BlendFactor = blendFactor; }
public static BlendState CreateBlendState(BlendFunction func, Blend colorSrc, Blend alphaSrc, Blend colorDst, Blend alphaDst) { return(new BlendState() { ColorBlendFunction = func, ColorSourceBlend = colorSrc, AlphaSourceBlend = alphaSrc, ColorDestinationBlend = colorDst, AlphaDestinationBlend = alphaDst }); }
extern private static Int32 AlphaBlend( IntPtr hdcDest, Int32 xDest, Int32 yDest, Int32 cxDest, Int32 cyDest, IntPtr hdcSrc, Int32 xSrc, Int32 ySrc, Int32 cxSrc, Int32 cySrc, BlendFunction blendFunction);
public void draw(Matrix world, Camera.CameraMatrices cam, GraphicsDevice g) { e.AmbientLightColor = new Vector3(1f, 1f, 1f); //sun.Draw(cam.View, world, cam.Projection, e); BlendFunction prev = g.RenderState.BlendFunction; g.RenderState.BlendFunction = BlendFunction.Add; e.AmbientLightColor = new Vector3(1f, 0.8f, 0.5f); e.DiffuseColor = new Vector3(1f, 0.8f, 0.5f); //e.SpecularColor = new Vector3(1f, 0.8f, 0.5f); glare.Draw(cam.View, world, cam.Projection, e); g.RenderState.BlendFunction = prev; }
public static BlendFuncMode ToBlendFuncMode(BlendFunction format) { switch(format) { case BlendFunction.Add : return BlendFuncMode.Add; case BlendFunction.ReverseSubtract : return BlendFuncMode.ReverseSubtract; case BlendFunction.Subtract : return BlendFuncMode.Subtract; } throw new NotImplementedException(); }
public static extern bool AlphaBlend( IntPtr hdcDest, // handle to destination DC int nXOriginDest, // x-coord of upper-left corner int nYOriginDest, // y-coord of upper-left corner int nWidthDest, // destination width int nHeightDest, // destination height IntPtr hdcSrc, // handle to source DC int nXOriginSrc, // x-coord of upper-left corner int nYOriginSrc, // y-coord of upper-left corner int nWidthSrc, // source width int nHeightSrc, // source height BlendFunction blendFunction // alpha-blending function );
/// <summary> /// Construct a layer style. /// </summary> /// <param name="blendFunction">Blend function to use when combining the result of this layer with the previous.</param> /// <param name="opacity">The opacity of the layer.</param> /// <param name="maskImageProviderResolver">A lazy resolve func that returns the <see cref="IImageProvider" /> based on context sensitive values such as source image size.</param> /// <param name="targetArea">If non-empty, positions and scales the layer within the bounds of the preceding one. See <see cref="Lumia.Imaging.Compositing.BlendEffect"/>.</param> /// <returns>A layer style.</returns> public LayerStyle(BlendFunction blendFunction, double opacity, Func<LayerContext, Task<IImageProvider>> maskImageProviderResolver, Rect? targetArea = null) { BlendFunction = blendFunction; Opacity = opacity; TargetArea = targetArea; if (maskImageProviderResolver != null) { MaskResolver = context => new MaybeTask<IImageProvider>(maskImageProviderResolver(context)); } else { MaskResolver = null; } }
public static void DrawAlpha(Graphics graphics, Bitmap image, byte transparency, int x, int y) { if (Environment.OSVersion.Platform == PlatformID.WinCE) { using (Graphics graphics2 = Graphics.FromImage(image)) { IntPtr hdc = graphics.GetHdc(); IntPtr hdcSrc = graphics2.GetHdc(); BlendFunction blendFunction = new BlendFunction(0, 0, transparency, 0); AlphaBlend(hdc, x, y, image.Width, image.Height, hdcSrc, 0, 0, image.Width, image.Height, blendFunction); graphics.ReleaseHdc(hdc); graphics2.ReleaseHdc(hdcSrc); return; } } TransparentBlt(graphics, image, x, y, transparency); }
public static BlendEquationMode ToOpenGL(BlendFunction blendFunction) { switch (blendFunction) { case BlendFunction.Subtract: return BlendEquationMode.FuncSubtract; case BlendFunction.Add: return BlendEquationMode.FuncAdd; #if !SILICONSTUDIO_XENKO_GRAPHICS_API_OPENGLES case BlendFunction.Max: return BlendEquationMode.Max; case BlendFunction.Min: return BlendEquationMode.Min; #endif case BlendFunction.ReverseSubtract: return BlendEquationMode.FuncReverseSubtract; default: throw new NotSupportedException(); } }
static private SharpDX.Direct3D11.BlendOperation GetBlendOperation(BlendFunction blend) { switch (blend) { case BlendFunction.Add: return SharpDX.Direct3D11.BlendOperation.Add; case BlendFunction.Max: return SharpDX.Direct3D11.BlendOperation.Maximum; case BlendFunction.Min: return SharpDX.Direct3D11.BlendOperation.Minimum; case BlendFunction.ReverseSubtract: return SharpDX.Direct3D11.BlendOperation.ReverseSubtract; case BlendFunction.Subtract: return SharpDX.Direct3D11.BlendOperation.Subtract; default: throw new ArgumentException("Invalid blend function!"); } }
private BlendState(Blend sourceBlend, Blend destinationBlend, BlendFunction function) { this.sourceBlend = sourceBlend; this.destinationBlend = destinationBlend; this.function = function; }
/// <summary> /// Construct a layer style. /// </summary> /// <param name="blendFunction">Blend function to use when combining the result of this layer with the previous.</param> /// <param name="opacity">The opacity of the layer.</param> /// <param name="maskImage">If non-null, specifies a mask image that controls how this layer is blended onto the preceding one. See <see cref="Lumia.Imaging.Compositing.BlendEffect"/>.</param> /// <param name="targetArea">If non-empty, positions and scales the layer within the bounds of the preceding one. See <see cref="Lumia.Imaging.Compositing.BlendEffect"/>.</param> /// <returns>A layer style.</returns> public LayerStyle(BlendFunction blendFunction, double opacity, MaybeTask<IImageProvider> maskImage, Rect? targetArea = null) { BlendFunction = blendFunction; Opacity = opacity; TargetArea = targetArea; if (!maskImage.IsEmpty) { MaskResolver = context => maskImage; } else { MaskResolver = null; } }
public static extern bool UpdateLayeredWindow(IntPtr handle, IntPtr hdcDst, ref Point pptDst, ref Size pSize, IntPtr hDc, ref Point pptSrc, int crKey, ref BlendFunction pBlend, int dwFlags);
private void SetDefaultParameters() { CanRenderAtPreviewSize = true; m_globalAlpha = 0.5f; m_blendFunction = BlendFunction.Normal; }
void SaveRenderState(RenderState renderState) { pointSpriteEnable = renderState.PointSpriteEnable; pointSizeMax = renderState.PointSizeMax; alphaBlendEnable = renderState.AlphaBlendEnable; alphaBlendOperation = renderState.AlphaBlendOperation; sourceBlend = renderState.SourceBlend; destinationBlend = renderState.DestinationBlend; alphaTestEnable = renderState.AlphaTestEnable; alphaFunction = renderState.AlphaFunction; referenceAlpha = renderState.ReferenceAlpha; depthBufferEnable = renderState.DepthBufferEnable; depthBufferWriteEnable = renderState.DepthBufferWriteEnable; }
/// <summary> /// Converts an Ultraviolet BlendFunction value to the equivalent OpenGL value. /// </summary> /// <param name="fn">The Ultraviolet BlendFunction value to convert.</param> /// <returns>The converted OpenGL value.</returns> private static UInt32 GetBlendFunctionGL(BlendFunction fn) { switch (fn) { case BlendFunction.Add: return gl.GL_FUNC_ADD; case BlendFunction.Min: return gl.GL_MIN; case BlendFunction.Max: return gl.GL_MAX; case BlendFunction.ReverseSubtract: return gl.GL_FUNC_REVERSE_SUBTRACT; case BlendFunction.Subtract: return gl.GL_FUNC_SUBTRACT; } throw new NotSupportedException(); }
/// <summary> /// The GdiAlphaBlend function displays bitmaps that have transparent or semitransparent pixels. /// </summary> /// <param name="hdcDest">Handle to the destination device context.</param> /// <param name="nXOriginDest">Specifies the x-coordinate, in logical units, /// of the upper-left corner of the destination rectangle</param> /// <param name="nYOriginDest">Specifies the y-coordinate, in logical units, /// of the upper-left corner of the destination rectangle</param> /// <param name="nWidthDest">Specifies the width, in logical units, of the destination rectangle</param> /// <param name="nHeightDest">Specifies the height, in logical units, of the destination rectangle</param> /// <param name="hdcSrc">Handle to the source device context</param> /// <param name="nXOriginSrc">Specifies the x-coordinate, in logical units, of the upper-left corner of the source rectangle</param> /// <param name="nYOriginSrc">Specifies the y-coordinate, in logical units, of the upper-left corner of the source rectangle</param> /// <param name="nWidthSrc">Specifies the width, in logical units, of the source rectangle</param> /// <param name="nHeightSrc">Specifies the height, in logical units, of the source rectangle</param> /// <param name="blendFunction">Specifies the alpha-blending function for source and destination bitmaps, a global alpha value to be /// applied to the entire source bitmap, and format information for the source bitmap. The source and destination blend /// functions are currently limited to AC_SRC_OVER.</param> /// <returns>If the function succeeds, the return value is true. /// If the function fails, the return value is false.</returns> public static bool GdiAlphaBlend(IntPtr hdcDest, int nXOriginDest, int nYOriginDest, int nWidthDest, int nHeightDest, IntPtr hdcSrc, int nXOriginSrc, int nYOriginSrc, int nWidthSrc, int nHeightSrc, BlendFunction blendFunction) { return Native.GdiAlphaBlend(hdcDest, nXOriginDest, nYOriginDest, nWidthDest, nHeightDest, hdcSrc, nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc, blendFunction); }
/// <summary> /// Construct a layer style. /// </summary> /// <param name="blendFunction">Blend function to use when combining the result of this layer with the previous.</param> /// <param name="opacity">The opacity of the layer.</param> /// <param name="maskImageProviderResolver">A lazy resolve func that returns the <see cref="IImageProvider" /> based on context sensitive values such as source image size.</param> /// <param name="targetArea">If non-empty, positions and scales the layer within the bounds of the preceding one. See <see cref="Lumia.Imaging.Compositing.BlendEffect"/>.</param> /// <returns>A layer style.</returns> public LayerStyle(BlendFunction blendFunction, double opacity, Func<LayerContext, MaybeTask<IImageProvider>> maskImageProviderResolver, Rect? targetArea = null) { BlendFunction = blendFunction; Opacity = opacity; TargetArea = targetArea; MaskResolver = maskImageProviderResolver; }
public static void GLBlendEquationOES(int equ) { AlphaBlendFunction = (equ == 0x8006) ? BlendFunction.Add : BlendFunction.ReverseSubtract; }
private static extern int AlphaBlendCE(IntPtr hdcDest, int xDest, int yDest, int cxDest, int cyDest, IntPtr hdcSrc, int xSrc, int ySrc, int cxSrc, int cySrc, BlendFunction blendFunction);
void UpdateWindow() { IntPtr screenDC = NativeMethods.GetDC(IntPtr.Zero); IntPtr imageDC = NativeMethods.CreateCompatibleDC(screenDC); IntPtr gdiBitmap = IntPtr.Zero; IntPtr oldBitmap = IntPtr.Zero; try { gdiBitmap = captionedImage.GetHbitmap(Color.FromArgb(0)); //Get a GDI handle to the image. oldBitmap = NativeMethods.SelectObject(imageDC, gdiBitmap); //Select the image into the DC, and cache the old bitmap. Size size = captionedImage.Size; //Get the size and location of the form, as integers. Point location = this.Location; BlendFunction alphaInfo = new BlendFunction { SourceConstantAlpha = 255, AlphaFormat = 1 }; //This struct provides information about the opacity of the form. NativeMethods.UpdateLayeredWindow(Handle, screenDC, ref location, ref size, imageDC, ref Zero, 0, ref alphaInfo, UlwType.Alpha); } finally { NativeMethods.ReleaseDC(IntPtr.Zero, screenDC); //Release the Screen's DC. if (gdiBitmap != IntPtr.Zero) { //If we got a GDI bitmap, NativeMethods.SelectObject(imageDC, oldBitmap); //Select the old bitmap into the DC NativeMethods.DeleteObject(gdiBitmap); //Delete the GDI bitmap, } NativeMethods.DeleteDC(imageDC); //And delete the DC. } Invalidate(); }
public static extern bool AlphaBlendWin(IntPtr hdcDest, int nXOriginDest, int nYOriginDest, int nWidthDest, int nHeightDest, IntPtr hdcSrc, int nXOriginSrc, int nYOriginSrc, int nWidthSrc, int nHeightSrc, BlendFunction blendFunction);
public static BlendOperation ConvertBlendFunction(BlendFunction blendFunction) { // TODO: Binary compatible switch (blendFunction) { case BlendFunction.Add: return BlendOperation.Add; case BlendFunction.Subtract: return BlendOperation.Subtract; case BlendFunction.ReverseSubtract: return BlendOperation.ReverseSubtract; case BlendFunction.Max: return BlendOperation.Max; case BlendFunction.Min: return BlendOperation.Min; default: throw new ArgumentOutOfRangeException(); } }
public static extern bool AlphaBlend([In] IntPtr hdcDest, int xoriginDest, int yoriginDest, int wDest, int hDest, [In] IntPtr hdcSrc, int xoriginSrc, int yoriginSrc, int wSrc, int hSrc, BlendFunction ftn);
private BlendFunction CreateBlendFunction() { BlendFunction blend = new BlendFunction(); blend.BlendOp = AC_SRC_OVER; blend.BlendFlags = 0; blend.SourceConstantAlpha = opacity; blend.AlphaFormat = AC_SRC_ALPHA; return blend; }
public void SetBlendState(BlendState blendState) { bool newEnable = ( !( blendState.ColorSourceBlend == Blend.One && blendState.ColorDestinationBlend == Blend.Zero && blendState.AlphaSourceBlend == Blend.One && blendState.AlphaDestinationBlend == Blend.Zero ) ); if (newEnable != alphaBlendEnable) { alphaBlendEnable = newEnable; ToggleGLState(GLenum.GL_BLEND, alphaBlendEnable); } if (alphaBlendEnable) { if (blendState.BlendFactor != blendColor) { blendColor = blendState.BlendFactor; glBlendColor( blendColor.R / 255.0f, blendColor.G / 255.0f, blendColor.B / 255.0f, blendColor.A / 255.0f ); } if ( blendState.ColorSourceBlend != srcBlend || blendState.ColorDestinationBlend != dstBlend || blendState.AlphaSourceBlend != srcBlendAlpha || blendState.AlphaDestinationBlend != dstBlendAlpha ) { srcBlend = blendState.ColorSourceBlend; dstBlend = blendState.ColorDestinationBlend; srcBlendAlpha = blendState.AlphaSourceBlend; dstBlendAlpha = blendState.AlphaDestinationBlend; glBlendFuncSeparate( XNAToGL.BlendMode[(int) srcBlend], XNAToGL.BlendMode[(int) dstBlend], XNAToGL.BlendMode[(int) srcBlendAlpha], XNAToGL.BlendMode[(int) dstBlendAlpha] ); } if ( blendState.ColorBlendFunction != blendOp || blendState.AlphaBlendFunction != blendOpAlpha ) { blendOp = blendState.ColorBlendFunction; blendOpAlpha = blendState.AlphaBlendFunction; glBlendEquationSeparate( XNAToGL.BlendEquation[(int) blendOp], XNAToGL.BlendEquation[(int) blendOpAlpha] ); } } if (blendState.ColorWriteChannels != colorWriteEnable) { colorWriteEnable = blendState.ColorWriteChannels; glColorMask( (colorWriteEnable & ColorWriteChannels.Red) != 0, (colorWriteEnable & ColorWriteChannels.Green) != 0, (colorWriteEnable & ColorWriteChannels.Blue) != 0, (colorWriteEnable & ColorWriteChannels.Alpha) != 0 ); } /* FIXME: So how exactly do we factor in * COLORWRITEENABLE for buffer 0? Do we just assume that * the default is just buffer 0, and all other calls * update the other write masks afterward? Or do we * assume that COLORWRITEENABLE only touches 0, and the * other 3 buffers are left alone unless we don't have * EXT_draw_buffers2? * -flibit */ if (blendState.ColorWriteChannels1 != colorWriteEnable1) { colorWriteEnable1 = blendState.ColorWriteChannels1; glColorMaskIndexedEXT( 1, (colorWriteEnable1 & ColorWriteChannels.Red) != 0, (colorWriteEnable1 & ColorWriteChannels.Green) != 0, (colorWriteEnable1 & ColorWriteChannels.Blue) != 0, (colorWriteEnable1 & ColorWriteChannels.Alpha) != 0 ); } if (blendState.ColorWriteChannels2 != colorWriteEnable2) { colorWriteEnable2 = blendState.ColorWriteChannels2; glColorMaskIndexedEXT( 2, (colorWriteEnable2 & ColorWriteChannels.Red) != 0, (colorWriteEnable2 & ColorWriteChannels.Green) != 0, (colorWriteEnable2 & ColorWriteChannels.Blue) != 0, (colorWriteEnable2 & ColorWriteChannels.Alpha) != 0 ); } if (blendState.ColorWriteChannels3 != colorWriteEnable3) { colorWriteEnable3 = blendState.ColorWriteChannels3; glColorMaskIndexedEXT( 3, (colorWriteEnable3 & ColorWriteChannels.Red) != 0, (colorWriteEnable3 & ColorWriteChannels.Green) != 0, (colorWriteEnable3 & ColorWriteChannels.Blue) != 0, (colorWriteEnable3 & ColorWriteChannels.Alpha) != 0 ); } if (blendState.MultiSampleMask != multisampleMask && supportsMultisampling) { if (blendState.MultiSampleMask == -1) { glDisable(GLenum.GL_SAMPLE_MASK); } else { if (multisampleMask == -1) { glEnable(GLenum.GL_SAMPLE_MASK); } // FIXME: index...? -flibit glSampleMaski(0, (uint) blendState.MultiSampleMask); } multisampleMask = blendState.MultiSampleMask; } }
public static extern bool UpdateLayeredWindow(IntPtr hwnd, IntPtr hdcDst, IntPtr pptDst, IntPtr psize, IntPtr hdcSrc, IntPtr pprSrc, int crKey, ref BlendFunction pblend, int dwFlags);