想了解如何在Windows8的新动态吗?本文将为您提供详细的信息,我们还将为您解答关于WinRT应用程序中显示可缩放的图像?的相关问题,此外,我们还将为您介绍关于c–如何在Windows8现代应用程序
想了解如何在Windows 8的新动态吗?本文将为您提供详细的信息,我们还将为您解答关于WinRT应用程序中显示可缩放的图像?的相关问题,此外,我们还将为您介绍关于c – 如何在Windows 8现代应用程序中从视频流中抓取帧?、c# – WinRT – 在Windows启动时启动一个应用程序?、c# – 如何在Windows 10通用应用程序中显示模态窗口?、c# – 如何在Windows 8应用程序中使用xaml矢量图像作为图像源的新知识。
本文目录一览:- 如何在Windows 8(WinRT)应用程序中显示可缩放的图像?(win10程序缩放显示不全)
- c – 如何在Windows 8现代应用程序中从视频流中抓取帧?
- c# – WinRT – 在Windows启动时启动一个应用程序?
- c# – 如何在Windows 10通用应用程序中显示模态窗口?
- c# – 如何在Windows 8应用程序中使用xaml矢量图像作为图像源
如何在Windows 8(WinRT)应用程序中显示可缩放的图像?(win10程序缩放显示不全)
是否有可能将图像放入WinRT中的控件,然后让用户放大和缩小等?
用多行回声string到.txt文件 – 用Windowsbatch file
获取当前在Windows任务栏中可见的应用程序(或窗口)列表
禁用报告服务的Windows身份validation
从命令行运行Python
如何让腻子在git输出上显示颜色编码?
是!
最简单的方法是把它放在scrollviewer里面。 你可以放大或缩小任何你喜欢的方式!
<ScrollViewer MaxZoomFactor="3" MinZoomFactor="0.5" ZoomMode="Enabled"> <Image Source="/Assets/logo.png" Width="200" Height="200"/> </ScrollViewer>
c – 如何在Windows 8现代应用程序中从视频流中抓取帧?
通过文档和示例的方式很少,但经过一些挖掘后,似乎有些人通过将帧读入纹理并将该纹理的内容复制到记忆可读纹理(我甚至不是确定我在这里使用正确的条款).尝试我发现的虽然给了我错误,我可能做了一堆错误.
这是我尝试做的一小段代码(项目本身附在底部).
ComPtr<ID3D11Texture2D> spTextureDst; MEDIA::ThrowIfFailed( m_spDX11SwapChain->GetBuffer(0,IID_PPV_ARGS(&spTextureDst)) ); auto rcnormalized = MFVideonormalizedRect(); rcnormalized.left = 0; rcnormalized.right = 1; rcnormalized.top = 0; rcnormalized.bottom = 1; MEDIA::ThrowIfFailed( m_spMediaEngine->TransferVideoFrame(m_spRenderTexture.Get(),&rcnormalized,&m_rcTarget,&m_bkgColor) ); //copy the render target texture to the readable texture. m_spDX11DeviceContext->copySubresourceRegion(m_spcopyTexture.Get(),m_spRenderTexture.Get(),NULL); m_spDX11DeviceContext->Flush(); //Map the readable texture; D3D11_MAPPED_SUBRESOURCE mapped = {0}; m_spDX11DeviceContext->Map(m_spcopyTexture.Get(),D3D11_MAP_READ,&mapped); void* buffer = ::CoTaskMemAlloc(600 * 400 * 3); memcpy(buffer,mapped.pData,600 * 400 * 3); //unmap so we can copy during next update. m_spDX11DeviceContext->Unmap(m_spcopyTexture.Get(),0); // and the present it to the screen MEDIA::ThrowIfFailed( m_spDX11SwapChain->Present(1,0) ); }
我得到的错误是:
First-chance exception at 0x76814B32 in App1.exe: Microsoft C++ exception: Platform::invalidargumentexception ^ at memory location 0x07AFF60C. HRESULT:0x80070057
我不太确定如何进一步追求它,因为就像我说的那样,关于它的文档很少.
Here’s the modified sample我正在工作.此问题特定于WinRT(Windows 8应用程序).
解决方法
部分成功,但也许足以回答你的问题.请继续阅读.
在我的系统上,调试异常表明OnTimer()函数在尝试调用TransferVideoFrame()时失败.它给出的错误是invalidargumentexception.
所以,一点谷歌搜索引发了我的第一次发现 – 显然是a bug in NVIDIA drivers – 这意味着视频播放似乎失败了11和10个功能级别.
所以我的第一个更改是在函数CreateDX11Device()中,如下所示:
static const D3D_FEATURE_LEVEL levels[] = { /* D3D_FEATURE_LEVEL_11_1,D3D_FEATURE_LEVEL_11_0,D3D_FEATURE_LEVEL_10_1,D3D_FEATURE_LEVEL_10_0,*/ D3D_FEATURE_LEVEL_9_3,D3D_FEATURE_LEVEL_9_2,D3D_FEATURE_LEVEL_9_1 };
现在TransferVideoFrame()仍然失败,但是给出了E_FAIL(作为HRESULT)而不是无效的参数.
更多谷歌搜索导致我的second discovery –
这是一个示例,显示使用TransferVideoFrame()而不使用CreateTexture2D()来预先创建纹理.我看到你已经在OnTimer()中有一些代码与此类似,但没有使用,所以我猜你找到了相同的链接.
无论如何,我现在使用此代码来获取视频帧:
ComPtr <ID3D11Texture2D> spTextureDst; m_spDX11SwapChain->GetBuffer (0,IID_PPV_ARGS (&spTextureDst)); m_spMediaEngine->TransferVideoFrame (spTextureDst.Get (),nullptr,&m_bkgColor);
执行此操作后,我看到TransferVideoFrame()成功(好!)但在复制的纹理上调用Map() – m_spcopyTexture – 失败,因为该纹理不是使用cpu读取访问创建的.
所以,我只是使用你的读/写m_spRenderTexture作为副本的目标,因为它具有正确的标志,并且由于之前的更改,我不再使用它.
//copy the render target texture to the readable texture. m_spDX11DeviceContext->copySubresourceRegion(m_spRenderTexture.Get(),spTextureDst.Get(),NULL); m_spDX11DeviceContext->Flush(); //Map the readable texture; D3D11_MAPPED_SUBRESOURCE mapped = {0}; HRESULT hr = m_spDX11DeviceContext->Map(m_spRenderTexture.Get(),&mapped); void* buffer = ::CoTaskMemAlloc(176 * 144 * 3); memcpy(buffer,176 * 144 * 3); //unmap so we can copy during next update. m_spDX11DeviceContext->Unmap(m_spRenderTexture.Get(),0);
现在,在我的系统上,OnTimer()函数不会失败.视频帧被渲染到纹理,像素数据被成功复制到内存缓冲区.
在考虑是否还有其他问题之前,也许现在是时候看看你能否取得与我迄今为止相同的进步.如果您使用更多信息对此答案发表评论,我将编辑答案,以便在可能的情况下添加更多帮助.
编辑
在FramePlayer :: CreateBackBuffers()中对纹理描述所做的更改
//make first texture cpu readable D3D11_TEXTURE2D_DESC texDesc = {0}; texDesc.Width = 176; texDesc.Height = 144; texDesc.MipLevels = 1; texDesc.ArraySize = 1; texDesc.Format = dxgi_FORMAT_B8G8R8A8_UnorM; texDesc.SampleDesc.Count = 1; texDesc.SampleDesc.Quality = 0; texDesc.Usage = D3D11_USAGE_STAGING; texDesc.BindFlags = 0; texDesc.cpuAccessFlags = D3D11_cpu_ACCESS_READ | D3D11_cpu_ACCESS_WRITE; texDesc.MiscFlags = 0; MEDIA::ThrowIfFailed(m_spDX11Device->CreateTexture2D(&texDesc,NULL,&m_spRenderTexture));
还要注意,有时需要清除内存泄漏(我确定你知道) – 以下行中分配的内存永远不会被释放:
void* buffer = ::CoTaskMemAlloc(176 * 144 * 3); // sizes changed for my test
成功
我现在已经成功保存了一个单独的框架,但现在没有使用复制纹理.
首先,我下载了最新版本的the DirectXTex Library,它提供了DX11纹理辅助函数,例如从纹理中提取图像并保存到文件. The instructions用于将DirectXTex库添加到您的解决方案作为现有项目需要仔细遵循,注意Windows 8商店应用程序所需的更改.
一旦,包含,引用和构建上面的库,将以下#include添加到FramePlayer.cpp
#include "..\DirectXTex\DirectXTex.h" // nb - use the relative path you copied to #include <wincodec.h>
最后,FramePlayer :: OnTimer()中的代码的中心部分需要类似于以下内容.您将看到我每次都保存到相同的文件名,因此需要修改以添加例如名称的帧号
// new frame available at the media engine so get it ComPtr<ID3D11Texture2D> spTextureDst; MEDIA::ThrowIfFailed(m_spDX11SwapChain->GetBuffer(0,IID_PPV_ARGS(&spTextureDst))); auto rcnormalized = MFVideonormalizedRect(); rcnormalized.left = 0; rcnormalized.right = 1; rcnormalized.top = 0; rcnormalized.bottom = 1; MEDIA::ThrowIfFailed(m_spMediaEngine->TransferVideoFrame(spTextureDst.Get(),&m_bkgColor)); // capture an image from the DX11 texture DirectX::ScratchImage pImage; HRESULT hr = DirectX::CaptureTexture(m_spDX11Device.Get(),m_spDX11DeviceContext.Get(),pImage); if (SUCCEEDED(hr)) { // get the image object from the wrapper const DirectX::Image *pRealImage = pImage.Getimage(0,0); // set some place to save the image frame StorageFolder ^dataFolder = ApplicationData::Current->LocalFolder; Platform::String ^szPath = dataFolder->Path + "\\frame.png"; // save the image to file hr = DirectX::SavetoWICFile(*pRealImage,DirectX::WIC_FLAGS_NONE,GUID_ContainerFormatPng,szPath->Data()); } // and the present it to the screen MEDIA::ThrowIfFailed(m_spDX11SwapChain->Present(1,0));
我现在没有时间进一步采取这一点,但我对目前为止取得的成就感到非常满意:-))
您能否重新审视并在评论中更新结果?
c# – WinRT – 在Windows启动时启动一个应用程序?
我无法找到任何其他地方,只有Windows 7或更低版本,与普通样式的应用程序.
解决方法
c# – 如何在Windows 10通用应用程序中显示模态窗口?
编辑:这是截图
有人知道如何实现它或有一些api可以做到吗?
注意:当此窗口打开时,您甚至无法最小化/最大化/关闭主窗口. X- 20045 X- 200 200 X- 200 200:
解决方法
var dialog = new ContentDialog() { Title = "Lorem Ipsum",MaxWidth = this.ActualWidth // required for Mobile! Content = YourXamlContent }; dialog.PrimaryButtonText = "OK"; dialog.IsPrimaryButtonEnabled = false; dialog.PrimaryButtonClick += delegate { }; var result = await dialog.ShowAsync();
msdn对话框指南:link
msdn ContentDialog API:link
c# – 如何在Windows 8应用程序中使用xaml矢量图像作为图像源
我得到以下xaml.
<Canvas xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Name="svg2997" Width="744.09448" Height="1052.3622" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> <Canvas x:Name="layer1"> <Path Fill="#FFCCCCCC" stroke="#FF000000" strokeThickness="1.34377062" strokeMiterLimit="4" x:Name="path3007" Data="M372.58272,134.72445C167.96301,134.72445 2.06820310000001,300.58818 2.06820310000001,505.20789 2.06820310000001,709.8276 167.96301,875.72241 372.58272,875.72241 577.20243,875.72241 743.06616,709.8276 743.06616,505.20789 743.06616,300.58818 577.20243,134.72445 372.58272,134.72445z M280.73888,251.77484L455.94149,251.77484 455.94149,413.70594 628.16035,588.97071 455.94149,773.71514 280.73888,588.97071 106.22005,413.70594 280.73888,251.77484z" /> </Canvas> </Canvas>
如果我直接将它添加到我的应用程序xaml,它会呈现,但是缩放比例是关闭的.
如果可能,我想使用它作为图像对象的图像源.
<Image HorizontalAlignment="Left" Height="100" Margin="127,37,0" VerticalAlignment="Top" Width="100" Source="Assets/plus_circle.xaml"/>
这可以做吗
解决方法
要自定义按钮的文本,您可以设置AutomationProperties.Name附加属性,以自定义按钮中的图标,您可以设置Content属性,并且为了辅助功能的原因设置AutomationProperties.AutomationId附加属性也是一个好主意.
以下是使用此方法定制的按钮的示例:
<Style x:Key="FolderButtonStyle" targettype="ButtonBase" BasedOn="{StaticResource AppBarButtonStyle}"> <Setter Property="AutomationProperties.AutomationId" Value="FolderAppBarButton"/> <Setter Property="AutomationProperties.Name" Value="Folder"/> <Setter Property="Content" Value=""/> </Style>
如上所述,要自定义图标,您可以设置Content属性.挑战是如何设置内容,以显示您的自定义矢量图.
事实证明,您可以将Xaml甚至您的任何路径放入ViewBox以更改其比例.这是我的第一个方法,但它不起作用.事实上,似乎任何时候你使用Xaml扩展符号来设置一个不起作用的按钮的Content属性.
<Style x:Key="SquareButtonStyle" targettype="ButtonBase" BasedOn="{StaticResource AppBarButtonStyle}"> <Setter Property="AutomationProperties.AutomationId" Value="SquareAppBarButton"/> <Setter Property="AutomationProperties.Name" Value="Square"/> <Setter Property="Content"> <Setter.Value> <!-- This square will never show --> <Rectangle Fill="Blue" Width="20" Height="20" /> </Setter.Value> </Setter>
我实际上认为这是一个错误,但幸运的是有一个解决方法.
Tim Heuer写了一篇关于使用Xaml Path作为按钮的艺术品的最简单的方法的优秀文章.那篇文章在这里:
http://timheuer.com/blog/archive/2012/09/03/using-vectors-as-appbar-button-icons.aspx
简而言之,您需要定义一个正确设置所有绑定的样式:
<Style x:Key="PathAppBarButtonStyle" BasedOn="{StaticResource AppBarButtonStyle}" targettype="ButtonBase"> <Setter Property="ContentTemplate"> <Setter.Value> <DataTemplate> <Path Width="20" Height="20" Stretch="Uniform" Fill="{Binding Path=Foreground,RelativeSource={RelativeSource Mode=TemplatedParent}}" Data="{Binding Path=Content,RelativeSource={RelativeSource Mode=TemplatedParent}}"/> </DataTemplate> </Setter.Value> </Setter>
然后,您创建一个继承自该样式的样式,并粘贴到您的路径中.以下是您上面列出的作品的风格:
<Style x:Key="CrossButtonStyle" targettype="ButtonBase" BasedOn="{StaticResource PathAppBarButtonStyle}"> <Setter Property="AutomationProperties.AutomationId" Value="CrossAppBarButton"/> <Setter Property="AutomationProperties.Name" Value="Cross"/> <Setter Property="Content" Value="M372.58272,251.77484z"/> </Style>
最后,您可以在AppBar中使用它:
<Button/>
开发支持,设计支持和更好的善良方式:
http://bit.ly/winappsupport
关于如何在Windows 8和WinRT应用程序中显示可缩放的图像?的问题我们已经讲解完毕,感谢您的阅读,如果还想了解更多关于c – 如何在Windows 8现代应用程序中从视频流中抓取帧?、c# – WinRT – 在Windows启动时启动一个应用程序?、c# – 如何在Windows 10通用应用程序中显示模态窗口?、c# – 如何在Windows 8应用程序中使用xaml矢量图像作为图像源等相关内容,可以在本站寻找。
本文标签: