public static string Gen(JObject obj) { if (obj == null) { return(null); } JObject data = obj["data"] as JObject; string id = data["room_info"]["room_id"].ToString(); Bitmap bitmap = new( Config.Width, Config.Height); Graphics graphics = Graphics.FromImage(bitmap); graphics.InterpolationMode = InterpolationMode.High; graphics.TextRenderingHint = TextRenderingHint.AntiAliasGridFit; graphics.Clear(back); string pic_url = data["anchor_info"]["base_info"]["face"].ToString(); using Bitmap pic = Image.FromStream(HttpUtils.GetData(pic_url)) as Bitmap; graphics.DrawImage(pic, Config.HeadPic.X, Config.HeadPic.Y, Config.HeadPicSize, Config.HeadPicSize); graphics.DrawString(data["anchor_info"]["base_info"]["uname"].ToString(), name_font, name_color, Config.NamePos.X, Config.NamePos.Y); graphics.DrawString("直播间:" + id, live_font, live_color, Config.LivePos.X, Config.LivePos.Y); graphics.DrawString("UID:" + data["room_info"]["uid"].ToString(), uid_font, uid_color, Config.UidPos.X, Config.UidPos.Y); string sort = $"https://live.bilibili.com/{id}"; var code = CQode.code(sort, pic, Qback, Qpoint); graphics.DrawImage(code, Config.QPos.X, Config.QPos.Y, Config.QSize, Config.QSize); DateTime startTime = new(1970, 1, 1, 8, 0, 0); DateTime dt = startTime.AddSeconds((long)data["room_info"]["live_start_time"]); string temp = dt.ToString("HH:mm:ss"); graphics.DrawString($"开播时间:{temp} 观看:{data["room_info"]["online"]} 分区:{data["room_info"]["area_name"]}", state_font, state_color, Config.StatePos.X, Config.StatePos.Y); temp = data["room_info"]["title"].ToString(); string temp1; int c = 0; while (true) { int now = 0; if (Config.TitleLim + c > temp.Length) { temp1 = temp; break; } string temp2 = temp.Substring(now, Config.TitleLim + c); SizeF size = graphics.MeasureString(temp2, title_font); if (size.Width > Config.Width - Config.TextLeft) { temp1 = temp.Substring(now, Config.TitleLim + c - 2) + "..."; break; } c++; } graphics.DrawString(temp1, title_font, title_color, Config.TitlePos.X, Config.TitlePos.Y); pic_url = data["room_info"]["cover"].ToString(); using Bitmap pic1 = Image.FromStream(HttpUtils.GetData(pic_url)) as Bitmap; graphics.DrawImage(Tools.ZoomImage(pic1, Config.PicHeight, Config.PicWidth), Config.PicPos.X, Config.PicPos.Y); temp = data["room_info"]["description"].ToString(); var doc = new HtmlDocument(); doc.LoadHtml(temp); float NowY = Config.InfoPos.Y; DrawStringes(doc.DocumentNode.InnerText, ref bitmap, ref graphics, ref NowY); if (NowY < bitmap.Height) { Bitmap bitmap1 = new(Config.Width, (int)NowY + Config.InfoDeviation); graphics.Save(); graphics.Dispose(); graphics = Graphics.FromImage(bitmap1); graphics.InterpolationMode = InterpolationMode.High; graphics.TextRenderingHint = TextRenderingHint.AntiAliasGridFit; graphics.Clear(back); graphics.DrawImage(bitmap, 0, 0); bitmap.Dispose(); bitmap = bitmap1; } temp = $"Live/{id}.jpg"; graphics.Save(); bitmap.Save(temp); graphics.Dispose(); bitmap.Dispose(); return(Program.RunLocal + temp); }
public static string Gen(JObject obj) { if (obj == null) { return(null); } Bitmap bitmap = new( Config.Width, Config.Height); Graphics graphics = Graphics.FromImage(bitmap); graphics.InterpolationMode = InterpolationMode.High; graphics.TextRenderingHint = TextRenderingHint.AntiAliasGridFit; graphics.Clear(back); JObject data = obj["data"] as JObject; string pic_url = data["owner"]["face"].ToString(); using Bitmap pic = Image.FromStream(HttpUtils.GetData(pic_url)) as Bitmap; graphics.DrawImage(pic, Config.HeadPic.X, Config.HeadPic.Y, Config.HeadPicSize, Config.HeadPicSize); graphics.DrawString(data["owner"]["name"].ToString(), name_font, name_color, Config.NamePos.X, Config.NamePos.Y); graphics.DrawString("UID:" + data["owner"]["mid"].ToString(), uid_font, uid_color, Config.UidPos.X, Config.UidPos.Y); string sort = $"https://b23.tv/{data["bvid"]}"; var code = CQode.code(sort, pic, Qback, Qpoint); graphics.DrawImage(code, Config.QPos.X, Config.QPos.Y, Config.QSize, Config.QSize); string temp = data["title"].ToString(); string temp1; int c = 0; while (true) { int now = 0; if (Config.TitleLim + c > temp.Length) { temp1 = temp; break; } string temp2 = temp.Substring(now, Config.InfoLim + c); SizeF size = graphics.MeasureString(temp2, info_font); if (size.Width > Config.Width - Config.InfoLeft) { temp1 = temp.Substring(now, Config.TitleLim + c - 2) + "..."; break; } c++; } graphics.DrawString(temp1, title_font, title_color, Config.TitlePos.X, Config.TitlePos.Y); DateTime startTime = new(1970, 1, 1, 8, 0, 0); DateTime dt = startTime.AddSeconds((long)data["pubdate"]); temp = dt.ToString("yyyy/MM/dd HH:mm:ss"); graphics.DrawString($"{temp} 观看:{data["stat"]["view"]} 点赞:{data["stat"]["like"]}", state_font, state_color, Config.StatePos.X, Config.StatePos.Y); pic_url = data["pic"].ToString(); using Bitmap pic1 = Image.FromStream(HttpUtils.GetData(pic_url)) as Bitmap; graphics.DrawImage(Tools.ZoomImage(pic1, Config.PicHeight, Config.PicWidth), Config.PicPos.X, Config.PicPos.Y); temp = data["desc"].ToString(); int AllLength = (temp.Length / Config.InfoLim + 2 + Tools.SubstringCount(temp, "\n")) * Config.InfoDeviation + (int)Config.InfoPos.Y; if (AllLength > bitmap.Height) { Bitmap bitmap1 = new(Config.Width, AllLength); graphics.Save(); graphics.Dispose(); graphics = Graphics.FromImage(bitmap1); graphics.InterpolationMode = InterpolationMode.High; graphics.TextRenderingHint = TextRenderingHint.AntiAliasGridFit; graphics.Clear(back); graphics.DrawImage(bitmap, 0, 0); bitmap.Dispose(); bitmap = bitmap1; } string[] list = temp.Split("\n"); int d = 0; double nowy1 = Config.InfoPos.Y; foreach (var item in list) { int a = 0; int now = 0; while (true) { bool last = false; float NowY = Config.InfoPos.Y + d * Config.InfoDeviation; d++; int b = 0; while (true) { if (now + Config.InfoLim + b > item.Length) { temp1 = item[now..];
public static string Gen(JObject obj) { if (obj == null) { return(null); } if (obj["data"]?["card"] is not JObject data) { data = obj["data"]["cards"][0] as JObject; } string id = data["desc"]["dynamic_id"].ToString(); JObject desc = data["desc"] as JObject; Bitmap bitmap = new( Config.Width, Config.Height); Graphics graphics = Graphics.FromImage(bitmap); graphics.InterpolationMode = InterpolationMode.High; graphics.TextRenderingHint = TextRenderingHint.AntiAliasGridFit; graphics.Clear(back); string pic_url = desc["user_profile"]["info"]["face"].ToString(); using Bitmap pic = Tools.GetImgUrl(pic_url); graphics.DrawImage(pic, Config.HeadPic.X, Config.HeadPic.Y, Config.HeadPicSize, Config.HeadPicSize); graphics.DrawString(desc["user_profile"]["info"]["uname"].ToString(), name_font, name_color, Config.NamePos.X, Config.NamePos.Y); graphics.DrawString("UID:" + desc["user_profile"]["info"]["uid"].ToString(), uid_font, uid_color, Config.UidPos.X, Config.UidPos.Y); string sort = $"https://t.bilibili.com/{id}"; var code = CQode.code(sort, pic, Qback, Qpoint); graphics.DrawImage(code, Config.QPos.X, Config.QPos.Y, Config.QSize, Config.QSize); DateTime startTime = new(1970, 1, 1, 8, 0, 0); DateTime dt = startTime.AddSeconds((long)data["desc"]["timestamp"]); string temp = dt.ToString("yyyy/MM/dd HH:mm:ss"); graphics.DrawString($"{temp} 观看:{data["desc"]["view"]} 点赞:{data["desc"]["like"]}", state_font, state_color, Config.StatePos.X, Config.StatePos.Y); float NowY = Config.PicStart.Y; int type = (int)desc["type"]; try { switch (type) { case 1: Type1(JObject.Parse(data["card"].ToString()), ref bitmap, ref graphics, ref NowY); break; case 2: Type2(JObject.Parse(data["card"].ToString()), ref bitmap, ref graphics, ref NowY); break; case 4: Type4(JObject.Parse(data["card"].ToString()), ref bitmap, ref graphics, ref NowY); break; case 8: Type8(JObject.Parse(data["card"].ToString()), ref bitmap, ref graphics, ref NowY); break; case 64: Type64(JObject.Parse(data["card"].ToString()), ref bitmap, ref graphics, ref NowY); break; case 2048: Type2048(JObject.Parse(data["card"].ToString()), ref bitmap, ref graphics, ref NowY); break; } } catch (Exception e) { File.WriteAllText($"Dynamic/{id}.json", obj.ToString()); Program.Error(e); } if (data["display"] is JObject display) { if (display["add_on_card_info"] is JArray add) { foreach (var item in add) { int type1 = (int)item["add_on_card_show_type"]; if (type1 == 5) { AType5(item["ugc_attach_card"] as JObject, ref bitmap, ref graphics, ref NowY); } } } } if (NowY < bitmap.Height) { Bitmap bitmap1 = new(Config.Width, (int)NowY + Config.TextDeviation); graphics.Save(); graphics.Dispose(); graphics = Graphics.FromImage(bitmap1); graphics.InterpolationMode = InterpolationMode.High; graphics.TextRenderingHint = TextRenderingHint.AntiAliasGridFit; graphics.Clear(back); graphics.DrawImage(bitmap, 0, 0); bitmap.Dispose(); bitmap = bitmap1; } temp = $"Dynamic/{id}.jpg"; graphics.Save(); bitmap.Save(temp); graphics.Dispose(); bitmap.Dispose(); return(Program.RunLocal + temp); }