public BitmapLayer(int width, int height, ColorBgra fillColor) : base(width, height) { this.surface = new Surface(width, height); // clear to see-through white, 0x00ffffff this.Surface.Clear(fillColor); this.properties = new BitmapLayerProperties(UserBlendOps.CreateDefaultBlendOp()); }
private void CompileBlendOp() { bool isDefaultOp = (properties.blendOp.GetType() == UserBlendOps.GetDefaultBlendOp()); if (this.Opacity == 255) { this.compiledBlendOp = properties.blendOp; } else { this.compiledBlendOp = properties.blendOp.CreateWithOpacity(this.Opacity); } }
/// <summary> /// Creates a new BitmapLayer of the same size as the given Surface, and either /// copies the pixels of the given Surface or takes ownership of it. /// </summary> /// <param name="surface">The Surface.</param> /// <param name="takeOwnership"> /// true to take ownership of the surface (make sure to Dispose() it yourself), or /// false to copy its pixels /// </param> public BitmapLayer(Surface surface, bool takeOwnership) : base(surface.Width, surface.Height) { if (takeOwnership) { this.surface = surface; } else { this.surface = surface.Clone(); } this.properties = new BitmapLayerProperties(UserBlendOps.CreateDefaultBlendOp()); }
public BitmapLayerPropertiesDialog() { // This call is required by the Windows Form Designer. InitializeComponent(); this.blendingHeader.Text = PdnResources.GetString("BitmapLayerPropertiesDialog.BlendingHeader.Text"); this.blendModeLabel.Text = PdnResources.GetString("BitmapLayerPropertiesDialog.BlendModeLabel.Text"); this.opacityLabel.Text = PdnResources.GetString("BitmapLayerPropertiesDialog.OpacityLabel.Text"); // populate the blendOpComboBox with all the blend modes they're allowed to use foreach (Type type in UserBlendOps.GetBlendOps()) { blendOpComboBox.Items.Add(UserBlendOps.CreateBlendOp(type)); } }
public void Render(RenderArgs args, Rectangle[] roi, int startIndex, int length, bool clearBackground) { int startLayerIndex; if (clearBackground) { BitmapLayer layer0; layer0 = this.layers[0] as BitmapLayer; // Special case: if the first layer is a visible BitmapLayer with full opacity using // the default blend op, we can just copy the pixels straight over if (layer0 != null && layer0.Visible && layer0.Opacity == 255 && layer0.BlendOp.GetType() == UserBlendOps.GetDefaultBlendOp()) { args.Surface.CopySurface(layer0.Surface, roi, startIndex, length); startLayerIndex = 1; } else { ClearBackground(args.Surface, roi, startIndex, length); startLayerIndex = 0; } } else { startLayerIndex = 0; } for (int i = startLayerIndex; i < this.layers.Count; ++i) { Layer layer = (Layer)this.layers[i]; if (layer.Visible) { layer.RenderUnchecked(args, roi, startIndex, length); } } }