Я использую следующий код для захвата экрана, но при захвате HDR-дисплея он будет переэкспонирован. Есть ли способ преобразовать изображение HDR в SDR или другие методы?
Я попробовал изменить формат на Format.FormatB8G8R8A8UnormSrgb, но в итоге получил байт[] все 0.
Возможно, у меня что-то не так с пониманием HDR. Любое решение проблемы «передержки» подойдет.
OutputDesc desc = new OutputDesc(null);
if (output->GetDesc(ref desc) != 0)
{
throw new Exception("Failed to get output description");
}
if (output->QueryInterface(out output5) != 0)
{
throw new Exception("Failed to get IDXGIOutput5");
}
if (output5.DuplicateOutput((IUnknown*)device, ref outputDuplication) != 0)
{
throw new Exception("Failed to get output duplication");
}
OutduplFrameInfo outduplFrameInfo = new OutduplFrameInfo();
Thread.Sleep(20);
if (outputDuplication->AcquireNextFrame(3000, &outduplFrameInfo, &desktopResource) != 0 ||
outduplFrameInfo.LastPresentTime == 0)
{
throw new Exception("Failed to acquire next frame");
}
if (desktopResource->QueryInterface(out desktopTexture) != 0)
{
throw new Exception("Failed to get desktop texture");
}
Texture2DDesc stagingTextureDesc = new()
{
CPUAccessFlags = (uint)CpuAccessFlag.Read,
BindFlags = (uint)(BindFlag.None),
Format = Format.FormatB8G8R8A8Unorm,
Width = (uint)desc.DesktopCoordinates.Size.X,
Height = (uint)desc.DesktopCoordinates.Size.Y,
MiscFlags = (uint)ResourceMiscFlag.None,
MipLevels = 1,
ArraySize = 1,
SampleDesc = { Count = 1, Quality = 0 },
Usage = Usage.Staging
};
if (device->CreateTexture2D(&stagingTextureDesc, null, ref stagingTexture) != 0)
{
throw new Exception("Failed to create staging texture");
}
stagingTexture->QueryInterface(out stagingResource);
immediateContext->CopyResource(stagingResource, desktopTexture);
MappedSubresource mappedSubresource = new MappedSubresource();
if (immediateContext->Map(stagingResource, 0, Map.Read, 0, &mappedSubresource) != 0)
{
throw new Exception("Failed to map staging texture");
}
var span = new ReadOnlySpan(mappedSubresource.PData,
(int)mappedSubresource.DepthPitch);
Подробнее здесь: https://stackoverflow.com/questions/791 ... r-problems
Проблемы с HDR при захвате экрана Dx11 ⇐ C#
Место общения программистов C#
1730151534
Anonymous
Я использую следующий код для захвата экрана, но при захвате HDR-дисплея он будет переэкспонирован. Есть ли способ преобразовать изображение HDR в SDR или другие методы?
Я попробовал изменить формат на Format.FormatB8G8R8A8UnormSrgb, но в итоге получил байт[] все 0.
Возможно, у меня что-то не так с пониманием HDR. Любое решение проблемы «передержки» подойдет.
OutputDesc desc = new OutputDesc(null);
if (output->GetDesc(ref desc) != 0)
{
throw new Exception("Failed to get output description");
}
if (output->QueryInterface(out output5) != 0)
{
throw new Exception("Failed to get IDXGIOutput5");
}
if (output5.DuplicateOutput((IUnknown*)device, ref outputDuplication) != 0)
{
throw new Exception("Failed to get output duplication");
}
OutduplFrameInfo outduplFrameInfo = new OutduplFrameInfo();
Thread.Sleep(20);
if (outputDuplication->AcquireNextFrame(3000, &outduplFrameInfo, &desktopResource) != 0 ||
outduplFrameInfo.LastPresentTime == 0)
{
throw new Exception("Failed to acquire next frame");
}
if (desktopResource->QueryInterface(out desktopTexture) != 0)
{
throw new Exception("Failed to get desktop texture");
}
Texture2DDesc stagingTextureDesc = new()
{
CPUAccessFlags = (uint)CpuAccessFlag.Read,
BindFlags = (uint)(BindFlag.None),
Format = Format.FormatB8G8R8A8Unorm,
Width = (uint)desc.DesktopCoordinates.Size.X,
Height = (uint)desc.DesktopCoordinates.Size.Y,
MiscFlags = (uint)ResourceMiscFlag.None,
MipLevels = 1,
ArraySize = 1,
SampleDesc = { Count = 1, Quality = 0 },
Usage = Usage.Staging
};
if (device->CreateTexture2D(&stagingTextureDesc, null, ref stagingTexture) != 0)
{
throw new Exception("Failed to create staging texture");
}
stagingTexture->QueryInterface(out stagingResource);
immediateContext->CopyResource(stagingResource, desktopTexture);
MappedSubresource mappedSubresource = new MappedSubresource();
if (immediateContext->Map(stagingResource, 0, Map.Read, 0, &mappedSubresource) != 0)
{
throw new Exception("Failed to map staging texture");
}
var span = new ReadOnlySpan(mappedSubresource.PData,
(int)mappedSubresource.DepthPitch);
Подробнее здесь: [url]https://stackoverflow.com/questions/79133633/dx11-screen-capture-hdr-problems[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия