我可以從我的表單(backbufferdata)中獲取「屏幕截圖」,但是是否可以只取其一部分?可以說,如果我的表單是1600x800像素,是否有可能只獲得100x100像素?從表單中獲取特定大小的矩形
int w = GraphicsDevice.PresentationParameters.BackBufferWidth;
int h = GraphicsDevice.PresentationParameters.BackBufferHeight;
//pull the picture from the buffer
int[] backBuffer = new int[w * h];
GraphicsDevice.GetBackBufferData(backBuffer);
//copy into a texture
Texture2D texture = new Texture2D(GraphicsDevice, w, h, true, GraphicsDevice.PresentationParameters.BackBufferFormat);
texture.SetData(backBuffer);
如果我改變寬度和高度,它會給出一個錯誤「它太小或太大」。
嘗試使用,需要一個矩形中的過載。 –