   Loading images using dx 9 for 3D
  hey all,its been a while since i've done much programming and i've already run into an annoying problem:i want to load an image using a few dx functions and then be able to render it (or any portion of it) anywhere within a 3d world, or on top as a gui or hud. however,  somewhere along the lines the image data gets messed up - i know this because it will still render, and using other less useful methods of loading images i can render images properly.here's my loading code://create a surface for the imageD3DDevice->CreateOffscreenPlainSurface(width, height, D3DFMT_A1R5G5B5, D3DPOOL_DEFAULT, &Image, NULL);//load the image dataD3DXLoadSurfaceFromFile(Image, NULL, NULL, szFileName, NULL, D3DX_FILTER_NONE, colourKey, NULL);//create a texture for easy renderingD3DXCreateTexture(D3DDevice, width, height, 1, 0, D3DFMT_A1R5G5B5, D3DPOOL_DEFAULT, &Texture);LPDIRECT3DSURFACE9 pTexSurface;pTexture->GetSurfaceLevel(0, &pTexSurface); //pointer to texture surface//Clear the texture with a colourD3DDevice->ColorFill(pTexSurface,NULL,D3DCOLOR_XRGB(0,0,0));// Copy the image to the texture - "from" is a RECT of the area i want to create a texture ofD3DDevice->StretchRect(Image, &from, pTexSurface, NULL, D3DTEXF_NONE);i think the problem is somewhere in the creation of the surface but i really haven't any evidence that this is definate so that is why i'm asking for help.if anyone knows of a way for me to accomplish what i am trying to do in a similar (or better ;)) manner, please let me know!thanks in advance,   
  Maybe just use two triangles as a square and render onto that instead of an offscreenplainsurface?   ;Quote:Original post by the_mooif anyone knows of a way for me to accomplish what i am trying to do in a similar (or better ;)) manner, please let me know!Do you actually need to use the IDirect3DSurface9 after you've run this code? If not, avoid the middle-man and go directly to IDirect3DTexture9's via the following functions:D3DXCreateTextureFromFileEx()D3DXCreateTextureFromFile()If they don't change much, then a better description of the visual corruption might be beneficial [smile]hthJack   ;  @xpyder:the problem isn't in rendering the image - that works fine - it's just the image doesn't appear anywhere near normal - it doesn't even look like the image. also, i use the method you mentioned to render my 2D stuff already [wink]. it seems i'm rendering bad image data. [edit] i've mentioned it a little further in this post how i know this is true. [/edit]@jollyjeffers:yeah i want to be able to keep the surface for creating multiple textures from it. this is why i asked if there is a better way of doing it because imagine this:using this method i can load the image onto a surface then copy individual sprites onto textures so i can then use them like i mentioned before.i'm not sure if this is the best way of doing it, but basically after all textures or sprites are created from the image i can then release it when i wish.as for using those 2 functions, i mentioned that i used another method that worked - that was it [smile].actually, i suppose i could try loading the image onto a texture and copying the sections in the same way i'm already using... any thoughts?thanks for the suggestions so far,   