create a texture with a memoryStream

Started by
13 comments, last by cgillopez 15 years, 1 month ago
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?
Advertisement
Read this. In particular, note that you cannot create a render target in system memory. You need to use the default pool and remove the initial data, or change the usage.

[Edited by - jpetrie on March 17, 2009 11:11:05 AM]
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...

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?
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.
Okay. You don't need to use the RenderTarget usage for this.
How i have to do it? im dont know how to...
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).
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?
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.

This topic is closed to new replies.

Advertisement