Ejemplo n.º 1
0
        void DisplayLiveView()
        {
            if (LiveViewData == null || LiveViewData.ImageData == null)
            {
                return;
            }
            MemoryStream stream = new MemoryStream(LiveViewData.ImageData,
                                                   LiveViewData.ImageDataPosition,
                                                   LiveViewData.ImageData.Length -
                                                   LiveViewData.ImageDataPosition);

            using (var bmp = new Bitmap(stream))
            {
                Bitmap res = bmp;
                if (Brightness != 0)
                {
                    BrightnessCorrection filter = new BrightnessCorrection(Brightness);
                    res = filter.Apply(res);
                }

                DisplayBitmap = BitmapFactory.ConvertToPbgra32Format(BitmapSourceConvert.ToBitmapSource(res));
                DrawGrid(DisplayBitmap);
                DisplayBitmap.Freeze();
                live_view_image.Source = DisplayBitmap;
            }
        }
Ejemplo n.º 2
0
        protected override void OnDraw(DrawEventArgs e)
        {
            var data = Data;

            if (data is null)
            {
                return;
            }

            // hacky way of checking top view
            if (e.Viewport.IsParallelProjection && e.Viewport.Name == "Top")
            {
                // get rectangle defining points in screen space
                var screenOrigin = e.Viewport.WorldToClient(data.Plane.Origin);
                var topRight     = e.Viewport.WorldToClient(data.Boundary.Corner(2));
                var topLeft      = e.Viewport.WorldToClient(data.Boundary.Corner(3));

                // scale bitmap
                var width  = Math.Abs(topRight.X - screenOrigin.X);
                var height = Math.Abs(topRight.Y - screenOrigin.Y);
                if (width < 0.01 | height < 0.01)
                {
                    return;
                }
                var displayBitmap =
                    new DisplayBitmap(ImageExtensions.ResizeImage(data.Image, Convert.ToInt32(width),
                                                                  Convert.ToInt32(height)));

                // display scaled bitmap
                e.Display.DrawBitmap(displayBitmap, Convert.ToInt32(topLeft.X), Convert.ToInt32(topLeft.Y));
            }
            base.OnDraw(e);
        }
Ejemplo n.º 3
0
            public ReceiverConduit()
                : base()
            {
                System.Drawing.Bitmap RSbmp = Properties.Resources.Receiver_Selected;
                System.Drawing.Bitmap RUbmp = Properties.Resources.Receiver;
                RSbmp.MakeTransparent(System.Drawing.Color.Black);
                RUbmp.MakeTransparent(System.Drawing.Color.Black);
                RS = new DisplayBitmap(RSbmp);
                RU = new DisplayBitmap(RUbmp);

                Instance = this;
            }
Ejemplo n.º 4
0
        private static void OnDrawImageOverlay(object sender, DrawEventArgs args)
        {
            if (args.Display.Viewport.Id != RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewportID || displayImage == null)
            {
                return;
            }

            if (screenSize != args.Viewport.Bounds.Size)
            {
                screenSize = args.Viewport.Bounds.Size;
                bitmap     = DrawInfoImage(displayImage);
            }

            args.Display.DrawBitmap(bitmap, 0, 0);
        }
Ejemplo n.º 5
0
        private static void DrawMessageBitmap(Font font)
        {
            Rectangle rect = new Rectangle(0, 0, messageSize.Width, messageSize.Height);
            Bitmap    bmp  = new Bitmap(messageSize.Width, messageSize.Height);

            // Init GFX
            Graphics g = Graphics.FromImage(bmp);

            g.SmoothingMode     = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            g.PageUnit          = GraphicsUnit.Pixel;
            g.PixelOffsetMode   = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
            g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
            g.Clear(Color.Transparent);

            // Draw BOX
            int rad  = Math.Min(paddingLeftRight, paddingTopBottom);
            int diam = rad * 2;

            Brush     brush = new SolidBrush(Color.FromArgb(180, 59, 59, 59));
            Rectangle box   = new Rectangle(
                paddingLeftRight,
                paddingTopBottom,
                messageSize.Width - 2 * paddingLeftRight,
                messageSize.Height - 2 * paddingTopBottom);

            g.FillRectangle(brush, box);

            box.Inflate(rad, rad);
            g.FillPie(brush, box.Left, box.Top, diam, diam, 180, 90);
            g.FillPie(brush, box.Left, box.Bottom - diam, diam, diam, 90, 90);
            g.FillPie(brush, box.Right - diam, box.Top, diam, diam, 270, 90);
            g.FillPie(brush, box.Right - diam, box.Bottom - diam, diam, diam, 0, 90);

            g.FillRectangle(brush, box.Left, box.Top + rad, rad, box.Height - diam);
            g.FillRectangle(brush, box.Right - rad, box.Top + rad, rad, box.Height - diam);
            g.FillRectangle(brush, box.Left + rad, box.Top, box.Width - diam, rad);
            g.FillRectangle(brush, box.Left + rad, box.Bottom - rad, box.Width - diam, rad);

            // Draw TEXT
            brush = new SolidBrush(Color.White);
            g.DrawString(message, font, brush, rect, messageFormat);


            // SAVE
            g.Save();
            bitmap = new DisplayBitmap(bmp);
        }
