How to create a new Texture from an existent Texture?

How to create a new Texture from an existent Texture

I have a bitmap file, first I created a Texture from a bitmap file by using function D3DXCreateTextureFromFile().

Now I want to create an another Texture from the existent Texture, and the new Texture's content is the existent one's bitmap but be rotated 15 degrees.

For Example: the existent Textures have a horizontal line "-" on it's center , from the old Textures I can create another three Textures by rotating different degrees, and the another Textures looks like "\", "|" or "/" .

How to do this I only want to create a series of sequential Textures from one Texture, not to rotate a point with Texture in 3D matrix.

At last, the example I rotate a Texture bitmap around Z axis, if it can be work out,then how to do this around X axis or Y axis

The textures is used for point sprites.so must be rotated.


Thanks



Answer this question

How to create a new Texture from an existent Texture?

  • Saleem Yusuf

    need more help, thanks 
  • Yaron Lavi

    thanks, but I created Texture1 from a bitmap file, and I want createTexture2 from Texture1 not from file.


  • er1067

     

    oh, not a exact sample.

    it's so hard for me to understanding...


  • Newbie2007

     

    What you need is to RenderToTarget on a Texture1

    Then Save that Texture to a File

    Make sure that when you create your Texture1 you use the Usage.RenderTarget :

    Texture1 = new Texture(window.D3DDevice, 128, 128, 1, Usage.RenderTarget, Format.X8R8G8B8, Pool.Default);

    surface = texture.GetSurfaceLevel(0)

    You then Get The Surface of that Texture as a Target of what you will draw
    And you tell the Device to use it as the Target this way :

    window.D3DDevice.SetRenderTarget(0, surface);

    You draw the Texture2 with the image you want with the rotation you need

    as if any other Device-> call (Begin Scene, End Scene, Clear etc...)

    At the end you will have a Texture1 that is the Output of what you draw

    You ''just'' have to save it in a File...(I think there is a function to do this)


    http://www.pieterg.com/Tutorials/tutorial7.php


  • vcboy

     

    please look my question,i want to know not only how to  create a new Texture from an existent Texture but also how to rotate the content of existent one.

    thanks:)

     


  • ruju

    sorry.

    I must rotate texture' content arround Z axis or X Y axis, because I use point sprites to render a point in different time, so i must  rotate texture' content.


  • Alan M. Carroll

    Etienne explained it.

    Load your first texture, create a render target, draw a quad textured with the first texture into the render target. You can rotate the quad when you draw it just like you roate any textured mesh. Your render target now contains the rotated texture.

    However generally there is no need to actually rotate the texture - you should be able to either set the texture coordinates of the mesh to do the rotation http://msdn.microsoft.com/coding4fun/zman/zmanTextures2/default.aspx or apply a transformation to the texture in the texture stage setup http://www.c-unit.com/tutorials/mdirectx/ t=52



  • BMF

     

     

        D3DXCreateTextureFromFileInMemory



  • dschon

    Since you need a new texture you will havew to use my 1st suggestion which is to render your original texture to a quad, then render that into another texture with a transform applied.

    Look for render to texture examples like this one

    http://www.riaz.de/tutorials/d3d.html#tut16



  • Maju V Poulose

  • How to create a new Texture from an existent Texture?