Liste der Anhänge anzeigen (Anzahl: 1)
WP7 App Nachtscanner - Download inkl. Sourcecode
Hallo
Wer Interesse hat, kann sich gerne meine kleine Demo App ansehen. Einfach aus Interesse durchstöbern wie sowas grundsätzlich beim WP7 funktioniert.
Die App liest die Videokamera Bilder frameweise ein und kann sie RGB-Manipuliert anzeigen.
Code:
<UserControl x:Class="Nachtscanner.CamControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
d:DesignHeight="480" d:DesignWidth="480">
<Grid x:Name="LayoutRoot" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<!--Camera viewfinder >-->
<Rectangle>
<Rectangle.Fill>
<VideoBrush x:Name="viewfinderBrush" Stretch="Uniform"/>
</Rectangle.Fill>
</Rectangle>
<!--Overlay for the viewfinder region to display grayscale WriteableBitmap objects-->
<Image x:Name="MainImage" Stretch="UniformToFill"/>
<TextBlock x:Name="txtDebug" HorizontalAlignment="Left" VerticalAlignment="Bottom" TextWrapping="Wrap" Grid.Row="1" />
</Grid>
</UserControl>
Code:
Private Sub StartCapture()
' Start ARGB to grayscale pump.
'MainImage.Visibility = Visibility.Visible
If _FrameCheckActive = True Then Exit Sub
Me._FrameCheckActive = True
' Start pump.
thFrameWorker = New System.Threading.Thread(AddressOf PumpARGBFrames)
thFrameWorker.IsBackground = True
thFrameWorker.Name = "thFrameWorker"
thFrameWorker.Start()
'Me.Dispatcher.BeginInvoke(Sub() txtDebug.Text = "ARGB to Grayscale")
End Sub
'ARGB frame pump
Private Sub PumpARGBFrames()
'Speicherbereich reservieren
Dim ARGBPx(CInt(cam.PreviewResolution.Width) * CInt(cam.PreviewResolution.Height) - 1) As Integer
Try
Dim phCam As PhotoCamera = CType(cam, PhotoCamera)
'Frames einlesen bis die Camera beendet wird
Do While Me._FrameCheckActive
'Warten bis die Daten bereit sind
PauseFramesEvent.WaitOne()
'Frame als Bytearray einlesen
phCam.GetPreviewBufferArgb32(ARGBPx)
'Bildauflösung auslesen
Dim NewVideoSize As Size = phCam.PreviewResolution
'Daten verarbeiten und Speicher klonen
Deployment.Current.Dispatcher.BeginInvoke(Sub()
If Me._Run = True Then
NachScanner.SetImageData(ARGBPx, NewVideoSize)
End If
End Sub)
PauseFramesEvent.Reset()
'Bildframe verändern und ausgeben
Deployment.Current.Dispatcher.BeginInvoke(Sub()
If Me._bm Is Nothing Then
Me._bm = New Imaging.WriteableBitmap(CInt(NewVideoSize.Width), CInt(NewVideoSize.Height))
Me.MainImage.Source = Me._bm
End If
ARGBPx.CopyTo(_bm.Pixels, 0)
_bm.Invalidate()
PauseFramesEvent.Set()
End Sub)
Loop
Catch e As Exception
' Display error message.
Me.Dispatcher.BeginInvoke(Sub()
txtDebug.Text = e.Message
End Sub)
End Try
Me._FrameCheckActive = False
End Sub
Anhang 91658
Download Sourcecode WP7 VB.Net
http://www.goldengel.ch/temp/Nachtscanner.zip
Auf Wunsch hab ich noch 101 andere Apps mit Source hier die dann auch komplexer sind.
lg
Timo