Click here to Skip to main content
15,903,854 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: WPF faster DrawingVisuals initialization. Pin
Polykar17-Nov-08 20:54
Polykar17-Nov-08 20:54 
QuestionGet element positions Pin
Not Active16-Nov-08 18:33
mentorNot Active16-Nov-08 18:33 
AnswerRe: Get element positions Pin
Michael Sync16-Nov-08 18:57
Michael Sync16-Nov-08 18:57 
GeneralRe: Get element positions Pin
Not Active16-Nov-08 18:59
mentorNot Active16-Nov-08 18:59 
GeneralLearning WPF Pin
ColinM12316-Nov-08 11:11
ColinM12316-Nov-08 11:11 
GeneralRe: Learning WPF Pin
Pete O'Hanlon16-Nov-08 11:18
mvePete O'Hanlon16-Nov-08 11:18 
QuestionDataGrid Pin
VisualLive16-Nov-08 5:33
VisualLive16-Nov-08 5:33 
QuestionAdvanced masking - Interlacing 3 video inputs into a single image [modified] Pin
Graeme_Grant16-Nov-08 2:14
mvaGraeme_Grant16-Nov-08 2:14 
I'm trying to convert GDI+ project into WPF.

The GDI+ code (see below) interlaces 3 images into one:

Image 1 | Image 2 | Image 3 > Combined Image
-------------------------------------------------
11111 | 22222 | 33333 > 123123123123123
11111 | 22222 | 33333 > 123123123123123
11111 | 22222 | 33333 > 123123123123123
11111 | 22222 | 33333 > 123123123123123
11111 | 22222 | 33333 > 123123123123123

I think that if an Linear Gradent Brush in an Opacity Mask is used on the 3 input Visual Brushes, it should be possible to interlace video in real time - I can figure out the concept but not sure how to get it done. Needs to be pixel perfect masking for a 1080 x 1920 (portrait) display area...

As I'm still a noobie at WPF, is there anyone who can help or guide me?


Thanks in advance...

Graeme


Sample GDI+ code is as follows:

Imports System.Math
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Drawing.Imaging
Imports System.Drawing.Text

Public Class Form1

#Const DEBUG = 0

    Private Filter As Region
    Dim Images(5) As TextureBrush
    Private ndx As Integer = 0
    Dim Toggle As Integer = 0

#If Debug = 1 Then
    Dim cnt As Integer
#End If

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Images(0) = New TextureBrush(My.Resources.Image1)
        Images(1) = New TextureBrush(My.Resources.Image2)
        Images(2) = New TextureBrush(My.Resources.Image3)
        Images(3) = New TextureBrush(My.Resources.Image4)
        Images(4) = New TextureBrush(My.Resources.Image5)
        Images(5) = New TextureBrush(My.Resources.Image6)

        ' Prep a Stripped-View Filter.
        Filter = New Region(New Rectangle(0, 0, 1930, 1080))
        Using pa As New GraphicsPath()
            For iTop As Integer = 0 To Me.Height Step 3
                pa.AddRectangle(New Rectangle(0, iTop, 1930, 2))
            Next
            Filter.Exclude(pa)
        End Using

    End Sub

    Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)

        ' Draw Base image
        e.Graphics.FillRectangle(Images(GetPtr(0)), New Rectangle(0, 0, 1920, 1080))

        ' Draw interlaced images
        For i = 1 To 2
            e.Graphics.TranslateTransform(0, i)
            e.Graphics.FillRegion(Images(GetPtr(i)), Filter)
            'e.Graphics.FillRegion(Images(GetPtr(0)), Filter)
        Next

        ' Toggle Logo Postion - From middle to sides and back
        Toggle = Toggle Xor 1

        ' Pass painting back to caller
        MyBase.OnPaint(e)

        ' Reposition count so that each AD image appears RHS > Middle > LHS
        If Toggle Then PrevNdx() Else NextNdx()

    End Sub

    Private Function NextNdx() As Integer
        ndx += 1
        If ndx > Images.Length - 1 Then ndx = 1
        Return ndx
    End Function

    Private Function PrevNdx() As Integer
        ndx -= 1
        If ndx < 1 Then ndx = Images.Length - 1
        Return ndx
    End Function

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Me.Invalidate()
    End Sub

End Class


modified on Sunday, November 16, 2008 8:26 AM

AnswerRe: Advanced masking - Interlacing 3 video inputs into a single image Pin
Insincere Dave16-Nov-08 8:57
Insincere Dave16-Nov-08 8:57 
GeneralRe: Advanced masking - Interlacing 3 video inputs into a single image Pin
Graeme_Grant16-Nov-08 9:39
mvaGraeme_Grant16-Nov-08 9:39 
GeneralRe: Advanced masking - Interlacing 3 video inputs into a single image Pin
Insincere Dave18-Nov-08 5:56
Insincere Dave18-Nov-08 5:56 
GeneralRe: Advanced masking - Interlacing 3 video inputs into a single image [modified] Pin
Graeme_Grant19-Nov-08 1:35
mvaGraeme_Grant19-Nov-08 1:35 
QuestionWPF Binding to an attached property from a DataTemplate [modified] Pin
Mark Salsbery14-Nov-08 13:13
Mark Salsbery14-Nov-08 13:13 
AnswerRe: WPF Binding to an attached property from a DataTemplate Pin
Timmy Kokke14-Nov-08 13:46
Timmy Kokke14-Nov-08 13:46 
GeneralRe: WPF Binding to an attached property from a DataTemplate Pin
Mark Salsbery14-Nov-08 14:20
Mark Salsbery14-Nov-08 14:20 
GeneralRe: WPF Binding to an attached property from a DataTemplate Pin
Timmy Kokke14-Nov-08 22:10
Timmy Kokke14-Nov-08 22:10 
GeneralRe: WPF Binding to an attached property from a DataTemplate [modified] Pin
Mark Salsbery15-Nov-08 5:36
Mark Salsbery15-Nov-08 5:36 
AnswerRe: WPF Binding to an attached property from a DataTemplate Pin
Gideon Engelberth14-Nov-08 16:48
Gideon Engelberth14-Nov-08 16:48 
GeneralRe: WPF Binding to an attached property from a DataTemplate Pin
Mark Salsbery15-Nov-08 6:40
Mark Salsbery15-Nov-08 6:40 
QuestionSWF Player in WPF Pin
ctrlnick14-Nov-08 10:25
ctrlnick14-Nov-08 10:25 
AnswerRe: SWF Player in WPF Pin
Pete O'Hanlon14-Nov-08 10:32
mvePete O'Hanlon14-Nov-08 10:32 
GeneralRe: SWF Player in WPF Pin
ctrlnick14-Nov-08 10:54
ctrlnick14-Nov-08 10:54 
QuestionDo we have a something like MASK effect (in SwishMax or Flash) in WPF? Pin
Mohammad Dayyan14-Nov-08 10:14
Mohammad Dayyan14-Nov-08 10:14 
AnswerRe: Do we have sth like MASK effect (in SwishMax or Flash) in WPF? Pin
Pete O'Hanlon14-Nov-08 10:43
mvePete O'Hanlon14-Nov-08 10:43 
GeneralRe: Do we have sth like MASK effect (in SwishMax or Flash) in WPF? Pin
Mohammad Dayyan14-Nov-08 10:48
Mohammad Dayyan14-Nov-08 10:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.