/// <summary> /// Adds a mapping from the given RGB color to the given ARGB color. /// </summary> /// <param name="source">The source RGB color.</param> /// <param name="destination">The destination ARGB color.</param> /// <exception cref="T:System.ArgumentException">The <paramref name="source"/> and <paramref name="destination"/> colors are /// identical, and thus this mapping is trivial.</exception> public void AddMapping(RgbColor source, ArgbColor destination) { if (source.ToArgb() == destination.ToArgb()) throw new ArgumentException( "source and destination colors are identical. Trivial mappings may not be explicitly defined."); map.Add(source, destination); }
/// <summary> /// Converts a value. /// </summary> /// <param name="value">The value that is produced by the binding target.</param> /// <param name="targetType">The type to convert to.</param> /// <param name="parameter">The converter parameter to use.</param> /// <param name="culture">The culture to use in the converter.</param> /// <returns>A converted value.</returns> public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { var brush = value as SolidColorBrush; if (brush != null && value != DependencyProperty.UnsetValue) { return(ArgbColor.Create( brush.Color.A, brush.Color.R, brush.Color.G, brush.Color.B)); } return(DependencyProperty.UnsetValue); }
private ArgbColor TransformPixel(ArgbColor pixel) { byte gray; gray = (byte)(0.299 * pixel.R + 0.587 * pixel.G + 0.114 * pixel.B); /* * I'm leaving the alpha channel untouched instead of making it fully opaque * otherwise the transparent areas become fully black, and I was getting annoyed * by this when testing images with large swathes of transparency! */ return(gray < (byte)thresholdNumericUpDown.Value ? new ArgbColor(pixel.A, 0, 0, 0) : new ArgbColor(pixel.A, 255, 255, 255)); }
public static void smethod_1( DxfEntity entity, DrawContext.Wireframe drawContext, IWireframeGraphicsFactory2 graphicsFactory, ArgbColor color, bool forText, bool fill, bool stroke, Polyline4D polyline) { graphicsFactory.BeginGeometry(entity, drawContext, color, false, fill, stroke, true); graphicsFactory.CreatePolyline(entity, polyline); graphicsFactory.EndGeometry(); }
public ArgbColor Transform(ArgbColor[] data, ArgbColor pixel, int x, int y, int width, int height) { byte gray; gray = (byte)(0.299 * pixel.R + 0.587 * pixel.G + 0.114 * pixel.B); /* * I'm leaving the alpha channel untouched instead of making it fully opaque * otherwise the transparent areas become fully black, and I was getting annoyed * by this when testing images with large swathes of transparency! */ return(gray < _threshold ? _black : _white); }
public static ArgbColor ToBWPixel(ArgbColor origin) { uint gray; gray = (uint)(0.299 * origin.R + 0.587 * origin.G + 0.114 * origin.B); /* * I'm leaving the alpha channel untouched instead of making it fully opaque * otherwise the transparent areas become fully black, and I was getting annoyed * by this when testing images with large swathes of transparency! */ return(gray < GrayThreshold ? new ArgbColor(origin.A, 0, 0, 0) : new ArgbColor(origin.A, 255, 255, 255)); }
protected static void ApplyAcadCorrection(ArgbColor[] colors, ArgbColor backgroundColor) { int mask = DxfIndexedColor.smethod_12(backgroundColor); int rgb1 = backgroundColor.Rgb; for (int index = 1; index <= (int)byte.MaxValue; ++index) { int rgb2 = colors[index].Rgb; if (DxfIndexedColor.smethod_11(rgb2 & mask, rgb1 & mask) < 29) { colors[index] = DxfIndexedColor.smethod_7(rgb2, rgb1, mask); } } }
public void CreatePathAsOne( DxfEntity entity, DrawContext.Wireframe drawContext, ArgbColor color, bool forText, IList <Polyline4D> polylines, bool fill, bool correctForBackgroundColor) { foreach (IList <Vector4D> polyline in (IEnumerable <Polyline4D>)polylines) { this.bounds3D_0.Update(polyline, this.matrix4D_0); } }
/// <summary> /// /// </summary> /// <param name="value"></param> /// <param name="targetType"></param> /// <param name="parameter"></param> /// <param name="culture"></param> /// <returns></returns> public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { var brush = value as SolidColorBrush; if (brush != null) { return(ArgbColor.Create( brush.Color.A, brush.Color.R, brush.Color.G, brush.Color.B)); } return(null); }
public SimpleIndexedPalettePixelTransform8() : base(new[] { ArgbColor.FromArgb(0, 0, 0), ArgbColor.FromArgb(255, 0, 0), ArgbColor.FromArgb(0, 255, 0), ArgbColor.FromArgb(0, 0, 255), ArgbColor.FromArgb(255, 255, 0), ArgbColor.FromArgb(255, 0, 255), ArgbColor.FromArgb(0, 255, 255), ArgbColor.FromArgb(255, 255, 255) }) { }
public EnvelopeGraphics() { _symbol = PlugInManager.Create(KnownObjects.Symbology_SimpleFillSymbol) as ISymbol; if (_symbol is IBrushColor) { ((IBrushColor)_symbol).FillColor = ArgbColor.FromArgb(155, ArgbColor.White); } _symbol2 = PlugInManager.Create(KnownObjects.Symbology_SimpleLineSymbol) as ISymbol; if (_symbol2 is IPenColor) { ((IPenColor)_symbol2).PenColor = ArgbColor.Blue; } }
void IErrorDiffusion.Diffuse(ArgbColor[] data, ArgbColor original, ArgbColor transformed, int x, int y, int width, int height) { byte gray; gray = (byte)(0.299 * original.R + 0.587 * original.G + 0.114 * original.B); if (gray > _random.Next(0, 255)) { data[y * width + x] = _white; } else { data[y * width + x] = _black; } }
public Class1073( ArgbColor color, bool fill, Point2D position, double ascent, double descent, double width) { this.argbColor_0 = color; this.bool_0 = fill; this.point2D_0 = position; this.double_0 = ascent; this.double_1 = descent; this.double_2 = width; }
private void GetSKPaintFill(ArgbColor color, bool isAntialias, out SKPaint brush) { if (color.IsDirty == true || !_paintCache.TryGetValue(color, out var brushCached)) { color.Invalidate(); brushCached = SkiaHelper.ToSKPaintBrush(color, isAntialias); _paintCache[color] = brushCached; } else { SkiaHelper.ToSKPaintBrushUpdate(brushCached, color); } brush = brushCached; }
public void CreatePathAsOne( DxfEntity entity, DrawContext.Wireframe drawContext, ArgbColor color, bool forText, IList <Polyline4D> polylines, bool fill, bool correctForBackgroundColor) { if (polylines.Count <= 0) { return; } this.method_7(polylines, color, fill, correctForBackgroundColor); }
internal static DxfIndexedColorSet smethod_13(ArgbColor backgroundColor) { backgroundColor.A = byte.MaxValue; ArgbColor[] indexedColors = (ArgbColor[])DxfIndexedColor.Color.Clone(); ArgbColor argbColor = ArgbColor.IsBrightColor(backgroundColor) ? ArgbColors.Black : ArgbColors.White; for (int index = 1; index < 256; ++index) { if (indexedColors[index] == backgroundColor) { indexedColors[index] = argbColor; } } return(new DxfIndexedColorSet(indexedColors)); }
public Class968( DxfEntity entity, DrawContext.Wireframe drawContext, ArgbColor color, bool forText, IList <Polyline4D> polylines, bool fill, bool correctForBackgroundColor) : base(entity, drawContext, color) { this.bool_0 = forText; this.ilist_0 = polylines; this.bool_1 = fill; this.bool_2 = correctForBackgroundColor; }
public void DrawPath( IShape2D path, Matrix4D transform, Color color, short lineWeight, bool filled, bool forText, double extrusion) { if (!path.HasSegments) { return; } IClippingTransformer transformer = (IClippingTransformer)this.wireframe_0.GetTransformer().Clone(); transformer.SetPreTransform(transform); IWireframeGraphicsFactory graphicsFactory0 = this.iwireframeGraphicsFactory_0; if (extrusion == 0.0) { IShape4D shape1 = (IShape4D) new FlatShape4D((IShape2D)(path as GeneralShape2D ?? new GeneralShape2D(path, true)), filled); IShape4D shape2 = transformer.Transform(shape1); if (shape2.IsEmpty) { return; } graphicsFactory0.CreateShape(this.dxfEntity_0, this.wireframe_0, this.wireframe_0.GetPlotColor(this.dxfEntity_0, color), forText, shape2); } else { IList <Polyline2D> flattened = (IList <Polyline2D>)ShapeTool.GetFlattened(path, this.wireframe_0.Config.ShapeFlattenEpsilon); IList <Polyline4D> polylines1 = DxfUtil.smethod_39(flattened, filled, transformer); ArgbColor plotColor = this.wireframe_0.GetPlotColor(this.dxfEntity_0, color); graphicsFactory0.CreatePathAsOne(this.dxfEntity_0, this.wireframe_0, plotColor, forText, polylines1, false, true); transformer.SetPreTransform(Transformation4D.Translation(0.0, 0.0, extrusion)); IList <Polyline4D> polylines2 = DxfUtil.smethod_39(flattened, filled, transformer); graphicsFactory0.CreatePathAsOne(this.dxfEntity_0, this.wireframe_0, plotColor, forText, polylines2, false, true); for (int index1 = polylines1.Count - 1; index1 >= 0; --index1) { Polyline4D polyline4D1 = polylines1[index1]; Polyline4D polyline4D2 = polylines2[index1]; for (int index2 = polyline4D1.Count - 1; index2 >= 0; --index2) { graphicsFactory0.CreateLine(this.dxfEntity_0, this.wireframe_0, plotColor, forText, polyline4D1[index2], polyline4D2[index2]); } } } }
public void BeginGeometry( DxfEntity entity, DrawContext.Wireframe drawContext, ArgbColor color, bool forText, bool fill, bool stroke, bool correctForBackgroundColor) { if (this.class925_0 != null) { throw new InvalidOperationException("BeginGeometry calls may not be nested."); } this.class925_0 = new WireframeGraphics2Cache.Class925(entity, drawContext, color, forText, fill, stroke, correctForBackgroundColor); this.linkedListNodeRef_0.Insert((IWireframeDrawable2)this.class925_0); }
internal void method_20( DrawContext.Wireframe context, IWireframeGraphicsFactory graphicsFactory) { ArgbColor[] argbColorArray = new ArgbColor[10] { ArgbColors.Red, ArgbColors.Green, ArgbColors.Blue, ArgbColors.Magenta, ArgbColors.Cyan, ArgbColors.Violet, ArgbColors.Orange, ArgbColors.YellowGreen, ArgbColors.Purple, ArgbColors.DarkOrchid }; ArgbColor color = argbColorArray[(int)this.Id % argbColorArray.Length]; IList <Polyline4D> polylines = this.method_21((DrawContext)context, context.GetTransformer()); if (polylines.Count <= 0) { return; } graphicsFactory.CreatePath((DxfEntity)this, context, color, false, polylines, false, true); }
public GraphicElement2 GetGraphicElement2( ArgbColor color, DxfLineType lineType, double lineTypeScale, bool plinegen) { foreach (IGraphicElement graphicElement in this.list_0) { GraphicElement2 graphicElement2 = graphicElement as GraphicElement2; if (graphicElement2 != null && graphicElement2.Matches(color, lineType, lineTypeScale, plinegen)) { return(graphicElement2); } } return((GraphicElement2)null); }
public void Diffuse(ArgbColor[] data, ArgbColor original, ArgbColor transformed, int x, int y, int width, int height, int levels, int size) { int[] boundries = new int[levels]; for (int i = 0; i < levels; i++) { boundries[i] = i * 255 / (levels - 1); } int[,] matrix; if (size == 3) { matrix = dither3Matrix; } else if (size == 4) { matrix = dither4Matrix; } else if (size == 6) { matrix = dither6Matrix; } else if (size == 8) { matrix = dither8Matrix; } else { matrix = dither2Matrix; } var gray = matrix[x % size, y % size]; double threshold = gray / ((size * size) + 1d); var pixelIntensity = original.R / 255.0; var color = Math.Floor((levels - 1) * pixelIntensity); var reminder = (levels - 1) * pixelIntensity - color; if (reminder >= threshold) { ++color; } var channelValue = boundries[(int)color]; data[y * width + x] = new ArgbColor(original.A, (int)channelValue, (int)channelValue, (int)channelValue); }
public override void DrawInternal( DrawContext.Wireframe context, IWireframeGraphicsFactory2 graphicsFactory) { PointDisplayMode pointDisplayMode = context.Model.Header.PointDisplayMode; bool flag = this.Layer != null && this.Layer == context.DefPointsLayer; if (pointDisplayMode == PointDisplayMode.None && !flag) { return; } ArgbColor plotColor = context.GetPlotColor((DxfEntity)this); IClippingTransformer transformer = context.GetTransformer(); if (this.double_1 != 0.0) { foreach (Segment4D segment4D in (IEnumerable <Segment4D>)transformer.Transform(new Segment3D(this.point3D_0, this.point3D_0 + this.double_1 * this.vector3D_0))) { graphicsFactory.BeginGeometry((DxfEntity)this, context, plotColor, false, false, true, true); graphicsFactory.CreateLine((DxfEntity)this, segment4D.Start, segment4D.End); graphicsFactory.EndGeometry(); } } else if (pointDisplayMode != PointDisplayMode.Point && context.Model.Header.PointDisplaySize > 0.0 && !flag) { IShape4D shape = transformer.Transform((IShape4D) new FlatShape4D(context.PointShape2D, Transformation4D.Translation(this.point3D_0.X, this.point3D_0.Y, this.point3D_0.Z), false)); if (shape.IsEmpty) { return; } graphicsFactory.BeginGeometry((DxfEntity)this, context, plotColor, false, true, false, true); graphicsFactory.CreateShape((DxfEntity)this, shape); graphicsFactory.EndGeometry(); } else { Vector4D?nullable = transformer.Transform(this.point3D_0); if (!nullable.HasValue) { return; } graphicsFactory.BeginGeometry((DxfEntity)this, context, plotColor, false, true, false, true); graphicsFactory.CreateDot((DxfEntity)this, nullable.Value); graphicsFactory.EndGeometry(); } }
/// <summary> /// Initializes a new instance of the <see cref="ArrowStyle"/> class. /// </summary> /// <param name="source">The source style.</param> public ArrowStyle(BaseStyle source) : this() { Stroke = ArgbColor.Create (source.Stroke.A, source.Stroke.R, source.Stroke.G, source.Stroke.B); Fill = ArgbColor.Create (source.Fill.A, source.Fill.R, source.Fill.G, source.Fill.B); Thickness = source.Thickness; LineCap = source.LineCap; Dashes = source.Dashes != null ? source.Dashes : default(string); DashOffset = source.DashOffset; }
static public ArgbColor ToColor(this int[] col) { if (col == null) { return(ArgbColor.Transparent); } if (col.Length == 3) { return(ArgbColor.FromArgb(col[0], col[1], col[2])); } if (col.Length == 4) { return(ArgbColor.FromArgb(col[3], col[0], col[1], col[2])); } throw new Exception("Invalid symbol color: [" + String.Join(",", col) + "]"); }
public Rectangle() { SimpleFillSymbol fillSymbol = new SimpleFillSymbol(); fillSymbol.Color = ArgbColor.FromArgb(40, 255, 255, 100); SimpleLineSymbol lineSymbol = new SimpleLineSymbol(); fillSymbol.OutlineSymbol = lineSymbol; this.Symbol = fillSymbol; Polygon polygon = new Polygon(); Ring ring = new Ring(); ring.AddPoint(new Point(0, 0)); ring.AddPoint(new Point(1, 0)); ring.AddPoint(new Point(1, 1)); ring.AddPoint(new Point(0, 1)); polygon.AddRing(ring); this.Template = polygon; }
public Ellipse() { SimpleFillSymbol fillSymbol = new SimpleFillSymbol(); fillSymbol.Color = ArgbColor.FromArgb(60, 255, 255, 100); SimpleLineSymbol lineSymbol = new SimpleLineSymbol(); fillSymbol.OutlineSymbol = lineSymbol; this.Symbol = fillSymbol; Polygon polygon = new Polygon(); Ring ring = new Ring(); for (double w = 0; w < 2.0 * Math.PI; w += 2.0 * Math.PI / 50) { ring.AddPoint(new Point(0.5 + 0.5 * Math.Cos(w), 0.5 + 0.5 * Math.Sin(w))); } polygon.AddRing(ring); this.Template = polygon; }
public Class925( DxfEntity entity, DrawContext.Wireframe drawContext, ArgbColor color, bool forText, bool fill, bool stroke, bool correctForBackgroundColor) { this.dxfEntity_0 = entity; this.wireframe_0 = drawContext; this.argbColor_0 = color; this.bool_0 = forText; this.bool_1 = fill; this.bool_2 = stroke; this.bool_3 = correctForBackgroundColor; }
static public void AlterSymbolColor(ISymbol symbol, ArgbColor from, ArgbColor to, double fac) { ArgbColor col = AlterColor(from, to, fac); if (symbol is IBrushColor) { ((IBrushColor)symbol).FillColor = col; } if (symbol is IFontColor) { ((IFontColor)symbol).FontColor = col; } if (symbol is IPenColor) { ((IPenColor)symbol).PenColor = col; } }
/// <summary> /// Creates a new <see cref="ShapeStyle"/> instance. /// </summary> /// <param name="name">The shape style name.</param> /// <param name="stroke">The stroke color.</param> /// <param name="fill">The fill color.</param> /// <param name="thickness">The stroke thickness.</param> /// <param name="textStyle">The text style.</param> /// <param name="lineStyle">The line style.</param> /// <param name="startArrowStyle">The start arrow style.</param> /// <param name="endArrowStyle">The end arrow style.</param> /// <returns>The new instance of the <see cref="ShapeStyle"/> class.</returns> public static ShapeStyle Create(string name, ArgbColor stroke, ArgbColor fill, double thickness, TextStyle textStyle, LineStyle lineStyle, ArrowStyle startArrowStyle, ArrowStyle endArrowStyle) { return(new ShapeStyle() { Name = name, Stroke = stroke, Fill = fill, Thickness = thickness, LineCap = LineCap.Round, Dashes = default(string), DashOffset = 0.0, LineStyle = lineStyle, TextStyle = textStyle, StartArrowStyle = startArrowStyle, EndArrowStyle = endArrowStyle }); }
private static string smethod_0(XamlExporter exporter, ArgbColor color) { if (exporter.nullable_0.HasValue) { color = exporter.nullable_0.Value; } else if (exporter.bool_0 && color.Argb == exporter.argbColor_0.Argb) { color = exporter.argbColor_1; } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append('#'); stringBuilder.Append(color.R.ToString("X2")); stringBuilder.Append(color.G.ToString("X2")); stringBuilder.Append(color.B.ToString("X2")); return(stringBuilder.ToString()); }
/// <summary> /// Builds the color mapping by adding all colors in the given table, and also resolving lookups according to the given alpha map. /// </summary> /// <param name="colorTable">The colors that should be added to the current lookup mapping.</param> /// <param name="alphaMap">The alpha mapping that specifies new ARGB colors that should replace any given RGB colors in the color /// table.</param> private void BuildColorMap(ArgbColor[] colorTable, AlphaRemappingTable alphaMap) { foreach (ArgbColor sourceArgbColor in colorTable) if (sourceArgbColor.A == 255) { RgbColor sourceRgbColor = (RgbColor)sourceArgbColor; Color sourceColor = Color.FromArgb(sourceRgbColor.ToArgb()); if (!colorMappingTable.ContainsKey(sourceColor)) { ArgbColor desiredArgbColor; if (!alphaMap.TryGetMapping(sourceRgbColor, out desiredArgbColor)) desiredArgbColor = sourceArgbColor; colorMappingTable.Add(sourceColor, Color.FromArgb(desiredArgbColor.ToArgb())); } } }
/// <summary> /// Draws background rectangle with specified color. /// </summary> /// <param name="dc">The drawing context.</param> /// <param name="c">The backgroud color.</param> /// <param name="width">The width of background rectangle.</param> /// <param name="height">The height of background rectangle.</param> private void DrawBackground(DrawingContext dc, ArgbColor c, double width, double height) { var color = Color.FromArgb(c.A, c.R, c.G, c.B); var brush = new SolidColorBrush(color); var rect = new Rect(0, 0, width, height); dc.FillRectangle(brush, rect); // TODO: brush.Dispose(); }
/// <summary> /// Draws background rectangle with specified color. /// </summary> /// <param name="g">The drawing context.</param> /// <param name="c">The backgroud color.</param> /// <param name="width">The width of background rectangle.</param> /// <param name="height">The height of background rectangle.</param> private void DrawBackground(Graphics g, ArgbColor c, double width, double height) { var brush = new SolidBrush( Color.FromArgb( c.A, c.R, c.G, c.B)); var rect = Rect2.Create(0, 0, width, height); g.FillRectangle( brush, (float)rect.X, (float)rect.Y, (float)rect.Width, (float)rect.Height); brush.Dispose(); }
/// <summary> /// Gets the ARGB color that is mapped to from the given RGB color. /// </summary> /// <param name="source">The source RGB color.</param> /// <param name="destination">When this method returns, contains resulting ARGB color, if a mapping exists; otherwise, the default /// ARGB color. This parameter is passed uninitialized.</param> /// <returns>Returns true if a mapping was found; otherwise, false.</returns> public bool TryGetMapping(RgbColor source, out ArgbColor destination) { return map.TryGetValue(source, out destination); }
/// <summary> /// Creates a new <see cref="ShapeStyle"/> instance. /// </summary> /// <param name="name">The shape style name.</param> /// <param name="stroke">The stroke color.</param> /// <param name="fill">The fill color.</param> /// <param name="thickness">The stroke thickness.</param> /// <param name="textStyle">The text style.</param> /// <param name="lineStyle">The line style.</param> /// <param name="startArrowStyle">The start arrow style.</param> /// <param name="endArrowStyle">The end arrow style.</param> /// <returns>The new instance of the <see cref="ShapeStyle"/> class.</returns> public static ShapeStyle Create(string name, ArgbColor stroke, ArgbColor fill, double thickness, TextStyle textStyle, LineStyle lineStyle, ArrowStyle startArrowStyle, ArrowStyle endArrowStyle) { return new ShapeStyle() { Name = name, Stroke = stroke, Fill = fill, Thickness = thickness, LineCap = LineCap.Round, Dashes = default(string), DashOffset = 0.0, LineStyle = lineStyle, TextStyle = textStyle, StartArrowStyle = startArrowStyle, EndArrowStyle = endArrowStyle }; }