DirectShow buffercb and DirectX
DirectShow buffercb and DirectX
DirectShow buffercb and DirectX
DirectShow buffercb and DirectX
DirectShow buffercb and DirectX
DirectShow buffercb and DirectX DirectShow buffercb and DirectX DirectShow buffercb and DirectX DirectShow buffercb and DirectX DirectShow buffercb and DirectX DirectShow buffercb and DirectX DirectShow buffercb and DirectX DirectShow buffercb and DirectX
DirectShow buffercb and DirectX DirectShow buffercb and DirectX
DirectShow buffercb and DirectX
Go Back  Xtreme Visual Basic Talk > > > > DirectShow buffercb and DirectX


Reply
 
Thread Tools Display Modes
  #1  
Old 06-22-2009, 02:43 PM
Richard87 Richard87 is offline
Junior Contributor
 
Join Date: Sep 2004
Posts: 235
Question DirectShow buffercb and DirectX


Hello

I have a problem trying to process my webcams picture in a texture in DirectX.

The problem is that my graffics card can only handle textures with the size of power of 2(eg. 512,1024 etc) so when my webcam only returns the picture as a frame of 640x480 i have a problem:P.

So, i have 2 solutions, 1 redirect all the pixels in a vertex shader, Ore, the slower, but easy way, just copy 1 line at a time with marshall.copy.

this is what I got so far:
Code:
                        Dim bm2() As Byte
                        m_text = New Texture(Display, 1024, 512, 0, Usage.Dynamic, Format.X8R8G8B8, Pool.Default)
                        bm2 = m_text.LockRectangle(GetType(Byte), 0, rect, Microsoft.DirectX.Direct3D.LockFlags.None, IPA)
                        'Marshal.Copy(pBuffer, bm2, 0, BufferLen)
                        Dim X As Integer, y As Integer = 0
                        For X = 0 To bm2.Length - 1 Step (1024 * 4)
                            Marshal.Copy(pBuffer, bm2, X, 640 * 4 * y)
                            y = y + (640 * 4)
                        Next

                        m_text.UnlockRectangle(0)
but that is not working:S

any tips would be greatly appreciated
Reply With Quote
  #2  
Old 06-23-2009, 01:42 PM
Richard87 Richard87 is offline
Junior Contributor
 
Join Date: Sep 2004
Posts: 235
Default

OK, i managed to produce a picture, but I have still some problems(here is my code:

Code:
                        Dim bm2() As Byte
                        Dim bData(BufferLen) As Byte


                        m_text = New Texture(Display, 1024, 512, 0, Usage.Dynamic, Format.X8R8G8B8, Pool.Default)
                        bm2 = m_text.LockRectangle(GetType(Byte), 0, rect, Microsoft.DirectX.Direct3D.LockFlags.None, IPA)

                        Marshal.Copy(pBuffer, bData, 0, BufferLen)

                        Dim X As Integer = 0, y As Integer = 0
                        Dim stride As Integer = 640 * 3, stride2 As Integer = 1024 * 4

                        Do
                            Array.Copy(bData, X, bm2, y, stride)

                            X = X + stride
                            y = y + stride2
                        Loop Until y >= bm2.Length

                        m_text.UnlockRectangle(0)
but my as you can notice, my data is coming in as 24bits(1byte for each color), but my textures takes 32bits in(1byte for alpha channel)


my question is, what is the most effective way of inserting 1 byte for every 3 byte in the array?
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
DirectShow buffercb and DirectX
DirectShow buffercb and DirectX
DirectShow buffercb and DirectX DirectShow buffercb and DirectX
DirectShow buffercb and DirectX
DirectShow buffercb and DirectX
DirectShow buffercb and DirectX DirectShow buffercb and DirectX DirectShow buffercb and DirectX DirectShow buffercb and DirectX DirectShow buffercb and DirectX DirectShow buffercb and DirectX DirectShow buffercb and DirectX
DirectShow buffercb and DirectX
DirectShow buffercb and DirectX
 
DirectShow buffercb and DirectX
DirectShow buffercb and DirectX
 
-->