0
我想縮放從AcquireNextFrame創建的紋理。 這裏是我的代碼:directX 11 scale texture2D
if (gRealTexture == nullptr) {
D3D11_TEXTURE2D_DESC description;
texture2D->GetDesc(&description);
description.BindFlags = 0;
description.CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE;
description.Usage = D3D11_USAGE_STAGING;
description.MiscFlags = 0;
hr = gDevice->CreateTexture2D(&description, NULL, &gRealTexture);
if (FAILED(hr)) {
if (gRealTexture) {
gRealTexture->Release();
gRealTexture = nullptr;
}
return NULL;
}
}
gImmediateContext->CopyResource(gRealTexture, texture2D);
D3D11_MAPPED_SUBRESOURCE mapped;
hr = gImmediateContext->Map(gRealTexture, 0, D3D11_MAP_READ_WRITE, 0, &mapped);
if (FAILED(hr)) {
gRealTexture->Release();
gRealTexture = NULL;
return NULL;
}
unsigned char *source = static_cast<unsigned char *>(mapped.pData); //Here I get the pixel buffer data
問題是,它是在全高清分辨率(1920×1080)。我想降低分辨率(例如1280x720),因爲我需要通過網絡發送source
。我並不需要全高清圖像。
在獲取像素緩衝區之前,是否可以使用DirectX輕鬆實現?
感謝
請你可以告訴我一些代碼嗎?我只需要創建一個新的紋理,然後我複製這個之前的?使用CopyResource? – DevAndroid
我創建了第二個紋理,我把這個描述:但是複製映射失敗: D3D11_TEXTURE2D_DESC描述; \t \t \t texture2D-> GetDesc(&description); \t \t \t description.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE; \t \t \t description.CPUAccessFlags = 0; \t \t \t description.Usage = D3D11_USAGE_DEFAULT; \t \t \t description.MiscFlags = 0; \t \t \t description.Width = 1280; \t \t \t description.Height = 720; \t \t \t hr = gDevice-> CreateTexture2D(&description,NULL,&gScaledTexture); – DevAndroid
https://msdn.microsoft.com/en-us/library/windows/desktop/ff476106(v=vs.85).aspx –