 |

06-22-2009, 01:43 PM
|
Junior Contributor
|
|
Join Date: Sep 2004
Posts: 235
|
|
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 
|
|

06-23-2009, 12:42 PM
|
Junior Contributor
|
|
Join Date: Sep 2004
Posts: 235
|
|
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?
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|