Jump to content
  • Advertisement

simin

Member
  • Content Count

    5
  • Joined

  • Last visited

Community Reputation

100 Neutral

About simin

  • Rank
    Newbie
  1. Thanks a lot! Thanks to You I was able to find wrong part of my code. It seems that on notebook pitch is the same size as the stride. When I fill texture bytes it used to be: var data = texture.LockRectangle(0, LockFlags.None); for (int i = 0; i < Height; i++) { data.Data.Write(TextureBytes, (Height - 1 - i)*Stride, Stride); } And the corrent version is: var data = texture.LockRectangle(0, LockFlags.None); for (int i = 0; i < Height; i++) { data.Data.Write(TextureBytes, (Height - 1 - i)*Stride, Stride); data.Data.Position += data.Pitch - Stride; }
  2. Hi! I have a big problem with my DirectShow (DirectShow.Net)/ DirectX (SlimDX) application. It worked perfectly fine on my notebook, but when I moved application to another machine output is not right. This is how it looks like in correct output: And there is what i get on other machine: DirectShow graphs looks the same: webcam -> smart tree -> Color Space converter -> Frame Grabber -> Null Renderer. The application simply captures the frame and set it as a texture in DirectX. I capture frames in ARGB32 format. Computers: Notebook (good result) Intel Core 2 Duo T9300 ATI Mobility Radeon HD 3650 Windows 7 Pro x64 SP1 K-Lite Mega Codec Pack 6.6.0 PC (bad result) Intel Core 2 Quad Q8300 MSI GeForce GTS250 1GB Windows 7 Pro x64 SP1 K-Lite Mega Codec Pack 8.4.0 Webcam: Logitech Pro HD C910 I suspect DirectShow problem with settings, but I dont know where to look for them. Can You tell me, so I can configure PC the same as notebook and run app on that? Thanks, Andrew
  3. Hi! I have a problem with drawing textured object in DlimDX (D3DX9). I have a rectangle that is textured with image from webcam. It works OK until I resize rectangle. When I resize the object, texture fades and disappears. If size is less than 33% - texture is 100% transparent. If size is 66% or more - texture 100% visible. Between that values transparency is linear. When I turn off the alpha blending in effect file object gets dark instead of transparent. There is creation of my texture from memory: tex = new Texture(_device, SourceWidth, SourceHeight, 0, Usage.Dynamic, Format.A8R8G8B8, Pool.Default); var data = tex.LockRectangle(0, LockFlags.None); for (int i = 0; i < SourceHeight; i++) { data.Data.Write(TextureBytes, (SourceHeight - 1 - i)*SourceStride, SourceStride); } tex.UnlockRectangle(0); There is creation of rectangle (updated every time) if (Resize) { Width *= (WidthRatio/100); Height *= (HeightRatio/100); } var v = new[] { new BillboardVertex() {Position = Center - Height*NUp - Width*NRight, Texcoord = new Vector2(0, 1)}, new BillboardVertex() {Position = Center + Height*NUp - Width*NRight, Texcoord = new Vector2(0, 0)}, new BillboardVertex() {Position = Center - Height*NUp + Width*NRight, Texcoord = new Vector2(1, 1)}, new BillboardVertex() {Position = Center + Height*NUp + Width*NRight, Texcoord = new Vector2(1, 0)}, }; _vertices.Lock(0, 0, LockFlags.None).WriteRange(v); _vertices.Unlock(); And used Effect file: float4x4 worldViewProj; texture tex0; sampler2D sampler0 = sampler_state { texture = tex0; MinFilter = Linear; MagFilter = Linear; MipFilter = Linear; }; void vsmain(float3 pos : POSITION, float2 texc : TEXCOORD0, out float4 oPos : POSITION, out float2 oTexc : TEXCOORD0) { oPos = mul(float4(pos,1), worldViewProj); oTexc = texc; } float4 psmain(float2 texc : TEXCOORD0) : COLOR { float4 color = tex2D(sampler0, texc); return color; } technique std { pass { AlphaBlendEnable = true; SrcBlend = SrcAlpha; DestBlend = InvSrcAlpha ; ZWriteEnable = false; CullMode = NONE; VertexShader = compile vs_2_0 vsmain(); PixelShader = compile ps_2_0 psmain(); } } It would be great if anyone could tell me how to fix that. Thanks, Simin
  4. Hi, I just realized that Texture.FromMemory would work if I have complete file in memory, and I have only raw pixels. I changed texture creation to: tex = new Texture(_device, Width, Height, 0, Usage.Dynamic, Format.A8R8G8B8, Pool.Default); var data = tex.LockRectangle(0, LockFlags.None); data.Data.Write(TextureBytes, 0, FrameLength); tex.UnlockRectangle(0); and it works quite well. Now I need to find a way to rotate TextureBytes quickly (the image i get is upside down) but it shouldn't be a problem.
  5. Hi! I have a problem creating texture from memory. I have array of bytes containing pixels data in format A8R8G8B8, but every time I try to execute method tex = [color="#2b91af"]Texture.FromMemory(_device, _textureBytes); I receive exception: D3DXERR_INVALIDDATA: Invalid data (-2005529767) When I execute following code: GCHandle handle = GCHandle.Alloc(_textureBytes, GCHandleType.Pinned); int scan0 = (int)handle.AddrOfPinnedObject(); scan0 += (Height - 1) * Stride; Bitmap b = new Bitmap(Width, Height, -Stride, System.Drawing.Imaging.PixelFormat.Format32bppArgb, (IntPtr)scan0); handle.Free(); b.Save(@"name.bmp"); tex = Texture.FromFile(_device, @"name.bmp"); it works fine (just really slow). _textureBytes is actually frame captured with DirectShowNet (SampleGrabber), and processed in another function, so it will be updated really frequently. How do I create texture from that array, so it doesn't throw exception and work as fast as possible? Regards, Simin
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!