C# Windows Phone 7-照相机闪光灯应用程序不起作用
为了按照这里的说明操作,我编写了一个非常简单的WP7应用程序来打开闪光灯。一切似乎都正常,除了……闪光灯没有激活 我的手机是三星SGH-I917(最新操作系统更新),我使用的是WP7 SDK 7.1,我已经检查了我的相机闪光灯是否正常工作。我还检查了以确保WMAppManifest.xml文件中包含以下内容C# Windows Phone 7-照相机闪光灯应用程序不起作用,c#,windows-phone-7,windows-phone-7.1,C#,Windows Phone 7,Windows Phone 7.1,为了按照这里的说明操作,我编写了一个非常简单的WP7应用程序来打开闪光灯。一切似乎都正常,除了……闪光灯没有激活 我的手机是三星SGH-I917(最新操作系统更新),我使用的是WP7 SDK 7.1,我已经检查了我的相机闪光灯是否正常工作。我还检查了以确保WMAppManifest.xml文件中包含以下内容 <Capability Name="ID_CAP_ISV_CAMERA" /> 下面是XAML: <phone:PhoneApplicationPage x:Class
<Capability Name="ID_CAP_ISV_CAMERA" />
下面是XAML:
<phone:PhoneApplicationPage
x:Class="PhoneApp1.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True">
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
<TextBlock x:Name="ApplicationTitle" Text="" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock x:Name="PageTitle" Text="FlashLite" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel>
<Canvas x:Name="viewfinderCanvas" HorizontalAlignment="Center" >
<Canvas.Background>
<VideoBrush x:Name="viewfinderBrush" />
</Canvas.Background>
</Canvas>
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<Button Width="200" Height="100" Content="Flash" Click="Button_Click" />
</Grid>
</Grid>
仅表示在拍摄图像时将激活闪光灯
这是通过行动来实现的
cam.CaptureImage();
编辑:如果你只想触发闪光灯,你可以调用
cam.Focus()代码>当然,这是有道理的。因此,如果我想制作一个“手电筒”应用程序,让闪光灯一直亮着,我想我需要找到一种方法来不断调用CaptureImage()代码>?我认为cam.Focus()代码>也会触发flashNice,谢谢你提供的信息。今晚将检查它的工作原理。cam.Focus()会触发闪光灯。许多想发明LED手电筒的人都发现,没有办法让LED灯亮1-2秒以上。您可以连续调用focus(),甚至在AutofocusCompleted事件中启动一个新的焦点,但所得到的只是一个闪烁的闪光灯。为了获得稳定的闪光,你必须看一下VideoCaptureDevice。@danglund-是的,我几天前也发现了这一点。你可以在这里加上这个答案,我会投票的。这是一件需要注意的重要事情。
cam.FlashMode = FlashMode.On;
cam.CaptureImage();