2021. 1. 17. 03:52
Unity/C#
모니터계열
public static Bitmap screenImg = new Bitmap(SystemInformation.VirtualScreen.Width
, SystemInformation.VirtualScreen.Height
, PixelFormat.Format32bppArgb);
public static Graphics graphicsScreenImg = Graphics.FromImage(screen_img);
//모니터 화면을 가져옴(전역변수에 담아둔다음 불러오는 형식)
public static System.Drawing.Bitmap GetScreen()
{
graphicsScreenImg.CopyFromScreen(SystemInformation.VirtualScreen.X
, SystemInformation.VirtualScreen.Y
, 0
, 0
, SystemInformation.VirtualScreen.Size
, CopyPixelOperation.SourceCopy);
return screenImg;
}
//모니터화면을 가져옴(안정적이지만 호출시마다 메모리 사용량이 높음)
public static Bitmap GetScreenLS()
{
Bitmap img = new Bitmap(SystemInformation.VirtualScreen.Width
, SystemInformation.VirtualScreen.Height
, PixelFormat.Format32bppArgb);
Graphics graphics = Graphics.FromImage(img);
graphics.CopyFromScreen(SystemInformation.VirtualScreen.X
, SystemInformation.VirtualScreen.Y
, 0
, 0
, SystemInformation.VirtualScreen.Size
, CopyPixelOperation.SourceCopy);
return img;
}
//모니터픽셀 가로
public static int GetScreenWidth()
{
return SystemInformation.VirtualScreen.X;
}
//모니터픽셀 세로
public static int GetScreenHeight()
{
return SystemInformation.VirtualScreen.Y;
}
2021년 기준 화면비
Z폴드2 (5:4)
Z플립3 (22:9)