Jump to content
  • Advertisement
Sign in to follow this  
cgillopez

create a texture with a memoryStream

This topic is 3477 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
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]

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
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!