Xtreme Visual Basic Talk

Xtreme Visual Basic Talk (http://www.xtremevbtalk.com/)
-   Managed DirectX (http://www.xtremevbtalk.com/managed-directx/)
-   -   DirectShow buffercb and DirectX (http://www.xtremevbtalk.com/managed-directx/308242-directshow-buffercb-directx.html)

Richard87 06-22-2009 02:43 PM

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:D

Richard87 06-23-2009 01:42 PM

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?


All times are GMT -6. The time now is 02:48 PM.

Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Optimisation provided by DragonByte SEO v2.0.15 (Lite) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
All site content is protected by the Digital Millenium Act of 1998. Copyright©2001-2011 MAS Media Inc. and Extreme Visual Basic Forum. All rights reserved.
You may not copy or reproduce any portion of this site without written consent.