Ejemplo n.º 6
0
        public DrawBitmapConduit()
        {
            var flag = new System.Drawing.Bitmap(100, 100);

            for (int x = 0; x < flag.Height; ++x)
            {
                for (int y = 0; y < flag.Width; ++y)
                {
                    flag.SetPixel(x, y, Color.White);
                }
            }

            var g = Graphics.FromImage(flag);

            g.FillEllipse(Brushes.Blue, 25, 25, 50, 50);
            m_display_bitmap = new DisplayBitmap(flag);
        }
        public void SetColorScale(double minValue, double maxValue, double minColor, double maxColor, string label)
        {
            _label = label;

            Bitmap   bm = new System.Drawing.Bitmap(100, 290);
            Graphics g  = Graphics.FromImage(bm);

            g.SmoothingMode     = SmoothingMode.AntiAlias;
            g.InterpolationMode = InterpolationMode.HighQualityBicubic;
            g.PixelOffsetMode   = PixelOffsetMode.HighQuality;

            Rectangle r = new Rectangle(0, 0, 100, 290);

            g.FillRectangle(new SolidBrush(Color.White), r);

            for (int i = 5; i < 260; i++)
            {
                double hue = (minColor + (i - 5.0) * (maxColor - minColor)) / 255.0;

                Color c = new ColorHSL(hue, 1, 0.5);

                for (int j = 5; j < 25; j++)
                {
                    bm.SetPixel(j, i, c);
                }
            }


            //minValue = minValue * 0.001;
            //maxValue = maxValue * 0.001;

            double range        = maxValue - minValue;
            int    numOfNumbers = 10;
            int    step         = 255 / (numOfNumbers - 1);

            Font usedFont = new Font("Tahoma", 8, FontStyle.Bold);

            for (int i = 0; i < numOfNumbers; i++)
            {
                string value = Math.Round((maxValue - i / (numOfNumbers - 1.0) * range), 2).ToString();

                g.DrawString(value, usedFont, Brushes.Black, 30, 1 + i * step);
            }
            g.DrawString(_label, usedFont, Brushes.Black, 2, 270);
            _bm = new DisplayBitmap(bm);
        }
Ejemplo n.º 8
0
    public void DrawParticles(Rhino.Geometry.ParticleSystem particles, DisplayBitmap[] bitmaps)
    {
      particles.UpdateDrawCache();
      uint[] ids = new uint[bitmaps.Length];
      for (int i = 0; i < bitmaps.Length; i++)
        ids[i] = UnsafeNativeMethods.CRhCmnDisplayBitmap_TextureId(m_ptr, bitmaps[i].NonConstPointer());

      UnsafeNativeMethods.CRhinoDisplayPipeline_DrawParticles2(m_ptr, ids.Length, ids, particles.m_points.Length, particles.m_points, particles.m_sizes, particles.m_colors_argb, particles.m_display_bitmap_ids, particles.DisplaySizesInWorldUnits);
    }
