Ejemplo n.º 1
0
        public static void GenWithTemplate(IEnumerable <BiliInterfaceInfo> binfos, Image bg, string template, int repeat, float offset, string ext = "jpg")
        {
            Zhubang zb = new Zhubang();

            foreach (BiliInterfaceInfo info in binfos)
            {
                BiliInterface.GetPic(info);
            }

            List <Zhubang.TemplateInfo> tinfos = new List <Zhubang.TemplateInfo>();

            for (int j = 0; j < binfos.Count(); j += repeat)
            {
                Image image = (Image)bg.Clone();
                for (int i = 0; i < repeat; i++)
                {
                    if (j + i >= binfos.Count())
                    {
                        break;
                    }
                    tinfos = ParseTemplate(binfos.ElementAt(j + i), template);
                    foreach (var tinfo in tinfos)
                    {
                        if (tinfo.point != null)
                        {
                            tinfo.point.Y += offset * i;
                        }
                        if (tinfo.rectangle != null)
                        {
                            tinfo.rectangle.Y += offset * i;
                        }
                    }
                    image = zb.GenWithTemplate(image, tinfos);
                }
                string url = FileManager.currentPath + @"\pic\Rank" + binfos.ElementAt(j).Fpaiming + "-" + (binfos.ElementAt(j).Fpaiming + repeat - 1) + "." + ext;
                image.Save(url);
                image.Dispose();
            }
        }