XNA Creators Club Online
Page 1 of 1 (3 items)
Sort Posts: Previous Next

copy IDirect3DTexture9 to another IDirect3DTexture9

Last post 19/10/2009 20.18 by legalize. 2 replies.
  • 03/09/2009 23.01

    copy IDirect3DTexture9 to another IDirect3DTexture9

    Hi all,
    Im using 2d sprites, and I would like to copy a small rectangle which is in the middle of the big sprite, to another sprite sized as that rectangle.
    I load my textures like this :
    1  
    2 D3DXCreateSprite(StdGfx::GetD3DDev(),&spritedata.d3dfigurespt);   
    3 D3DXCreateTextureFromFileEx(StdGfx::GetD3DDev(), // the device pointer  
    4 bmpfilename, // the file name  
    5 D3DX_DEFAULT, // default width  
    6 D3DX_DEFAULT, // default height  
    7 D3DX_DEFAULT, // no mip mapping  
    8 NULL, // regular usage  
    9 D3DFMT_A8R8G8B8, // 32-bit pixels with alpha  
    10 D3DPOOL_MANAGED, // typical memory handling  
    11 D3DX_DEFAULT, // no filtering  
    12 D3DX_DEFAULT, // no mip filtering  
    13 D3DCOLOR_XRGB(255, 0, 255),// the hot-pink color key  
    14 NULL, // no image info struct  
    15 NULL, // not using 256 colors  
    16 &spritedata.figureanim); // load to sprite  
    17  
    where spritedata.figureanim is of type LPDIRECT3DTEXTURE9 and spritedata.d3dfigurespt is of type LPD3DXSPRITE
    Any help will be appreciated :)
    Thanks
  • 04/09/2009 5.12 In reply to

    Re: copy IDirect3DTexture9 to another IDirect3DTexture9

    try this function D3DXLoadSurfaceFromSurface. Another way of doing this is locking the texture resource and reading out the relevant pixel data and stroring that in a memory block. Then create a new texture and upload the data to it.

    Bear in mind that reading from a texture on CPU side can be really slow, espacially when the default pool is used.
  • 19/10/2009 20.18 In reply to

    Re: copy IDirect3DTexture9 to another IDirect3DTexture9

    As long as the two sprite textures are the same format, you can copy directly between them by using StretchRect. Get the surface interface for each texture's level and then StretchRect from one to the other. This is ultimately what D3DX utility functions will do, but in your case you don't need the extra functionality of D3DX, a simple StretchRect will suffice.
Page 1 of 1 (3 items) Previous Next
var gDomain='m.webtrends.com'; var gDcsId='dcschd84w10000w4lw9hcqmsz_8n3x'; var gTrackEvents=1; var gFpc='WT_FPC'; /*<\/scr"+"ipt>");} /*]]>*/
DCSIMG