本文整理汇总了C#中System.Drawing.Graphics.Restore方法的典型用法代码示例。如果您正苦于以下问题:C# Graphics.Restore方法的具体用法?C# Graphics.Restore怎么用?C# Graphics.Restore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Graphics
的用法示例。
在下文中一共展示了Graphics.Restore方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Apply
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);
}
示例2: Apply
public unsafe override void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle rect, RenderMode renderMode)
{
int blurRadius = GetFieldValueAsInt(FieldType.BLUR_RADIUS);
double previewQuality = GetFieldValueAsDouble(FieldType.PREVIEW_QUALITY);
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;
}
示例3: Apply
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);
}
示例4: Draw
public void Draw (Graphics graphics, Route route, bool atEnd)
{
if (graphics == null) return;
if (route == null) return;
GraphicsState state = graphics.Save();
float direction = 0;
PointF pos = default(PointF);
if (atEnd)
{
pos = route.GetEndPoint();
direction = ConvertDirection(route.GetEndDirection());
}
else
{
pos = route.GetStartPoint();
direction = ConvertDirection(route.GetStartDirection());
}
// In matrix math, the correct way is to put rotation BEFORE
// translation. However, the simple transformation maethods of
// GDI+ works in "Prepend" mode, which reverses the order of
// operations.
graphics.TranslateTransform(pos.X, pos.Y);
graphics.RotateTransform(direction);
Paint(graphics);
graphics.Restore(state);
}
示例5: Apply
/// <summary>
/// Implements the Apply code for the Brightness Filet
/// </summary>
/// <param name="graphics"></param>
/// <param name="applyBitmap"></param>
/// <param name="rect"></param>
/// <param name="renderMode"></param>
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);
}
示例6: Print
/// <summary>
/// Prints an image box onto the specified graphics.
/// </summary>
/// <param name="imageBox">Image box to print.</param>
/// <param name="graphics">Graphics in which image box should be contained.</param>
/// <param name="box">Rectangle within which the image box should be contained.</param>
/// <param name="imageResolution">Image resolution.</param>
public static void Print(this ImageBox imageBox, Graphics graphics, RectF box, int imageResolution)
{
var state = graphics.Save();
FillBox(imageBox.FilmBox, box, graphics);
var boxCopy = box;
if (imageBox.FilmBox.Trim == "YES")
{
boxCopy.Inflate(-BORDER, -BORDER);
}
if (imageBox.ImageSequence != null && imageBox.ImageSequence.Contains(DicomTag.PixelData))
{
Image bitmap = null;
try
{
var image = new DicomImage(imageBox.ImageSequence);
var frame = image.RenderImage().As<Image>();
bitmap = frame;
DrawBitmap(graphics, boxCopy, bitmap, imageResolution, imageBox.FilmBox.EmptyImageDensity);
}
finally
{
if (bitmap != null)
{
bitmap.Dispose();
}
}
}
graphics.Restore(state);
}
示例7: PaintTransparentBackground
protected void PaintTransparentBackground(Graphics g, Rectangle clipRect) {
// check if we have a parent
if (this.Parent != null) {
// convert the clipRects coordinates from ours to our parents
clipRect.Offset(this.Location);
PaintEventArgs e = new PaintEventArgs(g, clipRect);
GraphicsState state = g.Save();
try {
// move the graphics object so that we are drawing in
// the correct place
g.TranslateTransform((float)-this.Location.X, (float)-this.Location.Y);
// draw the parents background and foreground
this.InvokePaintBackground(this.Parent, e);
this.InvokePaint(this.Parent, e);
return;
} finally {
// reset everything back to where they were before
g.Restore(state);
clipRect.Offset(-this.Location.X, -this.Location.Y);
}
}
// we don't have a parent, so fill the rect with
// the default control color
g.FillRectangle(SystemBrushes.Control, clipRect);
}
示例8: DrawToGraphics
public virtual void DrawToGraphics (Graphics graphics, float x, float y, float scaleX, float scaleY)
{
if (graphics == null) return;
GraphicsState state = graphics.Save();
graphics.TranslateTransform (x, y);
graphics.ScaleTransform(scaleX, scaleY);
Draw(graphics);
//graphics.DrawRectangle(Pens.Magenta, 0, 0, ShapeWidth, ShapeHeight);
graphics.Restore(state);
}
示例9: PaintPanel
protected override void PaintPanel(Graphics g)
{
if (g == null) throw new ArgumentNullException("g");
var scroll = Hexgrid.ScrollPosition;
if (DesignMode) { g.FillRectangle(Brushes.Gray, ClientRectangle); return; }
g.Clear(Color.Black);
if (IsTransposed) { g.Transform = TransposeMatrix; }
g.TranslateTransform(scroll.X, scroll.Y);
g.ScaleTransform(MapScale, MapScale);
var state = g.Save();
g.DrawImageUnscaled(MapBuffer, Point.Empty);
g.Restore(state); state = g.Save();
Host.PaintUnits(g);
g.Restore(state); state = g.Save();
Host.PaintHighlight(g);
}
示例10: Draw
public override void Draw(Graphics graphics)
{
if (graphics == null) return;
GraphicsState state = graphics.Save();
graphics.TranslateTransform(17.0f, 0.0f);
graphics.ScaleTransform(-1.0f, 1.0f);
MethodShape.DrawBrick(graphics, brickBrush1, brickBrush2, brickBrush3);
graphics.Restore(state);
graphics.FillRectangle(Brushes.Gray, 1.0f, 4.5f, 3.5f, 0.5f);
graphics.FillRectangle(Brushes.Gray, 0.0f, 6.5f, 3.5f, 0.5f);
graphics.FillRectangle(Brushes.Gray, 2.0f, 8.5f, 3.5f, 0.5f);
}
示例11: DrawElement
private void DrawElement(Graphics g, Act2DMapLayoutObject.Element e)
{
var bitmap = file.CreateBitmapForResource(e.resourceID);
if (bitmap == null) return;
var saved = g.Save();
g.TranslateTransform(e.x, e.y);
g.TranslateTransform(bitmap.Width * 0.5f, bitmap.Height * 0.5f);
g.RotateTransform(e.rotate);
g.ScaleTransform(e.scale_x, e.scale_y);
g.TranslateTransform(-bitmap.Width * 0.5f, -bitmap.Height * 0.5f);
g.DrawImage(bitmap, new PointF(0.0f, 0.0f));
g.Restore(saved);
}
示例12: draw
internal override void draw(Graphics g)
{
RectangleF rcNode = item.getRotatedBounds();
Rectangle rcDev = Utilities.docToDevice(g, getIconRect(rcNode));
if (rcDev.Width < 6 || rcDev.Height < 6) return;
GraphicsState state = g.Save();
item.flowChart.unsetTransforms(g);
if ((item as Node).Expanded)
g.DrawIcon(imgExpanded, rcDev.X, rcDev.Y);
else
g.DrawIcon(imgCollapsed, rcDev.X, rcDev.Y);
g.Restore(state);
}
示例13: DrawToolTip
protected override void DrawToolTip(Graphics g, GMapMarker m, int x, int y)
{
GraphicsState s = g.Save();
g.SmoothingMode = SmoothingMode.AntiAlias;
System.Drawing.Size st = g.MeasureString(m.ToolTipText, TooltipFont).ToSize();
System.Drawing.Rectangle rect = new System.Drawing.Rectangle(x, y, st.Width + Control.TooltipTextPadding.Width, st.Height + Control.TooltipTextPadding.Height);
rect.Offset(m.ToolTipOffset.X, m.ToolTipOffset.Y);
g.DrawLine(TooltipPen, x, y, rect.X + rect.Width / 2, rect.Y + rect.Height / 2);
g.FillRectangle(TooltipBackground, rect);
g.DrawRectangle(TooltipPen, rect);
g.DrawString(m.ToolTipText, TooltipFont, Brushes.Navy, rect, TooltipFormat);
g.Restore(s);
}
示例14: Draw
public override void Draw(Graphics graphics)
{
if (graphics == null) return;
GraphicsState state = graphics.Save();
CollapseExpandShape.DrawButton(graphics);
if (collapsed)
{
graphics.TranslateTransform(0, 21);
graphics.ScaleTransform(1, -1);
}
CollapseExpandShape.DrawArrow(graphics);
graphics.TranslateTransform(0, 6);
CollapseExpandShape.DrawArrow(graphics);
graphics.Restore(state);
}
示例15: DoGrid
public static void DoGrid(this WidgetMidiList widget, FloatRect grid, Graphics g)
{
var gs = g.Save();
using (g.Clip = new Region(grid))
{
using (var p0 = new Pen(Color.Black)) foreach (var i in widget.GetHLines(4))
g.DrawLines(p0, new Point[] { new FloatPoint(i.XO, grid.Top), new FloatPoint(i.XO, grid.Bottom) });
using (var p1 = new Pen(Gray130)) foreach (var i in widget.GetHLines(Convert.ToInt32(Math.Pow(4, 2))))
g.DrawLines(p1, new Point[] { new FloatPoint(i.XO, grid.Top), new FloatPoint(i.XO, grid.Bottom) });
using (var p2 = new Pen(White)) foreach (var i in widget.GetHLines(Convert.ToInt32(Math.Pow(4, 3))))
g.DrawLines(p2, new Point[] { new FloatPoint(i.XO, grid.Top), new FloatPoint(i.XO, grid.Bottom) });
g.ResetClip();
}
g.Restore(gs);
}