Sign in to follow this  

create a texture with a memoryStream

This topic is 3191 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i tried to give a memorystream to create a new texture but i "get an error application": Dim ms As New MemoryStream() Dim a As New Bitmap("c:\temp\movie_view.png") a.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp) Dim dat As Byte() = ms.ToArray() return New Texture(device, ms, Usage.RenderTarget, Pool.SystemMemory) could anyone help me?

Share this post


Link to post
Share on other sites
Thanks for your replay.

Im still having the same problem (error in application):

New Texture(device, ms, Usage.RenderTarge, Pool.Default)

Maybe im doing wrong, i dont know which options are needed...

Share this post


Link to post
Share on other sites
It also does not make sense to create a render target with initial image data. It's a render target -- you fill it with data by rendering to it. The particular MDX constructor you're calling will try to lock the texture for write access on the CPU, which won't work.

What are you really trying to do?

Share this post


Link to post
Share on other sites
Im a newbie (i have started today) with direct3d..

I started another thread: http://www.gamedev.net/community/forums/topic.asp?topic_id=528143

"know i have a problem with this line:

aBitmap = Bitmap.FromStream(mStream, False, True)

(where mStream is a memoryStream which contains the byte() bitmap frame)

which works with a lot of CPU, and i thought if i could paint it more efficiently the problem wouldnt make so much "noise"."


I get an jpeg format images (one by one) from the camera in a byte(), which i convert to memoryStream, and then to bitmap so i can paint a pictureBox. If i can "work" and render directly with the byte() i think the neckbottle wont exist.

So now what i want to do is create a texture with the byte() and show it in a form.. i downloaded an example from http://www.codesampler.com/usersrc/usersrc_1.htm#dx9vbu_texture and i tried to convert an image (.png) to a memorystream and then, use direct3d to show it.

Thanks.

Share this post


Link to post
Share on other sites
None, or AutoGenMipMaps, should be reasonable. Consult the documentation for D3DUSAGE and use the combination of values that make sense for what you want to do, which appears to be simply using the texture to render with (not render to, but render with, as in using it to texture some object).

Share this post


Link to post
Share on other sites
Thanks jpetrie for your reply!

I dont understand very well, "None, or AutoGenMipMaps".. sorry if this question is too obvious but i dont know what you means with "none".

Could you please tell me which steps do i need to do?

Share this post


Link to post
Share on other sites
Instead of Usage.RenderTarget, try Usage.None. Or Usage.AutoGenMipMaps. I may have the spelling/wording of that last one off slightly -- Managed DirectX is dead, so its been years since I've used it. But Intellisense in the IDE should help you out.

Share this post


Link to post
Share on other sites
I tried with both but i have the same error. What can be wrong?

Dim ms As New MemoryStream()
Dim a As New Bitmap("C:\temp\DirectDraw\dx9vbu_mesh\Texture0.bmp")
a.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp)
Dim dat As Byte() = ms.ToArray()
texture = createTexture(ms)

Function createTexture(ByVal ms As MemoryStream) As Texture
Try
Dim asd As New Texture(device, ms, Usage.AutoGenerateMipMap, Pool.Default)

Catch ex As Exception
Console.Out.WriteLine(ex.Message) --> Application Error
End Try

This is driving me crazy....

Share this post


Link to post
Share on other sites
Enable the debug runtimes in the D3D control panel, which is in the Start Menu entry for the DX SDK. Then turn on Unmanaged Debugging in VS, or use something like DebugView. It will produce more detailed output.

Share this post


Link to post
Share on other sites
Hello again,

Im still having problems..

I turn on:
*Debugging: Maximum validation, Enable shader debugging, Break on memory leaks, break ib D3D9 error, Enable multi-mon debugging

*Debug output level: More

And if i enable Debug/Retail version of Direct3D 9 --> Use retail version of Direct3D 9; the application goes stright till
Dim asd As New Texture(device, ms, Usage.AutoGenerateMipMap, Pool.Default)

When it goes throw, it doesnt do anything, if i enable Use debug version of Direct3D 9; it gives an "error application".

Share this post


Link to post
Share on other sites

This topic is 3191 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this