Here are the examples of the csharp api class System.Drawing.Graphics.Save() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
98 Examples
0
1. Example
Project: SvgNet
Source File: GDIGraphics.cs
Source File: GDIGraphics.cs
public GraphicsState Save() => _g.Save();
0
2. Example
Project: referencesource
Source File: GdiGraphics.cs
Source File: GdiGraphics.cs
public GraphicsState Save() { return _graphics.Save(); }
0
3. Example
Project: DotSpatial
Source File: PointSymbolizer.cs
Source File: PointSymbolizer.cs
public void Draw(Graphics g, double scaleSize) { GraphicsState s = g.Save(); if (Smoothing) { g.SmoothingMode = SmoothingMode.AntiAlias; g.TextRenderingHint = TextRenderingHint.AntiAlias; } else { g.SmoothingMode = SmoothingMode.None; g.TextRenderingHint = TextRenderingHint.SystemDefault; } foreach (ISymbol symbol in Symbols) { symbol.Draw(g, scaleSize); } g.Restore(s); // Changed by jany_ (2015-07-06) remove smoothing because we might not want to smooth whatever is drawn with g afterwards }
0
4. Example
Project: OpenLiveWriter
Source File: GraphicsHelper.cs
Source File: GraphicsHelper.cs
public static IDisposable Offset(Graphics g, int x, int y) { GraphicsState graphicsState = g.Save(); g.TranslateTransform(x, y); return new GraphicsStateRestorer(g, graphicsState); }
0
5. Example
Project: NGraphics
Source File: SystemDrawingPlatform.cs
Source File: SystemDrawingPlatform.cs
public void SaveState () { var s = graphics.Save (); stateStack.Push (s); }
0
6. Example
Project: Cyotek.Windows.Forms.ImageBox
Source File: ScaledAdornmentsDemoForm.cs
Source File: ScaledAdornmentsDemoForm.cs
private void imageBox_Paint(object sender, PaintEventArgs e) { Graphics g; GraphicsState originalState; Size scaledSize; Size originalSize; Size drawSize; bool scaleAdornmentSize; scaleAdornmentSize = scaleAdornmentsCheckBox.Checked; g = e.Graphics; originalState = g.Save(); // Work out the size of the marker graphic according to the current zoom level originalSize = _markerImage.Size; scaledSize = imageBox.GetScaledSize(originalSize); drawSize = scaleAdornmentSize ? scaledSize : originalSize; foreach (Point landmark in _landmarks) { Point location; // Work out the location of the marker graphic according to the current zoom level and scroll offset location = imageBox.GetOffsetPoint(landmark); // adjust the location so that the image is displayed above the location and centered to it location.Y -= drawSize.Height; location.X -= drawSize.Width >> 1; // Draw the marker g.InterpolationMode = InterpolationMode.NearestNeighbor; g.DrawImage(_markerImage, new Rectangle(location, drawSize), new Rectangle(Point.Empty, originalSize), GraphicsUnit.Pixel); } g.Restore(originalState); }
0
7. Example
Project: fuckshadows-windows
Source File: MenuViewController.cs
Source File: MenuViewController.cs
private Bitmap AddBitmapOverlay(Bitmap original, params Bitmap[] overlays) { Bitmap bitmap = new Bitmap(original.Width, original.Height, PixelFormat.Format64bppArgb); Graphics canvas = Graphics.FromImage(bitmap); canvas.DrawImage(original, new Point(0, 0)); foreach (Bitmap overlay in overlays) { canvas.DrawImage(new Bitmap(overlay, original.Size), new Point(0, 0)); } canvas.Save(); return bitmap; }
0
8. Example
Project: mbunit-v3
Source File: OverlayManager.cs
Source File: OverlayManager.cs
public void PaintOverlays(OverlayPaintRequest request) { if (request == null) throw new ArgumentNullException("request"); foreach (Overlay overlay in overlays) { GraphicsState originalState = request.Graphics.Save(); try { overlay.Paint(request); } finally { request.Graphics.Restore(originalState); } } }
0
9. Example
Project: Toxy
Source File: QRCoder.cs
Source File: QRCoder.cs
public Bitmap GetGraphic(int pixelsPerModule, Color darkColor, Color lightColor) { var size = ModuleMatrix.Count * pixelsPerModule; Bitmap bmp = new Bitmap(size, size); Graphics gfx = Graphics.FromImage(bmp); for (int x = 0; x < size; x = x + pixelsPerModule) { for (int y = 0; y < size; y = y + pixelsPerModule) { var module = ModuleMatrix[(y + pixelsPerModule) / pixelsPerModule - 1][(x + pixelsPerModule) / pixelsPerModule - 1]; if (module) { gfx.FillRectangle(new SolidBrush(darkColor), new Rectangle(x, y, pixelsPerModule, pixelsPerModule)); } else gfx.FillRectangle(new SolidBrush(lightColor), new Rectangle(x, y, pixelsPerModule, pixelsPerModule)); } } gfx.Save(); return bmp; }
0
10. Example
Project: ColorWanted
Source File: MainForm.cs
Source File: MainForm.cs
private void DrawPreview(Point pt) { var size = previewForm.Height / 11; /n ..... /n //View Source file for more details /n }
0
11. Example
Project: PKHeX
Source File: QRCode.cs
Source File: QRCode.cs
public Bitmap GetGraphic(int pixelsPerModule, Color darkColor, Color lightColor, bool drawQuietZones = true) { var size = (this.QrCodeData.ModuleMatrix.Count - (drawQuietZones ? 0 : 8)) * pixelsPerModule; var offset = drawQuietZones ? 0 : 4 * pixelsPerModule; var bmp = new Bitmap(size, size); var gfx = Graphics.FromImage(bmp); for (var x = 0; x < size + offset; x = x + pixelsPerModule) { for (var y = 0; y < size + offset; y = y + pixelsPerModule) { var module = this.QrCodeData.ModuleMatrix[(y + pixelsPerModule)/pixelsPerModule - 1][(x + pixelsPerModule)/pixelsPerModule - 1]; if (module) { gfx.FillRectangle(new SolidBrush(darkColor), new Rectangle(x - offset, y - offset, pixelsPerModule, pixelsPerModule)); } else { gfx.FillRectangle(new SolidBrush(lightColor), new Rectangle(x - offset, y - offset, pixelsPerModule, pixelsPerModule)); } } } gfx.Save(); return bmp; }
0
12. Example
Project: referencesource
Source File: ChartWebControl.cs
Source File: ChartWebControl.cs
public void Paint(Graphics graphics, Rectangle position) { // Change chart size to fit the new position int oldWidth = this.chartPicture.Width; int oldHeight = this.chartPicture.Height; // Save graphics state. GraphicsState transState = graphics.Save(); try { this.chartPicture.Width = position.Width; this.chartPicture.Height = position.Height; // Set required transformation graphics.TranslateTransform(position.X, position.Y); // Set printing indicator this.chartPicture.isPrinting = true; // Draw chart this.chartPicture.Paint(graphics, false); // Clear printing indicator this.chartPicture.isPrinting = false; } finally { // Restore graphics state. graphics.Restore(transState); // Restore old chart position this.chartPicture.Width = oldWidth; this.chartPicture.Height = oldHeight; } }
0
13. Example
Project: fabiano-swagger-of-doom
Source File: QRCodeGenerator.cs
Source File: QRCodeGenerator.cs
public Bitmap GetGraphic(int pixelsPerModule, Color darkColor, Color lightColor) { var size = ModuleMatrix.Count * pixelsPerModule; var bmp = new Bitmap(size, size); var gfx = Graphics.FromImage(bmp); for (var x = 0; x < size; x = x + pixelsPerModule) { for (var y = 0; y < size; y = y + pixelsPerModule) { var module = ModuleMatrix[(y + pixelsPerModule) / pixelsPerModule - 1][(x + pixelsPerModule) / pixelsPerModule - 1]; gfx.FillRectangle(module ? new SolidBrush(darkColor) : new SolidBrush(lightColor), new Rectangle(x, y, pixelsPerModule, pixelsPerModule)); } } gfx.Save(); return bmp; }
0
14. Example
Project: ServiceBusExplorer
Source File: AboutForm.cs
Source File: AboutForm.cs
protected void SetupTransform(Graphics g) { state = g.Save(); var matrix = new Matrix(); matrix.Rotate(Rotation, MatrixOrder.Append); matrix.Translate(Location.X, Location.Y, MatrixOrder.Append); g.Transform = matrix; }
0
15. Example
Project: rallets-windows
Source File: MenuViewController.cs
Source File: MenuViewController.cs
private Bitmap AddBitmapOverlay(Bitmap original, params Bitmap[] overlays) { Bitmap bitmap = new Bitmap(original.Width, original.Height, PixelFormat.Format64bppArgb); Graphics canvas = Graphics.FromImage(bitmap); canvas.DrawImage(original, new Point(0, 0)); foreach (Bitmap overlay in overlays) { canvas.DrawImage(new Bitmap(overlay, original.Size), new Point(0, 0)); } canvas.Save(); return bitmap; }
0
16. Example
Project: MysteryGiftTool
Source File: QRCode.cs
Source File: QRCode.cs
public Bitmap GetGraphic(int pixelsPerModule, Color darkColor, Color lightColor, bool drawQuietZones = true) { var size = (this.QrCodeData.ModuleMatrix.Count - (drawQuietZones ? 0 : 8)) * pixelsPerModule; var offset = drawQuietZones ? 0 : 4 * pixelsPerModule; var bmp = new Bitmap(size, size); var gfx = Graphics.FromImage(bmp); for (var x = 0; x < size + offset; x = x + pixelsPerModule) { for (var y = 0; y < size + offset; y = y + pixelsPerModule) { var module = this.QrCodeData.ModuleMatrix[(y + pixelsPerModule)/pixelsPerModule - 1][(x + pixelsPerModule)/pixelsPerModule - 1]; if (module) { gfx.FillRectangle(new SolidBrush(darkColor), new Rectangle(x - offset, y - offset, pixelsPerModule, pixelsPerModule)); } else { gfx.FillRectangle(new SolidBrush(lightColor), new Rectangle(x - offset, y - offset, pixelsPerModule, pixelsPerModule)); } } } gfx.Save(); return bmp; }
0
17. Example
Project: SharpMap
Source File: SharpDXVectorLayer.cs
Source File: SharpDXVectorLayer.cs
[MethodImpl(MethodImplOptions.Synchronized)] public override void Render(GDI.Graphics g, Map map) { if (map.Center == null) throw (new ApplicationException("Cannot render map. View center not specified")); g.SmoothingMode = SmoothingMode; var envelope = ToSource(map.Envelope); //View to render if (DataSource == null) throw (new ApplicationException("DataSource property not set on layer '" + LayerName + "'")); // Get the transform var transform = new Matrix3x2(g.Transform.Elements); // Save state of the graphics object var gs = g.Save(); // Create and prepare the render target var rt = RenderTargetFactory.Create(_d2d1Factory, g, map); // Set anti-alias mode and transform rt.AntialiasMode = AntialiasMode; rt.Transform = transform; if (Theme != null) RenderInternal(_d2d1Factory, rt, map, envelope, Theme); else RenderInternal(_d2d1Factory, rt, map, envelope); // Clean up the render target RenderTargetFactory.CleanUp(rt, g, map); // Restore the graphics object g.Restore(gs); // Invoke LayerRendered event OnLayerRendered(g); }
0
18. Example
Project: SMT
Source File: Convertion.cs
Source File: Convertion.cs
public static Bitmap ConvertTo(this Bitmap bmpSource, System.Drawing.Imaging.PixelFormat format) { var bmpRet = new Bitmap(bmpSource.Width, bmpSource.Height, format); using (Graphics g = Graphics.FromImage(bmpRet)) { g.DrawImage(bmpSource, 0, 0, new System.Drawing.Rectangle(0, 0, bmpSource.Width, bmpSource.Height), GraphicsUnit.Pixel); g.Save(); } return bmpRet; }
0
19. Example
Project: Core2D
Source File: WinFormsRenderer.cs
Source File: WinFormsRenderer.cs
public override object PushMatrix(object dc, MatrixObject matrix) { var _gfx = dc as Graphics; var state = _gfx.Save(); _gfx.MultiplyTransform(ToMatrix(matrix)); return state; }
0
20. Example
Project: Tellurium
Source File: ImageHelpers.cs
Source File: ImageHelpers.cs
private static void MarkBlindRegions(Image image, IReadOnlyList<BlindRegion> blindRegions) { if (blindRegions == null || blindRegions.Count == 0) return; var graphic = Graphics.FromImage(image); foreach (var blindRegion in blindRegions) { graphic.FillRectangle(Brushes.Black, blindRegion.Left, blindRegion.Top, blindRegion.Width, blindRegion.Height); } graphic.Save(); }
0
21. Example
Project: QRCoder
Source File: QRCode.cs
Source File: QRCode.cs
public Bitmap GetGraphic(int pixelsPerModule, Color darkColor, Color lightColor, bool drawQuietZones = true) { var size = (this.QrCodeData.ModuleMatrix.Count - (drawQuietZones ? 0 : 8)) * pixelsPerModule; var offset = drawQuietZones ? 0 : 4 * pixelsPerModule; var bmp = new Bitmap(size, size); var gfx = Graphics.FromImage(bmp); for (var x = 0; x < size + offset; x = x + pixelsPerModule) { for (var y = 0; y < size + offset; y = y + pixelsPerModule) { var module = this.QrCodeData.ModuleMatrix[(y + pixelsPerModule)/pixelsPerModule - 1][(x + pixelsPerModule)/pixelsPerModule - 1]; if (module) { gfx.FillRectangle(new SolidBrush(darkColor), new Rectangle(x - offset, y - offset, pixelsPerModule, pixelsPerModule)); } else { gfx.FillRectangle(new SolidBrush(lightColor), new Rectangle(x - offset, y - offset, pixelsPerModule, pixelsPerModule)); } } } gfx.Save(); return bmp; }
0
22. Example
Project: audio-switcher
Source File: DrawingServices.cs
Source File: DrawingServices.cs
public static Image CreateOverlayedImage(Image image, Image overlayImage, Size size) { if (image == null || overlayImage == null) throw new ArgumentNullException(image == null ? "image" : "overlayImage"); Image copy = new Bitmap(size.Width, size.Height); using (Graphics g = Graphics.FromImage(copy)) { g.DrawImage(image, 0, 0); // Overlay starting in the bottom right-hand corner g.DrawImage(overlayImage, size.Width - overlayImage.Width, size.Height - overlayImage.Height, overlayImage.Width, overlayImage.Height); g.Save(); return copy; } }
0
23. Example
Project: GameColorWheelCreator
Source File: MainWindow.cs
Source File: MainWindow.cs
private void DrawBitmap() { DrawBackground(_graphics); if (_spriteImage != null) { DrawColorWheel(_graphics); DrawSpriteImage(_graphics); } _graphics.Save(); pbxPreview.Image = _exportImage; }
0
24. Example
Project: ShareX
Source File: BlurFilter.cs
Source File: BlurFilter.cs
public override void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle rect, RenderMode renderMode) { int blurRadius = GetFieldValueAsInt(FieldType.BLUR_RADIUS); Rectangle applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert); if (applyRect.Width == 0 || applyRect.Height == 0) { return; } GraphicsState state = graphics.Save(); if (Invert) { graphics.SetClip(applyRect); graphics.ExcludeClip(rect); } if (GDIplus.IsBlurPossible(blurRadius)) { GDIplus.DrawWithBlur(graphics, applyBitmap, applyRect, null, null, blurRadius, false); } else { using (IFastBitmap fastBitmap = FastBitmap.CreateCloneOf(applyBitmap, applyRect)) { ImageHelper.ApplyBoxBlur(fastBitmap, blurRadius); fastBitmap.DrawTo(graphics, applyRect); } } graphics.Restore(state); }
0
25. Example
Project: ATF
Source File: AnnotatingCommands.cs
Source File: AnnotatingCommands.cs
private Image CreateBackColorIcon(Color color, int width, int height) { Image img = new Bitmap(width, height); Graphics drawing = Graphics.FromImage(img); drawing.Clear(color); drawing.Save(); drawing.Dispose(); return img; }
0
26. Example
Project: ShareX
Source File: BlurFilter.cs
Source File: BlurFilter.cs
public unsafe override void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle rect, RenderMode renderMode) { int blurRadius = GetFieldValueAsInt(FieldType.BLUR_RADIUS); Rectangle applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert); if (applyRect.Width == 0 || applyRect.Height == 0) { return; } GraphicsState state = graphics.Save(); if (Invert) { graphics.SetClip(applyRect); graphics.ExcludeClip(rect); } if (GDIplus.IsBlurPossible(blurRadius)) { GDIplus.DrawWithBlur(graphics, applyBitmap, applyRect, null, null, blurRadius, false); } else { using (IFastBitmap fastBitmap = FastBitmap.CreateCloneOf(applyBitmap, applyRect)) { ImageHelper.ApplyBoxBlur(fastBitmap, blurRadius); fastBitmap.DrawTo(graphics, applyRect); } } graphics.Restore(state); return; }
0
27. Example
Project: ColorPicker
Source File: MainForm.cs
Source File: MainForm.cs
private Bitmap GetSampleRegion(Screen screen, int mouseX, int mouseY) { var bmp = new Bitmap(sampleSize, sampleSize, PixelFormat.Format32bppArgb); Graphics gfxScreenshot = Graphics.FromImage(bmp); gfxScreenshot.CopyFromScreen(mouseX - sampleSize / 2, mouseY - sampleSize / 2, 0, 0, new Size(sampleSize, sampleSize)); gfxScreenshot.Save(); gfxScreenshot.Dispose(); return bmp; }
0
28. Example
Project: mooege
Source File: DebugNavMesh.cs
Source File: DebugNavMesh.cs
public Bitmap Draw() { // As quad-tree always has 4 quad-nodes beneath the root /n ..... /n //View Source file for more details /n }
0
29. Example
Project: ShareX
Source File: BrightnessFilter.cs
Source File: BrightnessFilter.cs
public override void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle rect, RenderMode renderMode) { Rectangle applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert); if (applyRect.Width == 0 || applyRect.Height == 0) { // nothing to do return; } GraphicsState state = graphics.Save(); if (Invert) { graphics.SetClip(applyRect); graphics.ExcludeClip(rect); } float brightness = GetFieldValueAsFloat(FieldType.BRIGHTNESS); using (ImageAttributes ia = ImageHelper.CreateAdjustAttributes(brightness, 1f, 1f)) { graphics.DrawImage(applyBitmap, applyRect, applyRect.X, applyRect.Y, applyRect.Width, applyRect.Height, GraphicsUnit.Pixel, ia); } graphics.Restore(state); }
0
30. Example
Project: ShareX
Source File: MagnifierFilter.cs
Source File: MagnifierFilter.cs
public override void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle rect, RenderMode renderMode) { Rectangle applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert); if (applyRect.Width == 0 || applyRect.Height == 0) { // nothing to do return; } int magnificationFactor = GetFieldValueAsInt(FieldType.MAGNIFICATION_FACTOR); GraphicsState state = graphics.Save(); if (Invert) { graphics.SetClip(applyRect); graphics.ExcludeClip(rect); } graphics.SmoothingMode = SmoothingMode.None; graphics.InterpolationMode = InterpolationMode.NearestNeighbor; graphics.CompositingQuality = CompositingQuality.HighQuality; graphics.PixelOffsetMode = PixelOffsetMode.None; int halfWidth = rect.Width / 2; int halfHeight = rect.Height / 2; int newWidth = rect.Width / magnificationFactor; int newHeight = rect.Height / magnificationFactor; Rectangle source = new Rectangle(rect.X + halfWidth - newWidth / 2, rect.Y + halfHeight - newHeight / 2, newWidth, newHeight); graphics.DrawImage(applyBitmap, rect, source, GraphicsUnit.Pixel); graphics.Restore(state); }
0
31. Example
Project: AudioSwitch
Source File: DeviceIcons.cs
Source File: DeviceIcons.cs
private static Image AddOverlay(Icon originalIcon, Image overlay) { using (Image original = originalIcon.ToBitmap()) { var bitmap = new Bitmap(originalIcon.Width, originalIcon.Height); using (var canvas = Graphics.FromImage(bitmap)) { canvas.DrawImage(original, 0, 0); canvas.DrawImage(overlay, 0, 0, original.Width, original.Height); canvas.Save(); return bitmap; } } }
0
32. Example
Project: barcodelib
Source File: BarcodeLib.cs
Source File: BarcodeLib.cs
private Image Label_Generic(Image img) { try { Syste/n ..... /n //View Source file for more details /n }
0
33. Example
Project: ShareX
Source File: BrightnessFilter.cs
Source File: BrightnessFilter.cs
public override void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle rect, RenderMode renderMode) { Rectangle applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert); if (applyRect.Width == 0 || applyRect.Height == 0) { // nothing to do return; } GraphicsState state = graphics.Save(); if (Invert) { graphics.SetClip(applyRect); graphics.ExcludeClip(rect); } float brightness = GetFieldValueAsFloat(FieldType.BRIGHTNESS); using (ImageAttributes ia = ImageHelper.CreateAdjustAttributes(brightness, 1f, 1f)) { graphics.DrawImage(applyBitmap, applyRect, applyRect.X, applyRect.Y, applyRect.Width, applyRect.Height, GraphicsUnit.Pixel, ia); } graphics.Restore(state); }
0
34. Example
Project: ShareX
Source File: MagnifierFilter.cs
Source File: MagnifierFilter.cs
public override void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle rect, RenderMode renderMode) { Rectangle applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert); if (applyRect.Width == 0 || applyRect.Height == 0) { // nothing to do return; } int magnificationFactor = GetFieldValueAsInt(FieldType.MAGNIFICATION_FACTOR); GraphicsState state = graphics.Save(); if (Invert) { graphics.SetClip(applyRect); graphics.ExcludeClip(rect); } graphics.SmoothingMode = SmoothingMode.None; graphics.InterpolationMode = InterpolationMode.NearestNeighbor; graphics.CompositingQuality = CompositingQuality.HighQuality; graphics.PixelOffsetMode = PixelOffsetMode.None; int halfWidth = rect.Width / 2; int halfHeight = rect.Height / 2; int newWidth = rect.Width / magnificationFactor; int newHeight = rect.Height / magnificationFactor; Rectangle source = new Rectangle(rect.X + halfWidth - (newWidth / 2), rect.Y + halfHeight - (newHeight / 2), newWidth, newHeight); graphics.DrawImage(applyBitmap, rect, source, GraphicsUnit.Pixel); graphics.Restore(state); }
0
35. Example
Project: daemaged.ibnet
Source File: CellRenderers.cs
Source File: CellRenderers.cs
protected override void OnDraw(DevAge.Drawing.GraphicsCache graphics, RectangleF area) { System.Drawing.Drawing2D.GraphicsState state = graphics.Graphics.Save(); try { float width2 = area.Width / 2; float height2 = area.Height / 2; //For a better drawing use the clear type rendering graphics.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit; //Move the origin to the center of the cell (for a more easy rotation) graphics.Graphics.TranslateTransform(area.X + width2, area.Y + height2); graphics.Graphics.RotateTransform(Angle); StringFormat.Alignment = StringAlignment.Center; StringFormat.LineAlignment = StringAlignment.Center; graphics.Graphics.DrawString(Value, Font, graphics.BrushsCache.GetBrush(ForeColor), 0, 0, StringFormat); } finally { graphics.Graphics.Restore(state); } }
0
36. Example
Project: core
Source File: BarcodeLib.cs
Source File: BarcodeLib.cs
private Image Label_ITF14(Image img) { try { var font = new Font("Microsoft Sans Serif", 10, FontStyle.Bold); using (var g = Graphics.FromImage(img)) { g.DrawImage(img, 0, (float) 0); g.SmoothingMode = SmoothingMode.HighQuality; g.InterpolationMode = InterpolationMode.HighQualityBicubic; g.PixelOffsetMode = PixelOffsetMode.HighQuality; g.CompositingQuality = CompositingQuality.HighQuality; //color a white box at the bottom of the barcode to hold the string of data g.FillRectangle(new SolidBrush(BackColor), new Rectangle(0, img.Height - 16, img.Width, 16)); //draw datastring under the barcode image var f = new StringFormat {Alignment = StringAlignment.Center}; g.DrawString(Raw_Data, font, new SolidBrush(ForeColor), img.Width/2, img.Height - 16, f); var pen = new Pen(ForeColor, (float) img.Height/16) {Alignment = PenAlignment.Inset}; g.DrawLine(pen, new Point(0, img.Height - 20), new Point(img.Width, img.Height - 20)); //bottom g.Save(); } return img; } catch (Exception ex) { throw new Exception("ELABEL_ITF14-1: " + ex.Message); } }
0
37. Example
Project: core
Source File: BarcodeLib.cs
Source File: BarcodeLib.cs
private Image Label_Generic(Image img) { try { var font = new Font("Microsoft Sans Serif", 10, FontStyle.Bold); using (var g = Graphics.FromImage(img)) { g.DrawImage(img, 0, (float) 0); g.SmoothingMode = SmoothingMode.HighQuality; g.InterpolationMode = InterpolationMode.HighQualityBicubic; g.PixelOffsetMode = PixelOffsetMode.HighQuality; g.CompositingQuality = CompositingQuality.HighQuality; //color a background color box at the bottom of the barcode to hold the string of data g.FillRectangle(new SolidBrush(BackColor), new Rectangle(0, img.Height - 16, img.Width, 16)); //draw datastring under the barcode image var f = new StringFormat {Alignment = StringAlignment.Center}; var strLabelText = !string.IsNullOrEmpty(FormattedData) ? FormattedData : RawData; g.DrawString(strLabelText, font, new SolidBrush(ForeColor), img.Width/2, img.Height - 16, f); g.Save(); } return img; } catch (Exception ex) { throw new Exception("ELABEL_GENERIC-1: " + ex.Message); } }
0
38. Example
Project: SAI-Editor
Source File: CustomTabControl.cs
Source File: CustomTabControl.cs
protected new void PaintTransparentBackground(Graphics graphics, Rectangle clipRect) { /n ..... /n //View Source file for more details /n }
0
39. Example
Project: LaserGRBL
Source File: GrblFile.cs
Source File: GrblFile.cs
private static void DrawString(Graphics g, float zoom, decimal curX, decimal curY, string text, bool centerX, bool centerY, bool subtractX, bool subtractY) { GraphicsState state = g.Save(); g.ScaleTransform(1.0f, -1.0f); using (Font f = new Font(FontFamily.GenericMonospace, 8 * 1 / zoom)) { float offsetX = 0; float offsetY = 0; SizeF ms = g.MeasureString(text, f); if (centerX) offsetX = ms.Width / 2; if (centerY) offsetY = ms.Height / 2; if (subtractX) offsetX += ms.Width; if (subtractY) offsetY += ms.Height; using (Brush b = GetBrush(ColorScheme.PreviewText)) { g.DrawString(text, f, b, (float)curX - offsetX, (float)-curY - offsetY); } } g.Restore(state); }
0
40. Example
Project: ShareX
Source File: GrayscaleFilter.cs
Source File: GrayscaleFilter.cs
public override void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle rect, RenderMode renderMode) { Rectangle applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert); if (applyRect.Width == 0 || applyRect.Height == 0) { // nothing to do return; } GraphicsState state = graphics.Save(); if (Invert) { graphics.SetClip(applyRect); graphics.ExcludeClip(rect); } ColorMatrix grayscaleMatrix = new ColorMatrix(new[] { new[] {.3f, .3f, .3f, 0, 0}, new[] {.59f, .59f, .59f, 0, 0}, new[] {.11f, .11f, .11f, 0, 0}, new float[] {0, 0, 0, 1, 0}, new float[] {0, 0, 0, 0, 1} }); using (ImageAttributes ia = new ImageAttributes()) { ia.SetColorMatrix(grayscaleMatrix); graphics.DrawImage(applyBitmap, applyRect, applyRect.X, applyRect.Y, applyRect.Width, applyRect.Height, GraphicsUnit.Pixel, ia); } graphics.Restore(state); }
0
41. Example
Project: ShareX
Source File: HighlightFilter.cs
Source File: HighlightFilter.cs
public override void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle rect, RenderMode renderMode) { Rectangle applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert); if (applyRect.Width == 0 || applyRect.Height == 0) { // nothing to do return; } GraphicsState state = graphics.Save(); if (Invert) { graphics.SetClip(applyRect); graphics.ExcludeClip(rect); } using (IFastBitmap fastBitmap = FastBitmap.CreateCloneOf(applyBitmap, applyRect)) { Color highlightColor = GetFieldValueAsColor(FieldType.FILL_COLOR); for (int y = fastBitmap.Top; y < fastBitmap.Bottom; y++) { for (int x = fastBitmap.Left; x < fastBitmap.Right; x++) { Color color = fastBitmap.GetColorAt(x, y); color = Color.FromArgb(color.A, Math.Min(highlightColor.R, color.R), Math.Min(highlightColor.G, color.G), Math.Min(highlightColor.B, color.B)); fastBitmap.SetColorAt(x, y, color); } } fastBitmap.DrawTo(graphics, applyRect.Location); } graphics.Restore(state); }
0
42. Example
Project: barcodelib
Source File: BarcodeLib.cs
Source File: BarcodeLib.cs
private Image Label_ITF14(Image img) { try { System./n ..... /n //View Source file for more details /n }
0
43. Example
Project: barcodelib
Source File: BarcodeLib.cs
Source File: BarcodeLib.cs
private Image Label_UPCA(Image img) { try { int iBar/n ..... /n //View Source file for more details /n }
0
44. Example
Project: ShareX
Source File: GrayscaleFilter.cs
Source File: GrayscaleFilter.cs
public override void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle rect, RenderMode renderMode) { Rectangle applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert); if (applyRect.Width == 0 || applyRect.Height == 0) { // nothing to do return; } GraphicsState state = graphics.Save(); if (Invert) { graphics.SetClip(applyRect); graphics.ExcludeClip(rect); } ColorMatrix grayscaleMatrix = new ColorMatrix(new float[][] { new float[] {.3f, .3f, .3f, 0, 0}, new float[] {.59f, .59f, .59f, 0, 0}, new float[] {.11f, .11f, .11f, 0, 0}, new float[] {0, 0, 0, 1, 0}, new float[] {0, 0, 0, 0, 1} }); using (ImageAttributes ia = new ImageAttributes()) { ia.SetColorMatrix(grayscaleMatrix); graphics.DrawImage(applyBitmap, applyRect, applyRect.X, applyRect.Y, applyRect.Width, applyRect.Height, GraphicsUnit.Pixel, ia); } graphics.Restore(state); }
0
45. Example
Project: ShareX
Source File: HighlightFilter.cs
Source File: HighlightFilter.cs
public override void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle rect, RenderMode renderMode) { Rectangle applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert); if (applyRect.Width == 0 || applyRect.Height == 0) { // nothing to do return; } GraphicsState state = graphics.Save(); if (Invert) { graphics.SetClip(applyRect); graphics.ExcludeClip(rect); } using (IFastBitmap fastBitmap = FastBitmap.CreateCloneOf(applyBitmap, applyRect)) { Color highlightColor = GetFieldValueAsColor(FieldType.FILL_COLOR); for (int y = fastBitmap.Top; y < fastBitmap.Bottom; y++) { for (int x = fastBitmap.Left; x < fastBitmap.Right; x++) { Color color = fastBitmap.GetColorAt(x, y); color = Color.FromArgb(color.A, Math.Min(highlightColor.R, color.R), Math.Min(highlightColor.G, color.G), Math.Min(highlightColor.B, color.B)); fastBitmap.SetColorAt(x, y, color); } } fastBitmap.DrawTo(graphics, applyRect.Location); } graphics.Restore(state); }
0
46. Example
Project: EDDiscovery
Source File: TabControlCustom.cs
Source File: TabControlCustom.cs
protected void PaintTransparentBackground(Graphics graphics, Rectangle clipRect) { if ((Parent != null)) { clipRect.Offset(Location); GraphicsState state = graphics.Save(); graphics.TranslateTransform((float)-Location.X, (float)-Location.Y); graphics.SmoothingMode = SmoothingMode.HighSpeed; PaintEventArgs e = new PaintEventArgs(graphics, clipRect); try { InvokePaintBackground(Parent, e); // we force it to paint into our bitmap InvokePaint(Parent, e); // which we do not use. } finally { graphics.Restore(state); clipRect.Offset(-Location.X, -Location.Y); } } }
0
47. Example
Project: Playnite
Source File: CoverCreator.cs
Source File: CoverCreator.cs
public static void CreateCover(Stream backgroundImage, Stream coverImage, Stream stream) { var background = Image.FromStream(backgroundImage); var cover = Image.FromStream(coverImage); using (var canvas = Graphics.FromImage(background)) { var scaled = ScaleRect(new SizeF(231, 50), new SizeF(cover.Width, cover.Height), true, false); canvas.InterpolationMode = InterpolationMode.HighQualityBicubic; canvas.DrawImage(cover, 0, 0, 231, scaled.Height); canvas.Save(); } var jpgEncoder = GetEncoder(ImageFormat.Jpeg); var myEncoder = System.Drawing.Imaging.Encoder.Quality; var myEncoderParameters = new EncoderParameters(1); var myEncoderParameter = new EncoderParameter(myEncoder, 100L); myEncoderParameters.Param[0] = myEncoderParameter; background.Save(stream, jpgEncoder, myEncoderParameters); }
0
48. Example
Project: P8Coder
Source File: FastColoredTextBox.cs
Source File: FastColoredTextBox.cs
private void DrawMiddleClickScrolling(Graphics gr) { // If mouse scrolling mode activated draw the scrolling cursor image bool ableToScrollVertically = this.VerticalScroll.Visible || !ShowScrollBars; bool ableToScrollHorizontally = this.HorizontalScroll.Visible || !ShowScrollBars; // Calculate inverse color Color inverseColor = Color.FromArgb(100, (byte)~this.BackColor.R, (byte)~this.BackColor.G, (byte)~this.BackColor.B); using (SolidBrush inverseColorBrush = new SolidBrush(inverseColor)) { var p = middleClickScrollingOriginPoint; var state = gr.Save(); gr.SmoothingMode = SmoothingMode.HighQuality; gr.TranslateTransform(p.X, p.Y); gr.FillEllipse(inverseColorBrush, -2, -2, 4, 4); if (ableToScrollVertically) DrawTriangle(gr, inverseColorBrush); gr.RotateTransform(90); if (ableToScrollHorizontally) DrawTriangle(gr, inverseColorBrush); gr.RotateTransform(90); if (ableToScrollVertically) DrawTriangle(gr, inverseColorBrush); gr.RotateTransform(90); if (ableToScrollHorizontally) DrawTriangle(gr, inverseColorBrush); gr.Restore(state); } }
0
49. Example
Project: P8Coder
Source File: Style.cs
Source File: Style.cs
public override void Draw(Graphics gr, Point position, Range range) { //draw bac/n ..... /n //View Source file for more details /n }
0
50. Example
Project: BaijiGenerator.Net
Source File: FastColoredTextBox.cs
Source File: FastColoredTextBox.cs
private void DrawMiddleClickScrolling(Graphics gr) { // If mouse scrolling mode activated draw the scrolling cursor image bool ableToScrollVertically = this.VerticalScroll.Visible || !ShowScrollBars; bool ableToScrollHorizontally = this.HorizontalScroll.Visible || !ShowScrollBars; // Calculate inverse color Color inverseColor = Color.FromArgb(100, (byte)~this.BackColor.R, (byte)~this.BackColor.G, (byte)~this.BackColor.B); using (SolidBrush inverseColorBrush = new SolidBrush(inverseColor)) { var p = middleClickScrollingOriginPoint; var state = gr.Save(); gr.SmoothingMode = SmoothingMode.HighQuality; gr.TranslateTransform(p.X, p.Y); gr.FillEllipse(inverseColorBrush, -2, -2, 4, 4); if (ableToScrollVertically) DrawTriangle(gr, inverseColorBrush); gr.RotateTransform(90); if (ableToScrollHorizontally) DrawTriangle(gr, inverseColorBrush); gr.RotateTransform(90); if (ableToScrollVertically) DrawTriangle(gr, inverseColorBrush); gr.RotateTransform(90); if (ableToScrollHorizontally) DrawTriangle(gr, inverseColorBrush); gr.Restore(state); } }