Ejemplo n.º 9
0
 public void DrawSprites(DisplayBitmap bitmap, DisplayBitmapDrawList items, float size, Vector3d translation, bool sizeInWorldSpace)
 {
   Vector3d camera_direction = new Vector3d();
   UnsafeNativeMethods.CRhinoDisplayPipeline_GetCameraDirection(m_ptr, ref camera_direction);
   int[] indices = items.Sort(camera_direction);
   IntPtr pBitmap = bitmap.NonConstPointer();
   UnsafeNativeMethods.CRhinoDisplayPipeline_DrawBitmaps(m_ptr, pBitmap, items.m_points.Length, items.m_points, items.m_colors_argb.Length, items.m_colors_argb, indices, size, translation, sizeInWorldSpace);
 }
Ejemplo n.º 10
0
 public void DrawParticles(Rhino.Geometry.ParticleSystem particles, DisplayBitmap bitmap)
 {
   particles.UpdateDrawCache();
   IntPtr pBitmap = bitmap.NonConstPointer();
   UnsafeNativeMethods.CRhinoDisplayPipeline_DrawParticles1(m_ptr, pBitmap, particles.m_points.Length, particles.m_points, particles.m_sizes, particles.m_colors_argb, particles.DisplaySizesInWorldUnits);
 }
Ejemplo n.º 11
0
 public void DrawSprite(DisplayBitmap bitmap, Point2d screenLocation, float size, System.Drawing.Color blendColor)
 {
   IntPtr pBitmap = bitmap.NonConstPointer();
   UnsafeNativeMethods.CRhinoDisplayPipeline_DrawBitmap2(m_ptr, pBitmap, screenLocation, size, blendColor.ToArgb());
 }
Ejemplo n.º 12
0
 public void DrawSprites(DisplayBitmap bitmap, DisplayBitmapDrawList items, float size, bool sizeInWorldSpace)
 {
   DrawSprites(bitmap, items, size, Vector3d.Zero, sizeInWorldSpace);
 }
Ejemplo n.º 13
0
 public void DrawSprite(DisplayBitmap bitmap, Point3d worldLocation, float size, System.Drawing.Color blendColor, bool sizeInWorldSpace)
 {
   IntPtr pBitmap = bitmap.NonConstPointer();
   UnsafeNativeMethods.CRhinoDisplayPipeline_DrawBitmap(m_ptr, pBitmap, worldLocation, size, blendColor.ToArgb(), sizeInWorldSpace);
 }
Ejemplo n.º 14
0
 public void DrawSprite(DisplayBitmap bitmap, Point2d screenLocation, float size)
 {
   DrawSprite(bitmap, screenLocation, size, System.Drawing.Color.White);
 }
Ejemplo n.º 15
0
 public void DrawSprite(DisplayBitmap bitmap, Point3d worldLocation, float size, bool sizeInWorldSpace)
 {
   DrawSprite(bitmap, worldLocation, size, System.Drawing.Color.White, sizeInWorldSpace);
 }
Ejemplo n.º 16
0
 public FaceMeDisplay(Bitmap bitmap)
 {
     Dbm = new DisplayBitmap(bitmap);
     System.DisplaySizesInWorldUnits = true;
 }
Ejemplo n.º 17
0
 public RhinoTool(DisplayBitmap icon, string englishName)
 {
     this.Bitmap      = icon;
     this.EnglishName = englishName;
 }
 /// <summary>
 /// Draws a bitmap in screen coordinates
 /// </summary>
 /// <param name="bitmap">bitmap to draw</param>
 /// <param name="left">where top/left corner of bitmap should appear in screen coordinates</param>
 /// <param name="top">where top/left corner of bitmap should appear in screen coordinates</param>
 public void DrawBitmap(DisplayBitmap bitmap, int left, int top)
 {
   DrawBitmap(bitmap, left, top, System.Drawing.Color.Empty);
 }
 /// <summary>
 /// Draws a bitmap in screen coordinates
 /// </summary>
 /// <param name="bitmap">bitmap to draw</param>
 /// <param name="left">where top/left corner of bitmap should appear in screen coordinates</param>
 /// <param name="top">where top/left corner of bitmap should appear in screen coordinates</param>
 /// <param name="maskColor">mask color to apply to bitmap for transparent regions</param>
 public void DrawBitmap(DisplayBitmap bitmap, int left, int top, System.Drawing.Color maskColor)
 {
   IntPtr ptr_bitmap = bitmap.NonConstPointer();
   int argb = maskColor.ToArgb();
   UnsafeNativeMethods.CRhinoDisplayPipeline_DrawBitmap3(m_ptr, ptr_bitmap, left, top, argb);
 }