View Single Post
 
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