using System.Runtime.InteropServices; using XFEEDToolBox.Core.Notifications; using Windows.Graphics.Imaging; namespace XFEEDToolBox.Services.Arrival; internal static class ArrivalHeroCard { public const int Width=728,Height=360; public static byte[] Render(ArrivalFrame frame,NavigationArrival arrival) =>Render(frame,"导航完成",arrival.Title,arrival.LocalNavigation?arrival.Detail:"已完成全部跃迁 · 点击返回星图"); public static byte[] Render(ArrivalFrame frame,SessionReadyNotification ready) =>Render(frame,"游戏已就绪",ready.Title,ready.Detail); private static byte[] Render(ArrivalFrame frame,string badge,string title,string detail) { if(frame.Width<1||frame.Height<1||frame.Bgra.Length!=checked(frame.Width*frame.Height*4))throw new ArgumentException("Invalid captured frame."); var pixels=new byte[Width*Height*4]; // Keep the upper cockpit view, where the arrival star is normally visible. // This is a crop of the actual frame, never a generated replacement star. var sourceHeight=Math.Min(frame.Height*.78,frame.Width*(double)Height/Width); var sourceWidth=sourceHeight*Width/Height; var left=(frame.Width-sourceWidth)*.5;var top=Math.Max(0,frame.Height*.40-sourceHeight*.5); for(var y=0;y=24 and <184&&y is >=22 and <72) { var cornerX=Math.Max(24+10-x,x-(184-10));var cornerY=Math.Max(22+10-y,y-(72-10)); if(cornerX<=0||cornerY<=0||cornerX*cornerX+cornerY*cornerY<=100)shade=Math.Max(shade,.82); } for(var c=0;c<3;c++) { var a=frame.Bgra[(iy*frame.Width+ix)*4+c]*(1-fx)+frame.Bgra[(iy*frame.Width+nx)*4+c]*fx; var b=frame.Bgra[(ny*frame.Width+ix)*4+c]*(1-fx)+frame.Bgra[(ny*frame.Width+nx)*4+c]*fx; var tint=c==0?24:c==1?17:11; pixels[at+c]=(byte)Math.Clamp((a*(1-fy)+b*fy)*(1-shade)+tint*shade,0,255); } pixels[at+3]=255; if(x is >=32 and <36&&y is >=32 and <60){pixels[at]=210;pixels[at+1]=225;pixels[at+2]=74;} } var info=new BitmapInfo{Size=40,Width=Width,Height=-Height,Planes=1,BitCount=32,SizeImage=(uint)pixels.Length}; var dc=CreateCompatibleDC(0);if(dc==0)throw new InvalidOperationException("Cannot create notification image surface."); nint bitmap=0,previous=0; try { bitmap=CreateDIBSection(dc,ref info,0,out var bits,0,0);if(bitmap==0)throw new InvalidOperationException("Cannot create notification bitmap."); previous=SelectObject(dc,bitmap);Marshal.Copy(pixels,0,bits,pixels.Length);SetBkMode(dc,1); Text(dc,badge,52,30,Width-80,38,22,600,0xD2E14A); Text(dc,title,32,220,Width-64,58,36,700,0xFFFFFF); Text(dc,detail,34,294,Width-68,34,20,400,0xCAB9A5); Marshal.Copy(bits,pixels,0,pixels.Length);for(var p=3;p