internal void DrawPng(Operation mask, Image png, int x, int y) { if (this.AutoSize) { this.Resize(png.Width, png.Height); } CompositingMode oldMode = this.m_g.CompositingMode; try { switch (mask) { case Operation.Copy: this.m_g.DrawImageUnscaled(png, x, y); break; case Operation.SourceOver: this.m_g.CompositingMode = CompositingMode.SourceOver; this.m_g.DrawImageUnscaled(png, x, y); break; default: throw new NotSupportedException(); } } finally { this.m_g.CompositingMode = oldMode; } }
// Constructor, which saves away all of the important information. // We assume that the lock on the "graphics" object is held by the caller. internal GraphicsContainer(Graphics graphics) { // Push this container onto the stack. this.graphics = graphics; next = graphics.stackTop; graphics.stackTop = this; // Save the graphics state information. clip = graphics.Clip; if (clip != null) { clip = clip.Clone(); } compositingMode = graphics.CompositingMode; compositingQuality = graphics.CompositingQuality; interpolationMode = graphics.InterpolationMode; pageScale = graphics.PageScale; pageUnit = graphics.PageUnit; pixelOffsetMode = graphics.PixelOffsetMode; renderingOrigin = graphics.RenderingOrigin; smoothingMode = graphics.SmoothingMode; textContrast = graphics.TextContrast; textRenderingHint = graphics.TextRenderingHint; if (graphics.transform == null) { transform = null; } else { transform = Matrix.Clone(graphics.transform); } }
/// <summary> /// Draw a string with the given size /// </summary> /// <param name="text">The string to draw</param> /// <param name="size">The font size of the string</param> /// <param name="location">The location to draw the string at</param> /// <param name="brush">The brush to draw the string with</param> /// <param name="centered">Set to true if you want to draw the string around instead of left-down from the location</param> public void DrawSizedString(string text, int size, PointF location, Brush brush, bool transform = true, bool centered = false) { SmoothingMode tmpS = g.SmoothingMode; InterpolationMode tmpI = g.InterpolationMode; CompositingMode tmpM = g.CompositingMode; CompositingQuality tmpQ = g.CompositingQuality; PixelOffsetMode tmpP = g.PixelOffsetMode; g.SmoothingMode = SmoothingMode.AntiAlias; g.InterpolationMode = InterpolationMode.HighQualityBicubic; g.CompositingMode = CompositingMode.SourceOver; g.CompositingQuality = CompositingQuality.HighQuality; g.PixelOffsetMode = PixelOffsetMode.HighQuality; Font f = new Font("Tahoma", size); SizeF s = g.MeasureString(text, f); RectangleF r = new RectangleF(centered ? new PointF(location.X - s.Width / 2, location.Y - s.Height / 2) : location, s); if (transform) { r = w2s(r); } g.DrawString(text, f, brush, r); g.PixelOffsetMode = tmpP; g.CompositingQuality = tmpQ; g.CompositingMode = tmpM; g.InterpolationMode = tmpI; g.SmoothingMode = tmpS; }
internal GraphicsState(Graphics g, Matrix matrix, bool resetState) { _compositingMode = g.CompositingMode; _compositingQuality = g.CompositingQuality; _clip = g.Clip; _interpolationMode = g.InterpolationMode; _pageScale = g.PageScale; _pageUnit = g.PageUnit; _pixelOffsetMode = g.PixelOffsetMode; // FIXME: render orign is not implemented yet _renderingOrigin = g.RenderingOrigin; _smoothingMode = g.SmoothingMode; _transform = g.Transform; _textContrast = g.TextContrast; _textRenderingHint = g.TextRenderingHint; _clipMask = g.ClipMask; if (resetState) { ResetState(g, matrix); } }
internal GraphicsState(Graphics graphics, Matrix matrix, bool resetState) { _compositingMode = graphics.CompositingMode; _compositingQuality = graphics.CompositingQuality; _clip = graphics.ScaledClip; _baseClip = graphics.NativeObject.getClip(); _interpolationMode = graphics.InterpolationMode; _pageScale = graphics.PageScale; _pageUnit = graphics.PageUnit; _pixelOffsetMode = graphics.PixelOffsetMode; // FIXME: render orign is not implemented yet //_renderingOrigin = new Point( g.RenderingOrigin.X, g.RenderingOrigin.Y ); _smoothingMode = graphics.SmoothingMode; _transform = graphics.Transform; _baseTransform = graphics.BaseTransform; _textContrast = graphics.TextContrast; _textRenderingHint = graphics.TextRenderingHint; if (resetState) { ResetState(graphics, matrix); } }
// Constructor, which saves away all of the important information. // We assume that the lock on the "graphics" object is held by the caller. internal GraphicsContainer(Graphics graphics) { // Push this container onto the stack. this.graphics = graphics; next = graphics.stackTop; graphics.stackTop = this; // Save the graphics state information. clip = graphics.Clip; if(clip != null) { clip = clip.Clone(); } compositingMode = graphics.CompositingMode; compositingQuality = graphics.CompositingQuality; interpolationMode = graphics.InterpolationMode; pageScale = graphics.PageScale; pageUnit = graphics.PageUnit; pixelOffsetMode = graphics.PixelOffsetMode; renderingOrigin = graphics.RenderingOrigin; smoothingMode = graphics.SmoothingMode; textContrast = graphics.TextContrast; textRenderingHint = graphics.TextRenderingHint; if (graphics.transform == null) { transform = null; } else { transform = Matrix.Clone(graphics.transform); } }
internal void CopyFrom(Layer sl, Operation mask, int srcx, int srcy, int srcwidth, int srcheight, int dstx, int dsty) { sl.m_g.Flush(FlushIntention.Sync); if (this.AutoSize) { //this.Resize(png.Width, png.Height); } Rectangle srcRect = new Rectangle(srcx, srcy, srcwidth, srcheight); Rectangle destRect = new Rectangle(dstx, dsty, srcwidth, srcheight); CompositingMode oldMode = this.m_g.CompositingMode; try { switch (mask) { case Operation.Copy: this.m_g.DrawImage(sl.m_bmp, srcRect: srcRect, destRect: destRect, srcUnit: GraphicsUnit.Pixel); break; case Operation.SourceOver: this.m_g.CompositingMode = CompositingMode.SourceOver; this.m_g.DrawImage(sl.m_bmp, srcRect: srcRect, destRect: destRect, srcUnit: GraphicsUnit.Pixel); break; default: throw new NotSupportedException(); } } finally { this.m_g.CompositingMode = oldMode; } }
protected AppearanceBase() { this.m_layer = 0; this.m_lineMode = (LineMode)null; this.m_polygonMode = (PolygonMode)null; this.m_compositingMode = (CompositingMode)null; }
/// <summary> /// Optimize the paint environment and paint the platform /// </summary> /// <param name="e"></param> public override void OnPaint(PaintEventArgs e) { CompositingMode c = e.Graphics.CompositingMode; e.Graphics.CompositingMode = CompositingMode.SourceCopy; base.OnPaint(e); e.Graphics.CompositingMode = c; }
/// <summary> /// Returns a Color that represents the blend of the two provided background and foreground colors /// </summary> /// <param name="backColor">The background color to blend</param> /// <param name="foreColor">The foreground color to blend</param> /// <param name="compositingMode"></param> /// <returns>The blend result of the two colors</returns> public Color BlendColors(Color backColor, Color foreColor, CompositingMode compositingMode) { if (compositingMode == CompositingMode.SourceCopy) { return(foreColor); } return(Utilities.FlattenColor(backColor, foreColor)); }
public ResizeImage(Size newSize) { NewSize = newSize; InterpolationMode = InterpolationMode.NearestNeighbor; GraphicsUnit = GraphicsUnit.Pixel; SmoothingMode = SmoothingMode.None; CompositingMode = CompositingMode.SourceOver; CompositingQuality = CompositingQuality.HighSpeed; PixelOffsetMode = PixelOffsetMode.None; }
/// <summary> /// Initializes a new instance of the SelectionUndoTask class /// </summary> /// <param name="targetBitmap">The target bitmap for the undo task</param> /// <param name="selectionBitmap">The selection bitmap</param> /// <param name="originalSlice">The original image slice before a Move operation was made</param> /// <param name="selectionStartArea">The area that the selection started at</param> /// <param name="area">The area of the affected SelectionUndoTask</param> /// <param name="operationType">The operation type of this SelectionUndoTask</param> /// <param name="compositingMode">The compositing mode for the operation</param> public SelectionUndoTask(Bitmap targetBitmap, Bitmap selectionBitmap, Bitmap originalSlice, Rectangle selectionStartArea, Rectangle area, SelectionOperationType operationType, CompositingMode compositingMode) { _targetbitmap = targetBitmap; _selectionBitmap = (Bitmap)selectionBitmap.Clone(); _originalSlice = (Bitmap)originalSlice?.Clone(); _selectionStartArea = selectionStartArea; _area = area; _operationType = operationType; _compositingMode = compositingMode; }
public PostEffects() { this.m_viewportX = 0; this.m_viewportY = 0; this.m_viewportW = 0; this.m_viewportH = 0; this.m_postEffectsWorld = (World)null; this.m_postEffectsCompositingMode = (CompositingMode)null; this.m_vertexBuffer = (VertexBuffer)null; float[] bias = (float[])null; Appearance appearance = new Appearance(); this.m_postEffectsCompositingMode = new CompositingMode(); this.m_postEffectsCompositingMode.setAlphaThreshold(0.0f); this.m_postEffectsCompositingMode.setDepthTestEnable(false); this.m_postEffectsCompositingMode.setDepthWriteEnable(false); appearance.setCompositingMode(this.m_postEffectsCompositingMode); VertexArray arr = new VertexArray(4, 3, 2); short[] src = new short[12] { (short)-1, (short)-1, (short)0, (short)1, (short)-1, (short)0, (short)-1, (short)1, (short)0, (short)1, (short)1, (short)0 }; arr.set(0, 4, src); this.m_vertexBuffer = new VertexBuffer(); this.m_vertexBuffer.setPositions(arr, 1f, bias); Mesh mesh = new Mesh(this.m_vertexBuffer, (IndexBuffer) new TriangleStripArray(0, new int[1] { 4 }), appearance); this.m_postEffectsWorld = new World(); Camera camera = new Camera(); camera.setParallel(1f, 1f, -1f, 1f); this.m_postEffectsWorld.addChild((Node)camera); this.m_postEffectsWorld.setActiveCamera(camera); Background background = new Background(); background.setColorClearEnable(false); background.setDepthClearEnable(false); this.m_postEffectsWorld.setBackground(background); this.m_postEffectsWorld.addChild((Node)mesh); }
//----------------------------------------------------- public void SelectDefault() { this.CompositingMode = CompositingMode.SourceCopy; this.CompositingQuality = CompositingQuality.Default; this.InterpolationMode = InterpolationMode.Default; this.PixelOffsetMode = PixelOffsetMode.Default; this.SmoothingMode = SmoothingMode.Default; this.TextRenderingHint = TextRenderingHint.SystemDefault; this.TextContrast = 4; return; }
//----------------------------------------------------- public void CopyFrom(Graphics Graphics_in) { this.CompositingMode = Graphics_in.CompositingMode; this.CompositingQuality = Graphics_in.CompositingQuality; this.InterpolationMode = Graphics_in.InterpolationMode; this.PixelOffsetMode = Graphics_in.PixelOffsetMode; this.SmoothingMode = Graphics_in.SmoothingMode; this.TextRenderingHint = Graphics_in.TextRenderingHint; this.TextContrast = Graphics_in.TextContrast; return; }
/// <summary> /// A custom version of Control.DrawToBitmap based on mscorlib 4.0.0.0. /// Functions very similarly, but uses CompositingQuality.HighQuality, /// InterpolationMode.HighQualityBicubic, SmoothingMode.HighQuality, /// CompositingMode.SourceCopy, /// It also does not pass the PRF_ERASEBKGND flag, assuming the destBitmap /// to be ready to draw to. /// As well, can't call CreateControl() if handle is not created, so the /// user should do that first. (Check control.IsHandleCreated) /// </summary> /// <param name="control">The control to draw.</param> /// <param name="destBitmap">The bitmap to render the control to.</param> /// <param name="targetBounds">The bounds of the bitmap to draw in.</param> public static void DrawToBitmapHighQuality(this Control control, Bitmap destBitmap, Rectangle targetBounds) { if (destBitmap == null) { throw new ArgumentNullException(nameof(destBitmap)); } if (targetBounds.Width <= 0 || targetBounds.Height <= 0 || targetBounds.X < 0 || targetBounds.Y < 0) { throw new ArgumentException($"{nameof(targetBounds)} must have valid bounds.", nameof(targetBounds)); } if (!control.IsHandleCreated) { throw new ArgumentException("control must have it's handle created first. Try calling control.CreateControl() if IsHandleCreated is false."); } CompositingMode compositingMode = CompositingMode.SourceCopy; CompositingQuality compostingQuality = CompositingQuality.HighQuality; InterpolationMode interpolationMode = InterpolationMode.HighQualityBicubic; SmoothingMode smoothingMode = SmoothingMode.HighQuality; int nWidth = Min(control.Width, targetBounds.Width); int nHeight = Min(control.Height, targetBounds.Height); using var tempBitmap = new Bitmap(nWidth, nHeight, destBitmap.PixelFormat); using var tempGdi = Graphics.FromImage(tempBitmap); tempGdi.CompositingQuality = compostingQuality; tempGdi.InterpolationMode = interpolationMode; tempGdi.SmoothingMode = smoothingMode; tempGdi.CompositingMode = compositingMode; IntPtr hdc = tempGdi.GetHdc(); DrawingOptions drawingOptions = DrawingOptions.PRF_NONCLIENT | DrawingOptions.PRF_CLIENT | //Native.DrawingOptions.PRF_ERASEBKGND | DrawingOptions.PRF_CHILDREN; _ = SendMessage(new HandleRef(control, control.Handle), WM.PRINT, hdc, (IntPtr)drawingOptions); using var targetGdi = Graphics.FromImage(destBitmap); targetGdi.CompositingMode = compositingMode; targetGdi.CompositingQuality = compostingQuality; targetGdi.InterpolationMode = interpolationMode; targetGdi.SmoothingMode = smoothingMode; IntPtr hdc2 = targetGdi.GetHdc(); BitBlt(new HandleRef(targetGdi, hdc2), targetBounds.X, targetBounds.Y, nWidth, nHeight, new HandleRef(tempGdi, hdc), 0, 0, (int)TernaryRasterOperations.SRCCOPY); targetGdi.ReleaseHdcInternal(hdc2); tempGdi.ReleaseHdcInternal(hdc); }
static public System.Drawing.Drawing2D.CompositingMode ToGdiCompositionMode(this CompositingMode mode) { switch (mode) { case CompositingMode.SourceCopy: return(System.Drawing.Drawing2D.CompositingMode.SourceCopy); default: return(System.Drawing.Drawing2D.CompositingMode.SourceOver); } }
protected override void duplicateTo(ref Object3D ret) { base.duplicateTo(ref ret); CompositingMode compositingMode = (CompositingMode)ret; compositingMode.setBlending(this.getBlending()); compositingMode.setBlender(this.getBlender()); compositingMode.setAlphaThreshold(this.getAlphaThreshold()); compositingMode.setColorWriteEnable(this.isColorWriteEnabled()); compositingMode.setDepthWriteEnable(this.isDepthWriteEnabled()); compositingMode.setDepthTestEnable(this.isDepthTestEnabled()); compositingMode.setDepthOffsetx(this.getDepthOffsetFactorx(), this.getDepthOffsetUnitsx()); }
// Constructor. protected ToolkitGraphicsBase(IToolkit toolkit) { this.toolkit = toolkit; clip = null; compositingMode = CompositingMode.SourceOver; compositingQuality = CompositingQuality.Default; interpolationMode = InterpolationMode.Default; pixelOffsetMode = PixelOffsetMode.Default; renderingOrigin = new Point(0, 0); smoothingMode = SmoothingMode.Default; textContrast = 4; textRenderingHint = TextRenderingHint.SystemDefault; dirtyFlags = DirtyFlags.All; }
private void DrawSelectionTinting(Graphics g) { if (unSelection == null) { return; } CompositingMode oldCM = g.CompositingMode; g.CompositingMode = CompositingMode.SourceOver; g.FillRegion(tintbrush, unSelection.GetRegionReadOnly()); g.CompositingMode = oldCM; }
/// <summary> /// Blends two colors together with an alpha erase mode /// </summary> /// <param name="backColor">The back color to blend</param> /// <param name="foreColor">The fore color to blend</param> /// <param name="blendCompositingMode">The compositing mode to blend with</param> /// <returns>The two colors, blended with an alpha erase mode</returns> public Color BlendColors(Color backColor, Color foreColor, CompositingMode blendCompositingMode) { if (backColor.A == 0) { return(backColor); } if (foreColor.A == 0) { return(Color.FromArgb(0, 0, 0, 0)); } float newAlpha = (((float)backColor.A / 255) * (1 - (float)foreColor.A / 255)); return(Color.FromArgb((int)(newAlpha * 255), backColor)); }
private void RenderGradient(Surface surface, PdnRegion clipRegion, CompositingMode compositingMode, PointF startPointF, ColorBgra startColor, PointF endPointF, ColorBgra endColor) { GradientRenderer gr = AppEnvironment.GradientInfo.CreateGradientRenderer(); gr.StartColor = startColor; gr.EndColor = endColor; gr.StartPoint = startPointF; gr.EndPoint = endPointF; gr.AlphaBlending = (compositingMode == CompositingMode.SourceOver); gr.BeforeRender(); Rectangle[] oldRois = clipRegion.GetRegionScansReadOnlyInt(); Rectangle[] newRois; if (oldRois.Length == 1) { newRois = new Rectangle[Processor.LogicalCpuCount]; Utility.SplitRectangle(oldRois[0], newRois); } else { newRois = oldRois; } RenderContext rc = new RenderContext(); rc.surface = surface; rc.rois = newRois; rc.renderer = gr; WaitCallback wc = new WaitCallback(rc.Render); for (int i = 0; i < Processor.LogicalCpuCount; ++i) { if (i == Processor.LogicalCpuCount - 1) { wc(BoxedConstants.GetInt32(i)); } else { PaintDotNet.Threading.ThreadPool.Global.QueueUserWorkItem(wc, BoxedConstants.GetInt32(i)); } } PaintDotNet.Threading.ThreadPool.Global.Drain(); }
private void DrawSelectionTinting(Graphics g, PdnGraphicsPath outline) { if (outline == null) { return; } CompositingMode oldCM = g.CompositingMode; g.CompositingMode = CompositingMode.SourceOver; SmoothingMode oldSM = g.SmoothingMode; g.SmoothingMode = SmoothingMode.AntiAlias; PixelOffsetMode oldPOM = g.PixelOffsetMode; g.PixelOffsetMode = PixelOffsetMode.None; Region oldClipRegion = null; RectangleF outlineBounds = outline.GetBounds(); if (outlineBounds.Left < 0 || outlineBounds.Top < 0 || outlineBounds.Right >= this.SourceSize.Width || outlineBounds.Bottom >= this.SourceSize.Height) { oldClipRegion = g.Clip; Region newClipRegion = oldClipRegion.Clone(); newClipRegion.Intersect(new Rectangle(0, 0, this.SourceSize.Width, this.SourceSize.Height)); g.Clip = newClipRegion; newClipRegion.Dispose(); } g.FillPath(InteriorBrush, outline); if (oldClipRegion != null) { g.Clip = oldClipRegion; oldClipRegion.Dispose(); } g.PixelOffsetMode = oldPOM; g.SmoothingMode = oldSM; g.CompositingMode = oldCM; }
public ImageUploader(HttpPostedFileBase file) : base(file) { try { _image = new Bitmap(file.InputStream); } catch (ArgumentException) { throw new HttpException(404, "Photo not found."); } Width = _image.Width; Height = _image.Height; Quality = CompositingQuality.HighSpeed; Interpolation = InterpolationMode.Default; Mode = CompositingMode.SourceCopy; }
/// <summary> /// Paint the background on the screen and repeat it. /// </summary> /// <param name="e">The paint environment.</param> public override void OnPaint(PaintEventArgs e) { Graphics g = e.Graphics; CompositingMode c = g.CompositingMode; g.CompositingMode = CompositingMode.SourceCopy; if (this.GetX() < -this.GetWidth()) { this.SetX(this.GetX() + this.GetWidth()); } if (this.GetX() >= 0) { this.SetX(-this.GetWidth()); } g.DrawImage(this.GetImage(), new Point(this.GetX(), this.GetY())); g.DrawImage(this.GetImage(), new Point(this.GetX() + this.GetWidth(), this.GetY())); g.CompositingMode = c; }
public new void Dispose() { this.m_world = (World)null; this.m_group = (Group)null; this.m_camera = (Camera)null; this.m_polygonMode = (PolygonMode)null; this.m_compModeReplace = (CompositingMode)null; this.m_compModeAlpha = (CompositingMode)null; this.m_compModeAlphaAdd = (CompositingMode)null; this.m_compModeModulate = (CompositingMode)null; for (int index1 = 0; index1 < this.m_instances.Length; ++index1) { for (int index2 = 0; index2 < this.m_instances[index1].Length; ++index2) { this.m_instances[index1][index2] = (Node)null; } } }
/// <summary> /// Initializes a new instance of the EllipseUndoTask class /// </summary> /// <param name="targetBitmap">The target bitmap of this EllipseUndoTask</param> /// <param name="firstColor">The first color to use when drawing the ellipse</param> /// <param name="secondColor">The second color to use when drawing the ellipse</param> /// <param name="area">The area of the ellipse to draw</param> /// <param name="compositingMode">The CompositingMode to use when drawing the ellipse</param> /// <param name="fillMode">The fill mode for this ellipse operation</param> public EllipseUndoTask(Bitmap targetBitmap, Color firstColor, Color secondColor, Rectangle area, CompositingMode compositingMode, OperationFillMode fillMode) { _firstColor = firstColor; _secondColor = secondColor; _area = area; _bitmap = targetBitmap; _compositingMode = compositingMode; _fillMode = fillMode; // Take the image slide now _originalSlice = new Bitmap(area.Width + 1, area.Height + 1); Graphics g = Graphics.FromImage(_originalSlice); g.DrawImage(_bitmap, new Point(-area.X, -area.Y)); g.Flush(); g.Dispose(); }
public static Bitmap GdiResize(Image photo, int width, int height, InterpolationMode interpolationMode = InterpolationMode.HighQualityBicubic, SmoothingMode smoothingMode = SmoothingMode.HighQuality, PixelOffsetMode pixelMode = PixelOffsetMode.HighQuality, CompositingQuality compositingQuality = CompositingQuality.HighQuality, CompositingMode compositingMode = CompositingMode.SourceOver ) { var resized = new Bitmap(width, height); using (var graphics = Graphics.FromImage(resized)) { graphics.CompositingQuality = compositingQuality; graphics.InterpolationMode = interpolationMode; graphics.CompositingMode = compositingMode; graphics.SmoothingMode = smoothingMode; graphics.PixelOffsetMode = pixelMode; graphics.DrawImage(photo, 0, 0, width, height); } return resized; }
public void Slide(int ox, int oy) { // this optimization technique creates the illusion of moving left or up. Bitmap image = new Bitmap(_edit_layer); if (ox < 0) { ox += _image.Width; } if (oy < 0) { oy += _image.Height; } int w = _image.Width - ox, h = _image.Height - oy; CompositingMode oldMode = _edit_canvas.CompositingMode; _edit_canvas.CompositingMode = CompositingMode.SourceCopy; _edit_canvas.DrawImageUnscaled(image, ox, oy); if (ox > 0) { Rectangle right = new Rectangle(w, 0, ox, h); _edit_canvas.DrawImageUnscaled(image.Clone(right, PixelFormat.Format32bppPArgb), 0, oy); } if (oy > 0) { Rectangle bottom = new Rectangle(0, h, w, oy); _edit_canvas.DrawImageUnscaled(image.Clone(bottom, PixelFormat.Format32bppPArgb), ox, 0); } if (ox > 0 && oy > 0) { Rectangle lr = new Rectangle(w, h, ox, oy); _edit_canvas.DrawImageUnscaled(image.Clone(lr, PixelFormat.Format32bppPArgb), 0, 0); } image.Dispose(); _edit_canvas.CompositingMode = oldMode; _start_anchor = Point.Empty; _end_anchor.X = _image.Width - 1; _end_anchor.Y = _image.Height - 1; }
/// <summary> /// Initializes this Paint Tool /// </summary> /// <param name="targetPictureBox">The picture box to initialize the paint tool on</param> public override void Initialize(ImageEditPanel.InternalPictureBox targetPictureBox) { base.Initialize(targetPictureBox); pictureBox = targetPictureBox; lastMousePosition = new Point(); pencilOperation = new PencilPaintOperation(targetPictureBox.Bitmap); UpdatePen(); ChangeBitmap(targetPictureBox.Bitmap); currentTraceBitmap = new Bitmap(targetPictureBox.Bitmap.Width, targetPictureBox.Bitmap.Height); CompositingMode = targetPictureBox.OwningPanel.DefaultCompositingMode; visible = true; Loaded = true; }
public static Bitmap GdiResize(Image photo, int width, int height, InterpolationMode interpolationMode = InterpolationMode.HighQualityBicubic, SmoothingMode smoothingMode = SmoothingMode.HighQuality, PixelOffsetMode pixelMode = PixelOffsetMode.HighQuality, CompositingQuality compositingQuality = CompositingQuality.HighQuality, CompositingMode compositingMode = CompositingMode.SourceOver ) { var resized = new Bitmap(width, height); using (var graphics = Graphics.FromImage(resized)) { graphics.CompositingQuality = compositingQuality; graphics.InterpolationMode = interpolationMode; graphics.CompositingMode = compositingMode; graphics.SmoothingMode = smoothingMode; graphics.PixelOffsetMode = pixelMode; graphics.DrawImage(photo, 0, 0, width, height); } return(resized); }
private void SetCompositingMode(CompositingMode mode, bool force) { if (!force && currentMode == mode) { return; } switch (mode) { case CompositingMode.AlphaBlending: device.SetRenderState(RenderState.AlphaBlendEnable, true); device.SetRenderState(RenderState.BlendOperation, BlendOperation.Add); device.SetRenderState(RenderState.SourceBlend, Blend.SourceAlpha); device.SetRenderState(RenderState.DestinationBlend, Blend.InverseSourceAlpha); break; case CompositingMode.Additive: device.SetRenderState(RenderState.AlphaBlendEnable, true); device.SetRenderState(RenderState.BlendOperation, BlendOperation.Add); device.SetRenderState(RenderState.SourceBlend, Blend.One); device.SetRenderState(RenderState.DestinationBlend, Blend.One); break; case CompositingMode.Modulate: device.SetRenderState(RenderState.AlphaBlendEnable, true); device.SetRenderState(RenderState.BlendOperation, BlendOperation.Add); device.SetRenderState(RenderState.SourceBlend, Blend.Zero); device.SetRenderState(RenderState.DestinationBlend, Blend.SourceColor); break; default: device.SetRenderState(RenderState.AlphaBlendEnable, false); break; } currentMode = mode; }
internal GraphicsState(Graphics graphics, Matrix matrix, bool resetState) { _compositingMode = graphics.CompositingMode; _compositingQuality = graphics.CompositingQuality; _clip = graphics.ScaledClip; _baseClip = graphics.NativeObject.getClip(); _interpolationMode = graphics.InterpolationMode; _pageScale = graphics.PageScale; _pageUnit = graphics.PageUnit; _pixelOffsetMode = graphics.PixelOffsetMode; // FIXME: render orign is not implemented yet //_renderingOrigin = new Point( g.RenderingOrigin.X, g.RenderingOrigin.Y ); _smoothingMode = graphics.SmoothingMode; _transform = graphics.Transform; _baseTransform = graphics.BaseTransform; _textContrast = graphics.TextContrast; _textRenderingHint = graphics.TextRenderingHint; if (resetState) ResetState(graphics, matrix); }
internal static extern GpStatus GdipGetCompositingMode(GpGraphics graphics, out CompositingMode compositingMode);
public static extern GpStatus GdipSetCompositingMode(GpGraphics graphics, CompositingMode compositingMode);
public void saveGraphics(NetGraphics netG) { if (netG == null ) { return; } if (netG.g != null ) { this.Transform = netG.g.Transform; this.Clip = netG.g.Clip; this.SmoothingMode = netG.g.SmoothingMode; this.PixelOffsetMode = netG.g.PixelOffsetMode; this.TextRenderingHint = netG.g.TextRenderingHint; this.InterpolationMode = netG.g.InterpolationMode; this.CompositingMode = netG.g.CompositingMode; savedGraphics = true; } if (netG.pen != null && netG.brush != null) { pen = (Pen)netG.pen.Clone(); brush = (Brush)netG.brush.Clone(); } }
public string ToCompositingOperation(CompositingMode mode) { switch (mode) { case CompositingMode.Clear: return "clear"; case CompositingMode.Source: return "src"; case CompositingMode.Destination: return "dst"; case CompositingMode.SourceOver: return "src-over"; case CompositingMode.DestinationOver: return "dst-over"; case CompositingMode.SourceIn: return "src-in"; case CompositingMode.DestinationIn: return "dst-in"; case CompositingMode.SourceOut: return "src-out"; case CompositingMode.DestinationOut: return "dst-out"; case CompositingMode.SourceATop: return "src-atop"; case CompositingMode.DestinationATop: return "dst-atop"; case CompositingMode.Xor: return "xor"; case CompositingMode.Plus: return "plus"; case CompositingMode.Minus: return "minus"; case CompositingMode.Multiply: return "multiply"; case CompositingMode.Screen: return "screen"; case CompositingMode.Overlay: return "overlay"; case CompositingMode.Darken: return "darken"; case CompositingMode.Lighten: return "lighten"; case CompositingMode.ColorDodge: return "color-dodge"; case CompositingMode.ColorBurn: return "color-burn"; case CompositingMode.HardLight: return "hard-light"; case CompositingMode.SoftLight: return "soft-light"; case CompositingMode.Difference: return "difference"; case CompositingMode.Exclusion: return "exclusion"; case CompositingMode.Contrast: return "contrast"; case CompositingMode.Invert: return "invert"; case CompositingMode.InvertRGB: return "invert-rgb"; case CompositingMode.GrainMerge: return "grain-merge"; case CompositingMode.GrainExtract: return "grain-extract"; case CompositingMode.Hue: return "hue"; case CompositingMode.Saturation: return "saturation"; case CompositingMode.Color: return "color"; case CompositingMode.Value: return "value"; default: return "src-over"; } }
internal static extern Status GdipGetCompositingMode(IntPtr graphics, out CompositingMode compositingMode);