public Form1() { InitializeComponent(); //m_img = Image.FromFile(@"c:\Users\mibu\Desktop\DSC02921.jpg"); m_img = Image.FromFile(@"..\..\test\Saturn_from_Cassini_Orbiter_(2004-10-06).jpg"); // either use multiple overlays, or just one image: if (true) { zoomableImageViewer1.Images.Add(new OverlayBitmap(m_img)); // create grayscale bitmap int width = 200; int height = 200; byte[] data = new byte[width * height]; for (int iy = 0; iy < height; iy++) { for (int ix = 0; ix < width; ix++) { data[ix + iy * width] = (byte)(ix + iy); } } IImageLayer il = new OverlayGrayscale(width, height, data); il.Position = new Point(300, 400); il.Alpha = 0.5; zoomableImageViewer1.Images.Add(il); // create overlay from pointlist short[] pl = new short[2 * width * height]; int count = 0; for (short iy = 0; iy < height; iy++) { for (short ix = 0; ix < width; ix++) { if ((ix + iy < width)) { pl[count++] = ix; pl[count++] = iy; } } } Array.Resize(ref pl, count); il = new OverlayPointList(pl, Color.Yellow); il.Position = new Point(600, 200); il.Alpha = 0.7; zoomableImageViewer1.Images.Add(il); zoomableImageViewer1.updateImageList(); } else { zoomableImageViewer1.Image = m_img; } // create overlay artwork RectangleOverlayArtwork oa = new RectangleOverlayArtwork(new Rectangle(0, 0, 200, 300), 30f / 180f * 3.14159f, Color.Yellow); propertyGrid1.SelectedObject = oa; zoomableImageViewer1.AddOverlay(oa); ZoomableImageViewer.HScaleBar hs = new ZoomableImageViewer.HScaleBar(1, "Hallo {0} {1}m", Color.Green); hs.Scale = 10e-9f; zoomableImageViewer1.AddOverlay(hs); ZoomableImageViewer.HScaleBar vs = new ZoomableImageViewer.VScaleBar(1, "Vallo {0} {1}m", Color.Green); vs.Scale = 10e-9f; zoomableImageViewer1.AddOverlay(vs); ZoomableImageViewer.VCursorOverlayArtwork vc = new VCursorOverlayArtwork(0); zoomableImageViewer1.AddOverlay(vc); toolStrip1.Items.Add(new ToolStripSeparator()); zoomableImageViewer1.AppendToolStrip(toolStrip1); Application.AddMessageFilter(this); }
private void toolStripAddOverlay_Click(object sender, EventArgs e) { RectangleOverlayArtwork oa = new RectangleOverlayArtwork(new Rectangle(400, 500, 200, 300), 0f / 180f * 3.14159f, Color.Red); zoomableImageViewer1.AddOverlay(oa); }