/// <summary> 绘制坐标系 </summary> void DrawCoordinateGrid() { { int span = 20; for (int i = 0; i < this.writeableBmp.PixelHeight; i++) { if (i < (int)margin.Top) { continue; } if (i > (this.writeableBmp.PixelHeight - (int)margin.Bottom)) { continue; } if ((i - (int)margin.Top) % span == 0) { // Do :绘制X坐标 int x0 = (int)margin.Left; int y0 = i; int x1 = this.writeableBmp.PixelWidth - (int)margin.Right; int y1 = i; writeableBmp.DrawLine(x0, y0, x1, y1, Colors.White); } } } { int span = 40; for (int i = 0; i < this.writeableBmp.PixelWidth; i++) { if (i < (int)margin.Left) { continue; } if (i > (this.writeableBmp.PixelWidth - (int)margin.Right)) { continue; } if ((i - (int)margin.Left) % span == 0) { // Do :绘制Y坐标 int x0 = i; int y0 = (int)margin.Top; int x1 = i; int y1 = this.writeableBmp.PixelHeight - (int)margin.Bottom; writeableBmp.DrawLine(x0, y0, x1, y1, Colors.White); } } } }
void SensorColorFrameReady(object sender, kinect.ColorImageFrameReadyEventArgs e) { using (kinect.ColorImageFrame colorFrame = e.OpenColorImageFrame()) { if (colorFrame != null) { // Copy the pixel data from the image to a temporary array colorFrame.CopyPixelDataTo(this.colorFramePixels); for (int i = 3; i < this.colorFramePixels.Length - 4; i += 4) { this.colorFramePixels[i] = 255; // set the alpha to max } // Write the pixel data into our bitmap this.colorBitmapVideo.WritePixels( new Int32Rect(0, 0, this.colorBitmapVideo.PixelWidth, this.colorBitmapVideo.PixelHeight), this.colorFramePixels, this.colorBitmapVideo.PixelWidth * sizeof(int), 0); } } // draw a sighting frame for precise alignment: // Horisontally the frame spans 16.56 degrees on every side and 12.75 degrees either up or down (at 74" the size it covers is 44"W by 33.5"H, i.e. 33.12 degrees by 25.5 degrees) // see http://writeablebitmapex.codeplex.com/ //int sightFrameColor = 255; // Pbgra32 Color sightFrameColor = Colors.Red; colorBitmapVideo.DrawLine((int)colorBitmapVideo.Width / 2, 0, (int)colorBitmapVideo.Width / 2, (int)colorBitmapVideo.Height, sightFrameColor); colorBitmapVideo.DrawLine(0, (int)colorBitmapVideo.Height / 2, (int)colorBitmapVideo.Width, (int)colorBitmapVideo.Height / 2, sightFrameColor); colorBitmapVideo.DrawRectangle((int)colorBitmapVideo.Width / 4, (int)colorBitmapVideo.Height / 4, (int)colorBitmapVideo.Width * 3 / 4, (int)colorBitmapVideo.Height * 3 / 4, sightFrameColor); }
private void RenderOscilloscope(Sample Sample) { Dispatcher.BeginInvoke(() => { int y = 0; int x = 0; const int leftOffset = 10; int sampleWidth = Sample.PreparedData.Length; int previousLeftX = leftOffset; int previousLeftY = 128; if (!(_clearEffectIsEnabled)) { ClearOutputBitmap(); } for (int sampleIndex = 0; sampleIndex < sampleWidth; sampleIndex++) { x = sampleIndex + leftOffset; y = ((Sample.PreparedData[sampleIndex] >> 8) + 192); _outputWriteableBitmap.DrawLine(previousLeftX, previousLeftY, x, y, _primaryColour); previousLeftX = x; previousLeftY = y; } if (_clearEffectIsEnabled) { RunClearEffect(); } FlushOutputBitmap(); }); }
/// <summary> /// Draws a quad. /// </summary> /// <param name="bmp">The WriteableBitmap.</param> /// <param name="x1">The x-coordinate of the 1st point.</param> /// <param name="y1">The y-coordinate of the 1st point.</param> /// <param name="x2">The x-coordinate of the 2nd point.</param> /// <param name="y2">The y-coordinate of the 2nd point.</param> /// <param name="x3">The x-coordinate of the 3rd point.</param> /// <param name="y3">The y-coordinate of the 3rd point.</param> /// <param name="x4">The x-coordinate of the 4th point.</param> /// <param name="y4">The y-coordinate of the 4th point.</param> /// <param name="color">The color.</param> public static void DrawQuad(this WriteableBitmap bmp, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4, int color) { bmp.DrawLine(x1, y1, x2, y2, color); bmp.DrawLine(x2, y2, x3, y3, color); bmp.DrawLine(x3, y3, x4, y4, color); bmp.DrawLine(x4, y4, x1, y1, color); }
public void draw() { switch (dt) { case Drawtype.point: this.drawlayer.SetPixel((int)mousepos.X, (int)mousepos.Y, c); break; case Drawtype.line: drawlayer.DrawLine((int)origin.X, (int)origin.Y, (int)mousepos.X, (int)mousepos.Y, c); break; case Drawtype.circle: drawlayer.DrawEllipse((int)origin.X, (int)origin.Y, (int)mousepos.X, (int)mousepos.Y, c); break; case Drawtype.rectangle: drawlayer.DrawRectangle((int)origin.X, (int)origin.Y, (int)mousepos.X, (int)mousepos.Y, c); break; case Drawtype.fillrectangle: drawlayer.FillRectangle((int)origin.X, (int)origin.Y, (int)mousepos.X, (int)mousepos.Y, c); break; case Drawtype.fillcircle: drawlayer.FillEllipse((int)origin.X, (int)origin.Y, (int)mousepos.X, (int)mousepos.Y, c); break; } }
private void button1_Click(object sender, EventArgs e) { using (Bitmap bmp1 = new Bitmap(400, 500)) using (var bmplock = bmp1.Lock()) { WriteableBitmap wb = bmplock.GetWritableBitmap(); //lines int y = 0; wb.DrawLine(0, y, 100, y + 100, System.Windows.Media.Imaging.Color.FromArgb(255, 255, 0, 0)); //red wb.DrawLine(0, y + 100, 100, y + 0, System.Windows.Media.Imaging.Color.FromArgb(255, 0, 0, 255)); //blue wb.DrawLineAa(100, y, 200, y + 100, System.Windows.Media.Imaging.Color.FromArgb(255, 255, 0, 0)); wb.DrawLineAa(100, y + 100, 200, y + 0, System.Windows.Media.Imaging.Color.FromArgb(255, 0, 0, 255)); //blue //---------- y += 150; wb.DrawLineDDA(0, y, 100, y + 100, System.Windows.Media.Imaging.Color.FromArgb(255, 255, 0, 0)); //red wb.DrawLineDDA(0, y + 100, 100, y + 0, System.Windows.Media.Imaging.Color.FromArgb(255, 0, 0, 255)); //blue wb.DrawEllipse(200, 0, 300, 100, System.Windows.Media.Imaging.Color.FromArgb(255, 255, 0, 0)); // bmplock.WriteAndUnlock(); bmp1.Save("d:\\WImageTest\\a0002.png"); } }
private static void DrawGrid( WriteableBitmap writeableBitmap, int previewSize, int offset) { const int divisionCells = 10; var sideWidth = offset * 2 + previewSize; for (var i = 0; i <= divisionCells; ++i) { var additionalOffset = (i * previewSize) / divisionCells; writeableBitmap.DrawLine( additionalOffset + offset, offset, additionalOffset + offset, sideWidth - offset, Colors.Gray ); writeableBitmap.DrawLine( offset, additionalOffset + offset, sideWidth - offset, additionalOffset + offset, Colors.Gray ); } }
public override WriteableBitmap PreviewTool() { var bmp = new WriteableBitmap(_wvm.Brush.Width + 1, _wvm.Brush.Height + 1, 96, 96, PixelFormats.Bgra32, null); bmp.Clear(); if (_wvm.Brush.Shape == BrushShape.Square || _wvm.Brush.Height <= 1 || _wvm.Brush.Width <= 1) { bmp.FillRectangle(0, 0, _wvm.Brush.Width, _wvm.Brush.Height, Color.FromArgb(127, 0, 90, 255)); } else if (_wvm.Brush.Shape == BrushShape.Left) { bmp.DrawLine(0, 0, _wvm.Brush.Width, _wvm.Brush.Height, Color.FromArgb(127, 0, 90, 255)); } else if (_wvm.Brush.Shape == BrushShape.Right) { bmp.DrawLine(0, _wvm.Brush.Height, _wvm.Brush.Width, 0, Color.FromArgb(127, 0, 90, 255)); } else { bmp.FillEllipse(0, 0, _wvm.Brush.Width, _wvm.Brush.Height, Color.FromArgb(127, 0, 90, 255)); } _preview = bmp; return(_preview); }
/// <summary> /// Draws the different types of shapes. /// </summary> private void DrawStaticShapes() { // Init some size vars int w = this.writeableBmp.PixelWidth - 2; int h = this.writeableBmp.PixelHeight - 2; int w3rd = w / 3; int h3rd = h / 3; int w6th = w3rd >> 1; int h6th = h3rd >> 1; // Clear writeableBmp.Clear(); // Draw some points for (int i = 0; i < 200; i++) { writeableBmp.SetPixel(rand.Next(w3rd), rand.Next(h3rd), GetRandomColor()); } // Draw Standard shapes writeableBmp.DrawLine(rand.Next(w3rd, w3rd * 2), rand.Next(h3rd), rand.Next(w3rd, w3rd * 2), rand.Next(h3rd), GetRandomColor()); writeableBmp.DrawTriangle(rand.Next(w3rd * 2, w - w6th), rand.Next(h6th), rand.Next(w3rd * 2, w), rand.Next(h6th, h3rd), rand.Next(w - w6th, w), rand.Next(h3rd), GetRandomColor()); writeableBmp.DrawQuad(rand.Next(0, w6th), rand.Next(h3rd, h3rd + h6th), rand.Next(w6th, w3rd), rand.Next(h3rd, h3rd + h6th), rand.Next(w6th, w3rd), rand.Next(h3rd + h6th, 2 * h3rd), rand.Next(0, w6th), rand.Next(h3rd + h6th, 2 * h3rd), GetRandomColor()); writeableBmp.DrawRectangle(rand.Next(w3rd, w3rd + w6th), rand.Next(h3rd, h3rd + h6th), rand.Next(w3rd + w6th, w3rd * 2), rand.Next(h3rd + h6th, 2 * h3rd), GetRandomColor()); // Random polyline int[] p = new int[rand.Next(7, 10) * 2]; for (int j = 0; j < p.Length; j += 2) { p[j] = rand.Next(w3rd * 2, w); p[j + 1] = rand.Next(h3rd, 2 * h3rd); } writeableBmp.DrawPolyline(p, GetRandomColor()); // Random closed polyline p = new int[rand.Next(6, 9) * 2]; for (int j = 0; j < p.Length - 2; j += 2) { p[j] = rand.Next(w3rd); p[j + 1] = rand.Next(2 * h3rd, h); } p[p.Length - 2] = p[0]; p[p.Length - 1] = p[1]; writeableBmp.DrawPolyline(p, GetRandomColor()); // Ellipses writeableBmp.DrawEllipse(rand.Next(w3rd, w3rd + w6th), rand.Next(h3rd * 2, h - h6th), rand.Next(w3rd + w6th, w3rd * 2), rand.Next(h - h6th, h), GetRandomColor()); writeableBmp.DrawEllipseCentered(w - w6th, h - h6th, w6th >> 1, h6th >> 1, GetRandomColor()); // Draw Grid writeableBmp.DrawLine(0, h3rd, w, h3rd, Colors.Black); writeableBmp.DrawLine(0, 2 * h3rd, w, 2 * h3rd, Colors.Black); writeableBmp.DrawLine(w3rd, 0, w3rd, h, Colors.Black); writeableBmp.DrawLine(2 * w3rd, 0, 2 * w3rd, h, Colors.Black); // Invalidate writeableBmp.Invalidate(); }
public void DrawXonImage() { int width = m_imageBitmap.PixelWidth - 1; int height = m_imageBitmap.PixelHeight - 1; m_imageBitmap.Lock(); m_imageBitmap.DrawLine(0, 0, width, height, Colors.Red); m_imageBitmap.DrawLine(width, 0, 0, height, Colors.Red); m_imageBitmap.Unlock(); }
public static void DrawRectangle(this WriteableBitmap image, int x1, int y1, int x2, int y2, Color color, int thickness) { if (image == null) { throw new NullReferenceException(); } image.DrawLine(x1, y1, x2, y1, color, thickness); image.DrawLine(x2, y1, x2, y2, color, thickness); image.DrawLine(x2, y2, x1, y2, color, thickness); image.DrawLine(x1, y2, x1, y1, color, thickness); }
public void DrawLine(double x0, double y0, double x1, double y1, DicomColor color, LineType lineType) { if (lineType == LineType.Normal) { _bitmap.DrawLine(transxi(x0), transyi(y0), transxi(x1), transyi(y1), getCachedColor(color)); } else { double hx = x0 + (x1 - x0) / 2; double hy = y0 + (y1 - y0) / 2; _bitmap.DrawLine(transxi(x0), transyi(y0), transxi(hx), transyi(hy), getCachedColor(color)); } }
public static void DrawRelationBox(this WriteableBitmap wb, int x, int y, Relation rel, int number) { if (rel == Relation.NONE) { return; } Color borderCol = Color.FromRgb(0, 0, 0); //wb.DrawLine(x, y, x + 10, y, borderCol); //wb.DrawLine(x, y, x, y + 8, borderCol); //wb.DrawLine(x + 10, y, x + 10, y + 8, borderCol); //wb.DrawLine(x, y + 8, x + 10, y + 8, borderCol); if (rel == Relation.EQUALS) { wb.DrawLine(x, y, x + 5, y, borderCol); wb.DrawLine(x, y + 1, x + 5, y + 1, borderCol); wb.DrawLine(x, y + 4, x + 5, y + 4, borderCol); wb.DrawLine(x, y + 5, x + 5, y + 5, borderCol); } if (rel == Relation.PARALLEL) { wb.DrawLine(x, y, x, y + 7, borderCol); wb.DrawLine(x + 1, y, x + 1, y + 7, borderCol); wb.DrawLine(x + 4, y, x + 4, y + 7, borderCol); wb.DrawLine(x + 5, y, x + 5, y + 7, borderCol); } wb.DrawDigit(x + 8, y, number, borderCol); }
public void GenerateChart() { WriteableBitmap chartBitMap = BitmapFactory.New(_bitMapWidth, _bitMapHeight); using (chartBitMap.GetBitmapContext()) { var rec1StartPoin = new Point() { X = 2, Y = 2 }; var rec1EndPoint = new Point() { X = _bitMapWidth - 3, Y = _bitMapHeight - 3 }; // Clear the WriteableBitmap with white color chartBitMap.Clear(Colors.Black); chartBitMap.DrawRectangle(rec1StartPoin.X, rec1StartPoin.Y, rec1EndPoint.X, rec1EndPoint.Y, Colors.White); chartBitMap.DrawLine(8, 8, 8, _bitMapHeight - 8, Colors.White); chartBitMap.DrawLine(8, 8, 8, _bitMapHeight - 8, Colors.White); chartBitMap.DrawLine(8, 8 + (_bitMapHeight - 8) / 2, _bitMapWidth - 8, 8 + (_bitMapHeight - 8) / 2, Colors.White); var minValue = 8; var maxValue = _bitMapHeight - 8; var zeroValue = 8 + (_bitMapHeight - 8) / 2; var minArgument = 8; var maxArgument = _bitMapWidth - 8; var tempValue = new int(); var ValueScale = zeroValue - minValue; var ArgumentScale = (maxArgument - minArgument) / 20; var tempPoint = new Point() { X = 8, Y = zeroValue }; for (int i = minArgument; i < maxArgument; i++) { tempValue = (int)((double)(ValueScale - 8) * Math.Sin((double)(i - 8) / (double)ArgumentScale)); //chartBitMap.SetPixel(i,zeroValue-tempValue,Colors.Red); chartBitMap.DrawLine(tempPoint.X, tempPoint.Y, i, zeroValue - tempValue, Colors.Red); tempPoint.X = i; tempPoint.Y = zeroValue - tempValue; } } ChartBitMap = chartBitMap; }
private void UpdateSpectrogramDisplay_DrawOneByOne() { //lock (DisplayLock) { int width = (int)this.SpectrogramViewPortContainer.ActualWidth; int height = (int)this.SpectrogramViewPortContainer.ActualHeight; if (mWriteableBmp == null) { mWriteableBmp = new WriteableBitmap(width, height, 96, 96, PixelFormats.Pbgra32, null); } mWriteableBmp.Lock(); int totalTraceCount = mViewModel.SpectrogramData.Count; for (int j = 0; j < totalTraceCount; j++) { if (height - j < 0) { break; } double[] data = mViewModel.SpectrogramData[totalTraceCount - 1 - j].Value; double xscale = (double)width / (double)data.Length; int lastx = 0; double lastvalue = -999.0; for (int i = 0; i < data.Length; i++) { int x = (int)Math.Round(i * xscale); if (x == lastx && data[i] < lastvalue) { continue; } mWriteableBmp.DrawLine(x, height - j, x + 1, height - j, GetColor(data[i])); lastx = x; lastvalue = data[i]; } } mWriteableBmp.Unlock(); this.SpectrogramImageViewport.Source = mWriteableBmp; } }
public void DrawPlate() { double colWidth = (int)(m_xPixelRange / m_cols); double rowHeight = (int)(m_yPixelRange / m_rows); int x1; int x2; int y1; int y2; m_plateBitmap.Lock(); m_plateBitmap.Clear(); x1 = 0; x2 = (int)(m_cols * colWidth); for (int r = 0; r <= m_rows; r++) { y1 = (int)(r * rowHeight); m_plateBitmap.DrawLine(x1, y1, x2, y1, Colors.Black); } y1 = 0; y2 = (int)(m_rows * rowHeight); for (int c = 0; c <= m_cols; c++) { x1 = (int)(c * colWidth); m_plateBitmap.DrawLine(x1, y1, x1, y2, Colors.Black); } int padding = 2; for (int r = 0; r < m_rows; r++) { for (int c = 0; c < m_cols; c++) { x1 = (int)(c * colWidth); x2 = (int)(x1 + colWidth); y1 = (int)(r * rowHeight); y2 = (int)(y1 + rowHeight); if (m_selected[r, c]) { m_plateBitmap.FillRectangle(x1 + padding + 1, y1 + padding + 1, x2 - padding, y2 - padding, m_SelectedWellColor); } } } m_plateBitmap.Unlock(); }
public WriteableBitmap NalozLinie(WriteableBitmap wejscie) { WriteableBitmap wynik = wejscie; for (int j = 0; j < 8; j++) { wynik.DrawLine(0, j * 60, 300, j * 60, Color.FromRgb(0, 0, 0)); } for (int i = 0; i < 6; i++) { wynik.DrawLine(i * 60, 0, i * 60, 420, Color.FromRgb(0, 0, 0)); } wynik.DrawLine(299, 0, 299, 419, Color.FromRgb(0, 0, 0)); wynik.DrawLine(0, 419, 300, 419, Color.FromRgb(0, 0, 0)); return(wynik); }
/// <summary> /// Draws the collection of <see cref="IGraphicLine"/>s and <see cref="IGraphicPolygon"/>s /// to the screen. /// </summary> public async Task Draw(IEnumerable <IGraphicLine> lines, IEnumerable <IGraphicPolygon> polygons) { try { await _mainDispatcher.InvokeAsync(() => { _bitmap.Clear(); foreach (var gline in lines) { _bitmap.DrawLine( gline.Point1.X , gline.Point1.Y , gline.Point2.X , gline.Point2.Y , _colorCache[gline.Color] ); } foreach (var gpoly in polygons) { var points = new int[gpoly.Points.Count * 2 + 2]; for (int i = 0, c = 0; i < points.Length - 2; i += 2, c++) { var p = gpoly.Points[c]; points[i] = p.X; points[i + 1] = p.Y; } var first = gpoly.Points.First(); points[^ 2] = first.X;
private void DrawLine(WriteableBitmap bmp, DenseVector p1, DenseVector p2) { (int x1, int y1) = ((int)p1.Values[0], (int)p1.Values[1]); (int x2, int y2) = ((int)p2.Values[0], (int)p2.Values[1]); bmp.DrawLine(x1, y1, x2, y2, Colors.Black); }
private void img_move(object sender, MouseEventArgs e) { if (isDrawable) { Point P = e.GetPosition(img); Paint = Buf.Clone(); img.Source = Paint; switch (tool) { case 1: Paint.DrawLine((int)point.X, (int)point.Y, (int)P.X, (int)P.Y, color); point = e.GetPosition(img); Buf = Paint.Clone(); break; case 2: Paint.DrawLineAa((int)point.X, (int)point.Y, (int)P.X, (int)P.Y, color, thickness); break; case 3: Paint.DrawEllipse((int)point.X, (int)point.Y, (int)P.X, (int)P.Y, color); break; } } }
void SignatureCaptureControl_PointerMoved(object sender, PointerRoutedEventArgs e) { _currentPoint = e.GetCurrentPoint(this).Position; _writeableBitmap.DrawLine((int)_currentPoint.X, (int)_currentPoint.Y, (int)_oldPoint.X, (int)_oldPoint.Y, PenColor); this.InvalidateArrange(); _oldPoint = _currentPoint; }
public WriteableBitmap BuildColorMapBitmap(ColorModelContainer modelContainer) { WriteableBitmap bmap = BitmapFactory.New(100, modelContainer.GradientSize); ColorModel model = new ColorModel(modelContainer.Description, modelContainer.MaxPixelValue, modelContainer.GradientSize); for (int i = 0; i < modelContainer.Stops.Count(); i++) { model.InsertColorStop(modelContainer.Stops[i].ColorIndex, modelContainer.Stops[i].Red, modelContainer.Stops[i].Green, modelContainer.Stops[i].Blue); } model.BuildColorGradient(); Color color = new Color(); color.A = 255; for (int i = 0; i < model.m_gradientSize; i++) { color.R = model.m_gradient[i].m_red; color.G = model.m_gradient[i].m_green; color.B = model.m_gradient[i].m_blue; bmap.DrawLine(0, model.m_gradientSize - i, 100, model.m_gradientSize - i, color); } return(bmap); }
private void DrawPolarGrid(WriteableBitmap bitmap) { var markProvider = new PolarAxisMarkProvider { MinStep = 20, MinMajorStep = 100 }; //{ MinStep = 5, MinMajorStep = 25 }; markProvider.IterateRadiusGrid(Viewport.HorizontalAxis, Viewport.VerticalAxis, (x0, y0, x, y) => bitmap.DrawLine((int)x0, (int)y0, (int)x, (int)y, _minorGridColor), false); markProvider.IterateEllipseGrid(Viewport.HorizontalAxis, Viewport.VerticalAxis, (x0, y0, x, y) => bitmap.DrawEllipseCentered((int)x0, (int)y0, (int)x, (int)y, _minorGridColor), false); markProvider.IterateRadiusGrid(Viewport.HorizontalAxis, Viewport.VerticalAxis, (x0, y0, x, y) => bitmap.DrawLine((int)x0, (int)y0, (int)x, (int)y, _majorGridColor), true); markProvider.IterateEllipseGrid(Viewport.HorizontalAxis, Viewport.VerticalAxis, (x0, y0, x, y) => bitmap.DrawEllipseCentered((int)x0, (int)y0, (int)x, (int)y, _majorGridColor), true); }
internal static void Transform(WriteableBitmap context, Geometry original, sb.Point location, int border, int fill) { var geometry = original.GetFlattenedPathGeometry(); foreach (var figure in geometry.Figures) { Point firstLocalPoint = ((PolyLineSegment)figure.Segments[0]).Points[0]; var firstPoint = new Point(firstLocalPoint.X + location.X, firstLocalPoint.Y + location.Y); foreach (var segment in figure.Segments) { if (segment is PolyLineSegment) { var points = ((PolyLineSegment)segment).Points.Select(i => new Point(i.X + location.X, i.Y + location.Y)).ToList(); points.Insert(0, firstPoint); AddLineString(context, points, border, fill); } else if (segment is LineSegment) { var x2 = ((LineSegment)segment).Point.X + location.X; var y2 = ((LineSegment)segment).Point.Y + location.Y; context.DrawLine((int)(firstPoint.X), (int)(firstPoint.Y), (int)(x2), (int)(y2), border); } else { throw new NotImplementedException(); } } } }
public static void DrawLine( WriteableBitmap writeableBitmap, int previewSize, int offset, Parametrisation begin, Parametrisation end ) { var x0 = (int)(begin.U * previewSize); var y0 = (int)(begin.V * previewSize); var x1 = (int)(end.U * previewSize); var y1 = (int)(end.V * previewSize); var maxDistance = (int)(0.8 * previewSize); if (Math.Abs(x0 - x1) > maxDistance || Math.Abs(y0 - y1) > maxDistance) { return; } writeableBitmap.DrawLine( offset + x0, offset + y0, offset + x1, offset + y1, Colors.Red ); }
public void DrawColorMap() { if (m_colorModel == null) { return; } int colorMapHeight = 40; if (m_colorMapBitmap == null) { m_colorMapBitmap = BitmapFactory.New(m_colorModel.m_maxPixelValue, colorMapHeight); ColorMapImage.Source = m_colorMapBitmap; } for (int i = 0; i < m_colorModel.m_maxPixelValue; i++) { Color color = new Color(); color.A = 255; color.R = m_colorModel.m_colorMap[i].m_red; color.G = m_colorModel.m_colorMap[i].m_green; color.B = m_colorModel.m_colorMap[i].m_blue; m_colorMapBitmap.DrawLine(i, 0, i, colorMapHeight, color); } }
public void DrawColorGradient() { if (m_colorModel == null) { return; } int gradWidth = 40; if (m_gradientBitmap == null) { m_gradientBitmap = BitmapFactory.New(gradWidth, m_colorModel.m_gradientSize); GradientImage.Source = m_gradientBitmap; } for (int i = 0; i < m_colorModel.m_gradientSize; i++) { Color color = new Color(); color.A = 255; color.R = m_colorModel.m_gradient[i].m_red; color.G = m_colorModel.m_gradient[i].m_green; color.B = m_colorModel.m_gradient[i].m_blue; m_gradientBitmap.DrawLine(0, m_colorModel.m_gradientSize - 1 - i, gradWidth, m_colorModel.m_gradientSize - 1 - i, color); } }
public unsafe void Draw(uint[] energyLevels) { source.Lock(); source.Clear(); if (energyLevels != null) { double widthScaleFactor = (double)WidthInPixels / energyLevels.Length; double heightScaleFactor = 1; if (GraphType == FourierGui.GraphType.Sample) { heightScaleFactor = (double)HeightInPixels / MaximumSample; } else if (GraphType == FourierGui.GraphType.Fourier) { heightScaleFactor = (double)HeightInPixels / energyLevels.Skip(1).Max(); } for (int i = 0; i < energyLevels.Length - 1; i++) { source.DrawLine((int)(i * widthScaleFactor), (int)(HeightInPixels - energyLevels[i] * heightScaleFactor), (int)((i + 1) * widthScaleFactor), (int)(HeightInPixels - energyLevels[i + 1] * heightScaleFactor), Colors.Black); } } source.AddDirtyRect(new Int32Rect(0, 0, source.PixelWidth, source.PixelHeight)); source.Unlock(); }
public WriteableBitmap WyczyscINalozLinie() { WriteableBitmap wynik = new WriteableBitmap(300, 420, 96, 96, PixelFormats.Bgr32, null); wynik.Clear(Color.FromRgb(255, 255, 255)); for (int j = 0; j < 8; j++) { wynik.DrawLine(0, j * 60, 300, j * 60, Color.FromRgb(0, 0, 0)); } for (int i = 0; i < 6; i++) { wynik.DrawLine(i * 60, 0, i * 60, 420, Color.FromRgb(0, 0, 0)); } wynik.DrawLine(299, 0, 299, 419, Color.FromRgb(0, 0, 0)); wynik.DrawLine(0, 419, 300, 419, Color.FromRgb(0, 0, 0)); return(wynik); }
public void DrawLine(double startX, double startY, double endX, double endY, Color color) { startX = Offset.X + startX * Scale; startY = Offset.Y + startY * Scale; endX = Offset.X + endX * Scale; endY = Offset.Y + endY * Scale; bmp.DrawLine((int)startX, (int)startY, (int)endX, (int)endY, color); }