Exemple #1
0
        public override void DrawImage(RectangleF rect, RectangleF full, int lv, Graphics g)
        {
            var rg_lay = Utils.GetRect(ext, lv);

            var px = (int)((rg_lay.X - full.X) * 256 - rect.X);
            var py = (int)((rg_lay.Y - full.Y) * 256 - rect.Y);

            if (px + rg_lay.Width < 0 || py + rg_lay.Height < 0) return;
            if (px > rect.Width || py > rect.Height) return;

            var tif = new Tiff(file);
            var bmp = tif.Pics[0].GetImage(new Rectangle(px, py, 4096, 4096), new Size((int)rg_lay.Width, (int)rg_lay.Height));
            if (bmp == null) return;
            g.DrawImage(bmp, Math.Max(px, 0), Math.Max(py, 0));
            bmp.Dispose();
            GC.Collect();
            Debug.WriteLine("draw->" + file);
        }
Exemple #2
0
        public static void DrawImage(Layer lay, RectangleF rect, RectangleF full, int lv, Graphics g)
        {
            var rg_lay = GetRect(lay.Extends, lv);

            if (lay.Tp == 1)
            {
                var px = (int)((rg_lay.X - full.X) * 256 - rect.X);
                var py = (int)((rg_lay.Y - full.Y) * 256 - rect.Y);

                if (px + rg_lay.Width < 0 || py + rg_lay.Height < 0)
                {
                    return;
                }
                if (px > rect.Width || py > rect.Height)
                {
                    return;
                }

                var tif = new Tiff(lay.File);
                var bmp = tif.Pics[0].GetImage(new Rectangle(px, py, (int)rect.Width, (int)rect.Height), new Size((int)rg_lay.Width, (int)rg_lay.Height));
                if (bmp == null)
                {
                    return;
                }
                g.DrawImage(bmp, Math.Max(px, 0), Math.Max(py, 0));
                bmp.Dispose();
                GC.Collect();
            }
            else
            {
                var l = lay as ShpLayer;
                if (l.Shapes == null)
                {
                    return;
                }
                foreach (var s in l.Shapes)
                {
                    var pts  = new List <PointF>();
                    var _pts = new List <PointF>();
                    foreach (var k in s.Points.Keys)
                    {
                        var ps = getPoints(s.Points[k], full.X, full.Y, rect.X, rect.Y, lv).Where(o => o.X > -rect.Width * 0.5 && o.Y > -rect.Height * 0.5 && o.X < rect.Width * 1.5 && o.Y < rect.Height * 1.5).ToList();
                        if (ps.Count() == 0)
                        {
                            continue;
                        }
                        pts.AddRange(ps);
                        _pts.Add(ps[0]);
                    }
                    if (pts.Count == 0)
                    {
                        continue;
                    }
                    if (s.Tp == 3 || s.Tp == 13)
                    {
                        if (l.Style.BorderWidth > 0)
                        {
                            g.DrawLines(new Pen(Color.FromArgb(l.Style.BorderTran, l.Style.BorderColor), l.Style.BorderWidth), pts.ToArray());
                        }
                    }
                    else if (s.Tp == 5 || s.Tp == 15)
                    {
                        _pts.Reverse();
                        pts.AddRange(_pts);
                        g.FillPolygon(new SolidBrush(Color.FromArgb(l.Style.FillTran, l.Style.FillColor)), pts.ToArray());
                    }
                }
            }
            Debug.WriteLine("draw->" + lay.File);
        }