public ArgbColor GetColor(DrawContext context) { ArgbColor baseColor; if (this.DxfColor == null) { if (this.entityColor_0 == EntityColor.ByBlock) { baseColor = context.ByBlockDxfColor == null?context.ByBlockColor.ToArgbColor(context.Config.IndexedColors) : context.ByBlockDxfColor.Color.ToArgbColor(context.Config.IndexedColors); } else if (this.entityColor_0 == EntityColor.ByLayer) { DxfLayer layer = this.GetLayer(context); baseColor = layer == null ? context.Config.IndexedColors[7] : layer.GetColor(context.Viewport).ToArgbColor(context.Config.IndexedColors); } else { baseColor = this.Color.ToArgbColor(context.Config.IndexedColors); } } else { baseColor = this.DxfColor.Color.ToArgbColor(context.Config.IndexedColors); } byte alpha = this.GetAlpha(context); if (alpha != byte.MaxValue) { return(ArgbColor.FromArgb((int)alpha, baseColor)); } return(baseColor); }
public void Load(IPersistStream stream) { base.Load(stream); this.Color = ArgbColor.FromArgb((int)stream.Load("color", ArgbColor.Red.ToArgb())); _outlineSymbol = (ISymbol)stream.Load("outlinesymbol"); }
static public ISymbol CreateStandardHighlightSymbol(geometryType type) { ISymbol symbol = null; switch (type) { case geometryType.Envelope: case geometryType.Polygon: symbol = new SimpleFillSymbol(); ((SimpleFillSymbol)symbol).Color = ArgbColor.FromArgb(100, 255, 255, 0); ((SimpleFillSymbol)symbol).OutlineSymbol = new SimpleLineSymbol(); ((SimpleLineSymbol)((SimpleFillSymbol)symbol).OutlineSymbol).Color = ArgbColor.Yellow; ((SimpleLineSymbol)((SimpleFillSymbol)symbol).OutlineSymbol).Width = 5; break; case geometryType.Polyline: symbol = new SimpleLineSymbol(); ((SimpleLineSymbol)symbol).Color = ArgbColor.Yellow; ((SimpleLineSymbol)symbol).Width = 5; break; case geometryType.Point: symbol = new SimplePointSymbol(); ((SimplePointSymbol)symbol).Color = ArgbColor.Yellow; ((SimplePointSymbol)symbol).Size = 10; break; } return(symbol); }
public EditSketch(IGeometry geometry) { _geometry = geometry; //geometry.Clone() as IGeometry; if (geometry is IPoint || geometry is IMultiPoint) { _symbol = new SimplePointSymbol(); ((SimplePointSymbol)_symbol).Size = 14; ((SimplePointSymbol)_symbol).Marker = SimplePointSymbol.MarkerType.Star; ((SimplePointSymbol)_symbol).Color = ArgbColor.Yellow; } else if (geometry is IPolyline) { _symbol = new SimpleLineSymbol(); ((SimpleLineSymbol)_symbol).Color = ArgbColor.Yellow; ((SimpleLineSymbol)_symbol).Width = 2.0f; ((SimpleLineSymbol)_symbol).PenDashStyle = LineDashStyle.Solid; } else if (geometry is IPolygon) { SimpleLineSymbol outlineSymbol = new SimpleLineSymbol(); outlineSymbol.Color = ArgbColor.Orange; outlineSymbol.Width = 2.0f; outlineSymbol.PenDashStyle = LineDashStyle.Solid; _symbol = new SimpleFillSymbol(); ((SimpleFillSymbol)_symbol).Color = ArgbColor.FromArgb(125, ArgbColor.Yellow); ((SimpleFillSymbol)_symbol).OutlineSymbol = outlineSymbol; } }
public void Load(gView.Framework.IO.IPersistStream stream) { MinValue = (double)stream.Load("MinValue", 0.0); MaxValue = (double)stream.Load("MaxValue", 0.0); Color = ArgbColor.FromArgb((int)stream.Load("Color", ArgbColor.White.ToArgb())); Legend = (string)stream.Load("Legend", String.Empty); }
override public void Load(IPersistStream stream) { base.Load(stream); this.GlowingColor = ArgbColor.FromArgb((int)stream.Load("outlinecolor", ArgbColor.Yellow.ToArgb())); this.GlowingSmoothingmode = (SymbolSmoothing)stream.Load("outlinesmoothing", (int)this.Smoothingmode); this.GlowingWidth = (int)stream.Load("outlinewidth", 1); }
public void Load(IPersistStream stream) { base.Load(stream); this.ForeColor = ArgbColor.FromArgb((int)stream.Load("forecolor", ArgbColor.Red.ToArgb())); this.BackColor = ArgbColor.FromArgb((int)stream.Load("backcolor", ArgbColor.Transparent.ToArgb())); this.HatchStyle = (HatchStyle)stream.Load("hatchstyle", HatchStyle.Horizontal); _outlineSymbol = (ISymbol)stream.Load("outlinesymbol"); }
public bool IsEmptyBitmap(IBitmap bitmap, ArgbColor backgroundColor) { BitmapPixelData bmData = null; try { bmData = bitmap.LockBitmapPixelData(BitmapLockMode.ReadOnly, PixelFormat.Rgba32); int stride = bmData.Stride; IntPtr Scan0 = bmData.Scan0; int backgroundColorValue = ArgbColor.FromArgb( backgroundColor.A, backgroundColor.R, backgroundColor.G, backgroundColor.B).ToArgb(); unsafe { byte *p = (byte *)(void *)Scan0; int nOffset = stride - bitmap.Width * 4; for (int y = 0; y < bitmap.Height; ++y) { for (int x = 0; x < bitmap.Width; ++x) { byte blue = p[0]; byte green = p[1]; byte red = p[2]; byte alpha = p[3]; if (alpha != 0) // Not transparent { int pixelValue = ArgbColor.FromArgb(alpha, red, green, blue).ToArgb(); if (!pixelValue.Equals(backgroundColorValue)) { return(false); } } p += 4; } p += nOffset; } } } finally { if (bitmap != null && bmData != null) { bitmap.UnlockBitmapPixelData(bmData); } } return(true); }
public double GetStdDev(IBitmap bitmap) { double total = 0, totalVariance = 0; int count = 0; double stdDev = 0; // First get all the bytes BitmapPixelData bmData = null; try { bmData = bitmap.LockBitmapPixelData(BitmapLockMode.ReadOnly, bitmap.PixelFormat); int stride = bmData.Stride; IntPtr Scan0 = bmData.Scan0; unsafe { byte *p = (byte *)(void *)Scan0; int nOffset = stride - bitmap.Width * 3; for (int y = 0; y < bitmap.Height; ++y) { for (int x = 0; x < bitmap.Width; ++x) { count++; byte blue = p[0]; byte green = p[1]; byte red = p[2]; int pixelValue = ArgbColor.FromArgb(0, red, green, blue).ToArgb(); total += pixelValue; double avg = total / count; totalVariance += Math.Pow(pixelValue - avg, 2); stdDev = Math.Sqrt(totalVariance / count); p += 3; } p += nOffset; } } } finally { if (bmData != null) { bitmap.UnlockBitmapPixelData(bmData); } } return(stdDev); }
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; } }
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 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 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; }
private ArgbColor ReadColor(XmlNode cssParameter, XmlNode cssParameter2) { if (cssParameter == null) { return(ArgbColor.Transparent); } try { var col = System.Drawing.ColorTranslator.FromHtml(cssParameter.InnerText); if (cssParameter2 != null) { int alpha = (int)(ReadFloat(cssParameter2) * 255f); col = System.Drawing.Color.FromArgb(alpha, col); } return(ArgbColor.FromArgb(col.ToArgb())); } catch { return(ArgbColor.Transparent); } }
public void Load(IPersistStream stream) { base.Load(stream); HorizontalOffset = (float)stream.Load("xOffset", (float)0); VerticalOffset = (float)stream.Load("yOffset", (float)0); Angle = (float)stream.Load("Angle", (float)0); Size = (float)stream.Load("size", (float)5); SymbolWidth = (float)stream.Load("symbolWidth", (float)0); OutlineWidth = (float)stream.Load("outlinewidth", (float)1); Color = ArgbColor.FromArgb((int)stream.Load("color", ArgbColor.Red.ToArgb())); OutlineColor = ArgbColor.FromArgb((int)stream.Load("outlinecolor", ArgbColor.Black.ToArgb())); Marker = (MarkerType)stream.Load("marker", (int)MarkerType.Circle); this.MaxPenWidth = (float)stream.Load("maxpenwidth", 0f); this.MinPenWidth = (float)stream.Load("minpenwidth", 0f); this.MaxSymbolSize = (float)stream.Load("maxsymbolsize", 0f); this.MinSymbolSize = (float)stream.Load("minsymbolsize", 0f); }
public void Load(IPersistStream stream) { base.Load(stream); this.Color = ArgbColor.FromArgb((int)stream.Load("color", ArgbColor.Black.ToArgb())); this.Width = (float)stream.Load("width", (float)1); this.DashStyle = (LineDashStyle)stream.Load("dashstyle", LineDashStyle.Solid); this.LineStartCap = (LineCap)stream.Load("linescap", LineCap.Flat); this.LineEndCap = (LineCap)stream.Load("lineecap", LineCap.Flat); int cap_old = (int)stream.Load("linecap", -1); if (cap_old >= 0) { this.LineStartCap = this.LineEndCap = (LineCap)cap_old; } this.MaxPenWidth = (float)stream.Load("maxwidth", 0f); this.MinPenWidth = (float)stream.Load("minwidth", 0f); this.PenWidthUnit = (DrawingUnit)stream.Load("widthunit", DrawingUnit.Pixel); }
public SimpleIndexedPalettePixelTransform16() : base(new[] { ArgbColor.FromArgb(0, 0, 0), ArgbColor.FromArgb(128, 0, 0), ArgbColor.FromArgb(0, 128, 0), ArgbColor.FromArgb(128, 128, 0), ArgbColor.FromArgb(0, 0, 128), ArgbColor.FromArgb(128, 0, 128), ArgbColor.FromArgb(0, 128, 128), ArgbColor.FromArgb(128, 128, 128), ArgbColor.FromArgb(192, 192, 192), ArgbColor.FromArgb(255, 0, 0), ArgbColor.FromArgb(0, 255, 0), ArgbColor.FromArgb(255, 255, 0), ArgbColor.FromArgb(0, 0, 255), ArgbColor.FromArgb(255, 0, 255), ArgbColor.FromArgb(0, 255, 255), ArgbColor.FromArgb(255, 255, 255) }) { }
void IErrorDiffusion.Diffuse(ArgbColor[] data, ArgbColor original, ArgbColor transformed, int x, int y, int width, int height) { int row; int col; byte threshold; col = x % _matrixWidth; row = y % _matrixHeight; threshold = _matrix[col, row]; if (threshold > 0) { byte r; byte g; byte b; r = Clamp(transformed.R + threshold); g = Clamp(transformed.G + threshold); b = Clamp(transformed.B + threshold); data[y * width + x] = ArgbColor.FromArgb(original.A, r, g, b); } }
static public ArgbColor AlterColor(ArgbColor from, ArgbColor to, double fac) { if (fac < 0.0) { return(from); } if (fac > 1.0) { return(to); } try { return(ArgbColor.FromArgb( from.A + (int)((double)(to.A - from.A) * fac), from.R + (int)((double)(to.R - from.R) * fac), from.G + (int)((double)(to.G - from.G) * fac), from.B + (int)((double)(to.B - from.B) * fac))); } catch { return(ArgbColor.Transparent); } }
void IErrorDiffusion.Diffuse(ArgbColor[] data, ArgbColor original, ArgbColor transformed, int x, int y, int width, int height) { int redError; int blueError; int greenError; redError = original.R - transformed.R; blueError = original.G - transformed.G; greenError = original.B - transformed.B; for (int row = 0; row < _matrixHeight; row++) { int offsetY; offsetY = y + row; for (int col = 0; col < _matrixWidth; col++) { int coefficient; int offsetX; coefficient = _matrix[row, col]; offsetX = x + (col - _startingOffset); if (coefficient != 0 && offsetX > 0 && offsetX < width && offsetY > 0 && offsetY < height) { ArgbColor offsetPixel; int offsetIndex; int newR; int newG; int newB; byte r; byte g; byte b; offsetIndex = offsetY * width + offsetX; offsetPixel = data[offsetIndex]; // if the UseShifting property is set, then bit shift the values by the specified // divisor as this is faster than integer division. Otherwise, use integer division if (_useShifting) { newR = (redError * coefficient) >> _divisor; newG = (greenError * coefficient) >> _divisor; newB = (blueError * coefficient) >> _divisor; } else { newR = (redError * coefficient) / _divisor; newG = (greenError * coefficient) / _divisor; newB = (blueError * coefficient) / _divisor; } r = (offsetPixel.R + newR).ToByte(); g = (offsetPixel.G + newG).ToByte(); b = (offsetPixel.B + newB).ToByte(); data[offsetIndex] = ArgbColor.FromArgb(offsetPixel.A, r, g, b); } } } }
virtual public void Load(IPersistStream stream) { base.Load(stream); string err = ""; try { System.IO.MemoryStream ms = new System.IO.MemoryStream(); ASCIIEncoding encoder = new ASCIIEncoding(); string soap = (string)stream.Load("font"); // // Im Size muss Punkt und Komma mit Systemeinstellungen // übereinstimmen // XmlDocument doc = new XmlDocument(); doc.LoadXml(soap); XmlNode sizeNode = doc.SelectSingleNode("//Size"); if (sizeNode != null) { sizeNode.InnerText = sizeNode.InnerText.Replace(".", ","); } soap = doc.OuterXml; // // // ms.Write(encoder.GetBytes(soap), 0, soap.Length); ms.Position = 0; SoapFormatter formatter = new SoapFormatter(); _font = (IFont)formatter.Deserialize <IFont>(ms, stream, this); this.MaxFontSize = (float)stream.Load("maxfontsize", 0f); this.MinFontSize = (float)stream.Load("minfontsize", 0f); } catch (Exception ex) { err = ex.Message; ex = null; } this.Color = ArgbColor.FromArgb((int)stream.Load("color", ArgbColor.Red.ToArgb())); HorizontalOffset = (float)stream.Load("xOffset", (float)0); VerticalOffset = (float)stream.Load("yOffset", (float)0); Angle = (float)stream.Load("Angle", (float)0); _align = (TextSymbolAlignment)stream.Load("Alignment", (int)TextSymbolAlignment.Center); var secAlignments = (string)stream.Load("secAlignments", null); if (!String.IsNullOrWhiteSpace(secAlignments)) { try { this.SecondaryTextSymbolAlignments = secAlignments.Split(',') .Select(s => (TextSymbolAlignment)int.Parse(s)) .Distinct() .ToArray(); } catch { } } this.IncludesSuperScript = (bool)stream.Load("includessuperscript", false); }
public GraphicPolygon() { _symbol = new SimpleFillSymbol(); ((SimpleFillSymbol)_symbol).OutlineSymbol = new SimpleLineSymbol(); ((SimpleFillSymbol)_symbol).Color = ArgbColor.FromArgb(150, 255, 255, 0); }
public void Load(IPersistStream stream) { base.Load(stream); this.Color = ArgbColor.FromArgb((int)stream.Load("color", ArgbColor.White.ToArgb())); }
public SimpleIndexedPalettePixelTransform256() : base(new[] { ArgbColor.FromArgb(0, 0, 0), ArgbColor.FromArgb(128, 0, 0), ArgbColor.FromArgb(0, 128, 0), ArgbColor.FromArgb(128, 128, 0), ArgbColor.FromArgb(0, 0, 128), ArgbColor.FromArgb(128, 0, 128), ArgbColor.FromArgb(0, 128, 128), ArgbColor.FromArgb(192, 192, 192), ArgbColor.FromArgb(128, 128, 128), ArgbColor.FromArgb(255, 0, 0), ArgbColor.FromArgb(0, 255, 0), ArgbColor.FromArgb(255, 255, 0), ArgbColor.FromArgb(0, 0, 255), ArgbColor.FromArgb(255, 0, 255), ArgbColor.FromArgb(0, 255, 255), ArgbColor.FromArgb(255, 255, 255), ArgbColor.FromArgb(25, 25, 25), ArgbColor.FromArgb(51, 51, 51), ArgbColor.FromArgb(76, 76, 76), ArgbColor.FromArgb(90, 90, 90), ArgbColor.FromArgb(102, 102, 102), ArgbColor.FromArgb(115, 115, 115), ArgbColor.FromArgb(128, 128, 128), ArgbColor.FromArgb(141, 141, 141), ArgbColor.FromArgb(153, 153, 153), ArgbColor.FromArgb(166, 166, 166), ArgbColor.FromArgb(178, 178, 178), ArgbColor.FromArgb(192, 192, 192), ArgbColor.FromArgb(204, 204, 204), ArgbColor.FromArgb(218, 218, 218), ArgbColor.FromArgb(230, 230, 230), ArgbColor.FromArgb(243, 243, 243), ArgbColor.FromArgb(63, 0, 0), ArgbColor.FromArgb(92, 0, 0), ArgbColor.FromArgb(120, 0, 0), ArgbColor.FromArgb(148, 0, 0), ArgbColor.FromArgb(177, 0, 0), ArgbColor.FromArgb(205, 0, 0), ArgbColor.FromArgb(233, 0, 0), ArgbColor.FromArgb(254, 7, 7), ArgbColor.FromArgb(255, 35, 35), ArgbColor.FromArgb(255, 63, 63), ArgbColor.FromArgb(255, 92, 92), ArgbColor.FromArgb(255, 120, 120), ArgbColor.FromArgb(254, 148, 148), ArgbColor.FromArgb(255, 177, 177), ArgbColor.FromArgb(254, 205, 205), ArgbColor.FromArgb(255, 233, 233), ArgbColor.FromArgb(63, 23, 0), ArgbColor.FromArgb(92, 34, 0), ArgbColor.FromArgb(120, 45, 0), ArgbColor.FromArgb(148, 55, 0), ArgbColor.FromArgb(177, 66, 0), ArgbColor.FromArgb(205, 77, 0), ArgbColor.FromArgb(233, 87, 0), ArgbColor.FromArgb(254, 100, 7), ArgbColor.FromArgb(255, 117, 35), ArgbColor.FromArgb(255, 135, 63), ArgbColor.FromArgb(255, 153, 92), ArgbColor.FromArgb(255, 170, 120), ArgbColor.FromArgb(254, 188, 148), ArgbColor.FromArgb(255, 206, 177), ArgbColor.FromArgb(254, 224, 205), ArgbColor.FromArgb(255, 241, 233), ArgbColor.FromArgb(63, 47, 0), ArgbColor.FromArgb(92, 69, 0), ArgbColor.FromArgb(120, 90, 0), ArgbColor.FromArgb(148, 111, 0), ArgbColor.FromArgb(177, 132, 0), ArgbColor.FromArgb(205, 154, 0), ArgbColor.FromArgb(233, 175, 0), ArgbColor.FromArgb(254, 193, 7), ArgbColor.FromArgb(255, 200, 35), ArgbColor.FromArgb(255, 207, 63), ArgbColor.FromArgb(255, 214, 92), ArgbColor.FromArgb(255, 221, 120), ArgbColor.FromArgb(254, 228, 148), ArgbColor.FromArgb(255, 235, 177), ArgbColor.FromArgb(254, 242, 205), ArgbColor.FromArgb(255, 249, 233), ArgbColor.FromArgb(55, 63, 0), ArgbColor.FromArgb(80, 92, 0), ArgbColor.FromArgb(105, 120, 0), ArgbColor.FromArgb(130, 148, 0), ArgbColor.FromArgb(154, 177, 0), ArgbColor.FromArgb(179, 205, 0), ArgbColor.FromArgb(204, 233, 0), ArgbColor.FromArgb(224, 254, 7), ArgbColor.FromArgb(227, 255, 35), ArgbColor.FromArgb(231, 255, 63), ArgbColor.FromArgb(234, 255, 92), ArgbColor.FromArgb(238, 255, 120), ArgbColor.FromArgb(241, 254, 148), ArgbColor.FromArgb(245, 255, 177), ArgbColor.FromArgb(248, 254, 205), ArgbColor.FromArgb(252, 255, 233), ArgbColor.FromArgb(31, 63, 0), ArgbColor.FromArgb(46, 92, 0), ArgbColor.FromArgb(60, 120, 0), ArgbColor.FromArgb(74, 148, 0), ArgbColor.FromArgb(88, 177, 0), ArgbColor.FromArgb(102, 205, 0), ArgbColor.FromArgb(116, 233, 0), ArgbColor.FromArgb(131, 254, 7), ArgbColor.FromArgb(145, 255, 35), ArgbColor.FromArgb(159, 255, 63), ArgbColor.FromArgb(173, 255, 92), ArgbColor.FromArgb(187, 255, 120), ArgbColor.FromArgb(201, 254, 148), ArgbColor.FromArgb(216, 255, 177), ArgbColor.FromArgb(230, 254, 205), ArgbColor.FromArgb(244, 255, 233), ArgbColor.FromArgb(7, 63, 0), ArgbColor.FromArgb(11, 92, 0), ArgbColor.FromArgb(15, 120, 0), ArgbColor.FromArgb(18, 148, 0), ArgbColor.FromArgb(22, 177, 0), ArgbColor.FromArgb(25, 205, 0), ArgbColor.FromArgb(29, 233, 0), ArgbColor.FromArgb(38, 254, 7), ArgbColor.FromArgb(62, 255, 35), ArgbColor.FromArgb(87, 255, 63), ArgbColor.FromArgb(112, 255, 92), ArgbColor.FromArgb(137, 255, 120), ArgbColor.FromArgb(162, 254, 148), ArgbColor.FromArgb(186, 255, 177), ArgbColor.FromArgb(211, 254, 205), ArgbColor.FromArgb(236, 255, 233), ArgbColor.FromArgb(0, 63, 15), ArgbColor.FromArgb(0, 92, 23), ArgbColor.FromArgb(0, 120, 30), ArgbColor.FromArgb(0, 148, 37), ArgbColor.FromArgb(0, 177, 44), ArgbColor.FromArgb(0, 205, 51), ArgbColor.FromArgb(0, 233, 58), ArgbColor.FromArgb(7, 254, 69), ArgbColor.FromArgb(35, 255, 90), ArgbColor.FromArgb(63, 255, 111), ArgbColor.FromArgb(92, 255, 132), ArgbColor.FromArgb(120, 255, 154), ArgbColor.FromArgb(148, 254, 175), ArgbColor.FromArgb(177, 255, 196), ArgbColor.FromArgb(205, 254, 217), ArgbColor.FromArgb(233, 255, 239), ArgbColor.FromArgb(0, 63, 39), ArgbColor.FromArgb(0, 92, 57), ArgbColor.FromArgb(0, 120, 75), ArgbColor.FromArgb(0, 148, 92), ArgbColor.FromArgb(0, 177, 110), ArgbColor.FromArgb(0, 205, 128), ArgbColor.FromArgb(0, 233, 146), ArgbColor.FromArgb(7, 254, 162), ArgbColor.FromArgb(35, 255, 172), ArgbColor.FromArgb(63, 255, 183), ArgbColor.FromArgb(92, 255, 193), ArgbColor.FromArgb(120, 255, 204), ArgbColor.FromArgb(148, 254, 215), ArgbColor.FromArgb(177, 255, 225), ArgbColor.FromArgb(205, 254, 236), ArgbColor.FromArgb(233, 255, 247), ArgbColor.FromArgb(0, 63, 63), ArgbColor.FromArgb(0, 92, 92), ArgbColor.FromArgb(0, 120, 120), ArgbColor.FromArgb(0, 148, 148), ArgbColor.FromArgb(0, 177, 177), ArgbColor.FromArgb(0, 205, 205), ArgbColor.FromArgb(0, 233, 233), ArgbColor.FromArgb(7, 254, 254), ArgbColor.FromArgb(35, 255, 255), ArgbColor.FromArgb(63, 255, 255), ArgbColor.FromArgb(92, 255, 255), ArgbColor.FromArgb(120, 255, 255), ArgbColor.FromArgb(148, 254, 254), ArgbColor.FromArgb(177, 255, 255), ArgbColor.FromArgb(205, 254, 254), ArgbColor.FromArgb(233, 255, 255), ArgbColor.FromArgb(0, 39, 63), ArgbColor.FromArgb(0, 57, 92), ArgbColor.FromArgb(0, 75, 120), ArgbColor.FromArgb(0, 92, 148), ArgbColor.FromArgb(0, 110, 177), ArgbColor.FromArgb(0, 128, 205), ArgbColor.FromArgb(0, 146, 233), ArgbColor.FromArgb(7, 162, 254), ArgbColor.FromArgb(35, 172, 255), ArgbColor.FromArgb(63, 183, 255), ArgbColor.FromArgb(92, 193, 255), ArgbColor.FromArgb(120, 204, 255), ArgbColor.FromArgb(148, 215, 254), ArgbColor.FromArgb(177, 225, 255), ArgbColor.FromArgb(205, 236, 254), ArgbColor.FromArgb(233, 247, 255), ArgbColor.FromArgb(0, 15, 63), ArgbColor.FromArgb(0, 23, 92), ArgbColor.FromArgb(0, 30, 120), ArgbColor.FromArgb(0, 37, 148), ArgbColor.FromArgb(0, 44, 177), ArgbColor.FromArgb(0, 51, 205), ArgbColor.FromArgb(0, 58, 233), ArgbColor.FromArgb(7, 69, 254), ArgbColor.FromArgb(35, 90, 255), ArgbColor.FromArgb(63, 111, 255), ArgbColor.FromArgb(92, 132, 255), ArgbColor.FromArgb(120, 154, 255), ArgbColor.FromArgb(148, 175, 254), ArgbColor.FromArgb(177, 196, 255), ArgbColor.FromArgb(205, 217, 254), ArgbColor.FromArgb(233, 239, 255), ArgbColor.FromArgb(7, 0, 63), ArgbColor.FromArgb(11, 0, 92), ArgbColor.FromArgb(15, 0, 120), ArgbColor.FromArgb(18, 0, 148), ArgbColor.FromArgb(22, 0, 177), ArgbColor.FromArgb(25, 0, 205), ArgbColor.FromArgb(29, 0, 233), ArgbColor.FromArgb(38, 7, 254), ArgbColor.FromArgb(62, 35, 255), ArgbColor.FromArgb(87, 63, 255), ArgbColor.FromArgb(112, 92, 255), ArgbColor.FromArgb(137, 120, 255), ArgbColor.FromArgb(162, 148, 254), ArgbColor.FromArgb(186, 177, 255), ArgbColor.FromArgb(211, 205, 254), ArgbColor.FromArgb(236, 233, 255), ArgbColor.FromArgb(31, 0, 63), ArgbColor.FromArgb(46, 0, 92), ArgbColor.FromArgb(60, 0, 120), ArgbColor.FromArgb(74, 0, 148), ArgbColor.FromArgb(88, 0, 177), ArgbColor.FromArgb(102, 0, 205), ArgbColor.FromArgb(116, 0, 233), ArgbColor.FromArgb(131, 7, 254), ArgbColor.FromArgb(145, 35, 255), ArgbColor.FromArgb(159, 63, 255), ArgbColor.FromArgb(173, 92, 255), ArgbColor.FromArgb(187, 120, 255), ArgbColor.FromArgb(201, 148, 254), ArgbColor.FromArgb(216, 177, 255), ArgbColor.FromArgb(230, 205, 254), ArgbColor.FromArgb(244, 233, 255), ArgbColor.FromArgb(55, 0, 63), ArgbColor.FromArgb(80, 0, 92), ArgbColor.FromArgb(105, 0, 120), ArgbColor.FromArgb(130, 0, 148), ArgbColor.FromArgb(154, 0, 177), ArgbColor.FromArgb(179, 0, 205), ArgbColor.FromArgb(204, 0, 233), ArgbColor.FromArgb(224, 7, 254), ArgbColor.FromArgb(227, 35, 255), ArgbColor.FromArgb(231, 63, 255), ArgbColor.FromArgb(234, 92, 255), ArgbColor.FromArgb(238, 120, 255), ArgbColor.FromArgb(241, 148, 254), ArgbColor.FromArgb(245, 177, 255), ArgbColor.FromArgb(248, 205, 254), ArgbColor.FromArgb(252, 233, 255) }) { }
static public ArgbColor ToArgbColor(this Color color) { return(ArgbColor.FromArgb(color.ToArgb())); }
public void Load(IPersistStream stream) { this.Color1 = ArgbColor.FromArgb((int)stream.Load("color1", ArgbColor.Red.ToArgb())); this.Color2 = ArgbColor.FromArgb((int)stream.Load("color2", ArgbColor.Blue.ToArgb())); this.Angle = (float)stream.Load("angle", 0f); }
private IRasterPaintContext PaintImage(int x, int y, int wWidth, int wHeight, int iWidth, int iHeight, ICancelTracker cancelTracker) { if (CancelTracker.Canceled(cancelTracker) || _gDS == null) { return(null); } int pixelSpace = 3; var bitmap = Current.Engine.CreateBitmap(iWidth, iHeight, GraphicsEngine.PixelFormat.Rgb24); var bitmapData = bitmap.LockBitmapPixelData(BitmapLockMode.WriteOnly, GraphicsEngine.PixelFormat.Rgb24); try { int stride = bitmapData.Stride; IntPtr buf = bitmapData.Scan0; List <ArgbColor> colors = new List <ArgbColor>(); for (int i = 1; i <= (_gDS.RasterCount > 3 ? 3 : _gDS.RasterCount); ++i) { using (OSGeo_v1.GDAL.Band band = _gDS.GetRasterBand(i)) { int ch = 0; switch ((ColorInterp)band.GetRasterColorInterpretation()) { case ColorInterp.BlueBand: ch = 0; break; case ColorInterp.GreenBand: ch = 1; break; case ColorInterp.RedBand: ch = 2; break; case ColorInterp.GrayIndex: for (int iColor = 0; iColor < 256; iColor++) { colors.Add(ArgbColor.FromArgb(255, iColor, iColor, iColor)); } break; case ColorInterp.PaletteIndex: OSGeo_v1.GDAL.ColorTable colTable = band.GetRasterColorTable(); if (colTable == null) { break; } int colCount = colTable.GetCount(); for (int iColor = 0; iColor < colCount; iColor++) { OSGeo_v1.GDAL.ColorEntry colEntry = colTable.GetColorEntry(iColor); colors.Add(ArgbColor.FromArgb( colEntry.c4, colEntry.c1, colEntry.c2, colEntry.c3)); } break; } band.ReadRaster(x, y, wWidth, wHeight, new IntPtr(buf.ToInt64() + ch), iWidth, iHeight, OSGeo_v1.GDAL.DataType.GDT_Byte, pixelSpace, stride); } } if (colors.Count > 0) { unsafe { byte *ptr = (byte *)(bitmapData.Scan0); for (int i = 0; i < bitmapData.Height; i++) { if (CancelTracker.Canceled(cancelTracker)) { return(null); } for (int j = 0; j < bitmapData.Width; j++) { // write the logic implementation here byte c = ptr[0]; ArgbColor col = colors[c]; ptr[0] = col.B; ptr[1] = col.G; ptr[2] = col.R; ptr += pixelSpace; } ptr += bitmapData.Stride - bitmapData.Width * pixelSpace; } } } return(new RasterPaintContext(bitmap)); } catch (Exception ex) { if (bitmap != null && bitmapData != null) { bitmap.UnlockBitmapPixelData(bitmapData); bitmapData = null; bitmap.Dispose(); bitmap = null; } throw ex; } finally { if (bitmap != null && bitmapData != null) { bitmap.UnlockBitmapPixelData(bitmapData); } } }
private ICursor QueryImage(int x, int y) { unsafe { int bandCount = _gDS.RasterCount; string[] tags = new string[bandCount + 2]; object[] values = new object[bandCount + 2]; List <ArgbColor> colors = new List <ArgbColor>(); for (int i = 1; i <= bandCount; ++i) { OSGeo_v1.GDAL.Band band = _gDS.GetRasterBand(i); string bandName = ""; switch ((ColorInterp)band.GetRasterColorInterpretation()) { case ColorInterp.BlueBand: bandName = "(blue)"; break; case ColorInterp.GreenBand: bandName = "(green)"; break; case ColorInterp.RedBand: bandName = "(red)"; break; case ColorInterp.GrayIndex: for (int iColor = 0; iColor < 256; iColor++) { colors.Add(ArgbColor.FromArgb(255, iColor, iColor, iColor)); } break; case ColorInterp.PaletteIndex: tags = new string[tags.Length + 4]; values = new object[values.Length + 4]; OSGeo_v1.GDAL.ColorTable colTable = band.GetRasterColorTable(); if (colTable == null) { break; } int colCount = colTable.GetCount(); for (int iColor = 0; iColor < colCount; iColor++) { OSGeo_v1.GDAL.ColorEntry colEntry = colTable.GetColorEntry(iColor); colors.Add(ArgbColor.FromArgb( colEntry.c4, colEntry.c1, colEntry.c2, colEntry.c3)); } break; } int c = 0; int *buf = &c; band.ReadRaster(x, y, 1, 1, (IntPtr)buf, 1, 1, OSGeo_v1.GDAL.DataType.GDT_Int32, 4, 0); band.Dispose(); tags[i + 1] = "Band " + i.ToString() + " " + bandName; values[i + 1] = c; if (colors.Count > 0 && c >= 0 && c < colors.Count) { ArgbColor col = colors[c]; tags[i + 2] = "Alpha"; values[i + 2] = col.A; tags[i + 3] = "Red"; values[i + 3] = col.R; tags[i + 4] = "Green"; values[i + 4] = col.G; tags[i + 5] = "Blue"; values[i + 5] = col.B; } } tags[0] = "ImageX"; values[0] = x; tags[1] = "ImageY"; values[1] = y; return(new QueryCursor(tags, values)); } }
override public void Load(IPersistStream stream) { base.Load(stream); this.ColorOutline = ArgbColor.FromArgb((int)stream.Load("outlinecolor", ArgbColor.Yellow.ToArgb())); }