Re: D3DXLoadSurfaceFromMemory problem

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



The image info always returns the closest format that resembles the file's
internal pixel representation. So, for a 24-bit BMP you will get a
D3DFMT_R8G8B8 and so on.
The output texture format can be obtained from
IDirect3DTexture9::GetLevelDesc().

--
Wessam Bahnassi
Microsoft DirectX MVP,
Lead Programmer
In|Framez
--
In|Structurez Arabic Gamedev Community
www.instructurez.com


"gameMaker" <gameMaker@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:AEFCFE74-687F-439A-A9CD-ECB0ABBB2674@xxxxxxxxxxxxxxxx
> So, maybe the ImageInfo returned from this function just tells me the
> original image info? And if I use D3DXGetImageInfoFromFileInMemory()
> maybe
> that will tell me that it has been converted to an alpha texture? I will
> try
> this...
>
>
>
> "gameMaker" wrote:
>
>> That is what is in the D3DXImageInfo structure that is returned from
>> D3DXCreateTextureFromFileEx().
>>
>> hResult = D3DXCreateTextureFromFileEx(
>> pDevice, // Device
>> rTextureID.c_str(), // file to load
>> uiWidth, // Width
>> uiHeight, // Height
>> D3DX_FROM_FILE, // Number of Mip-levels
>> 0, // Usage
>> D3DFMT_A8R8G8B8, // format I want to convert it to
>> pool, // The resource buffer we're using (scratch)
>> D3DX_FILTER_POINT, // filter D3DX_FILTER_NONE, // Mip
>> Filter
>> color_key, // Transparent color key
>> &myTextureValue.m_ImageInfo,// Details about the image.
>> NULL, // Palette entry.
>> &myTextureValue.m_pTexture );// Address of texture loaded.
>>
>> I also found out something else. It works if I do this: When the
>> texture
>> is NOT color keyed, I use the format for the source texture in scratch
>> memory
>> (just like the documentation says). But, when the texture IS color
>> keyed, I
>> use the format for the destination (Dynamic texture). That seems to
>> work.
>> But I am still puzzled as to why my texture in scratch memory is not an
>> alpha
>> texture format?
>>
>>
>> "Wessam Bahnassi" wrote:
>>
>> > How do you know what is the format of the newely created scratch
>> > texture?
>> >
>> > --
>> > Wessam Bahnassi
>> > Microsoft DirectX MVP,
>> > Lead Programmer
>> > In|Framez
>> > --
>> > In|Structurez Arabic Gamedev Community
>> > www.instructurez.com
>> >
>> >
>> > "gameMaker" <gameMaker@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
>> > news:948D34BD-67D2-4AD5-B21C-A61F2247DBE9@xxxxxxxxxxxxxxxx
>> > > Yes.
>> > >
>> > > It seems that the real problem is when I create my texture with
>> > > D3DXCreateTextureFromFileEx and use a color key, it is not giving me
>> > > back
>> > > a
>> > > texture with alpha. Even when I specify that I want to create a
>> > > D3DFMT_A8R8G8B8 texture, it gives me back the same format as the file
>> > > (D3DFMT_R8G8B8). Is there something I don't know about creating
>> > > textures
>> > > in
>> > > SCRATCH memory? Does D3D treat SCRATCH memory different and decide
>> > > that I
>> > > shouldn't have an alpha texture stored there?
>> > >
>> > > Then, when I copy this texture to my texture in DEFAULT memory, the
>> > > texture
>> > > formats are different (since I assumed that it was going to create an
>> > > alpha
>> > > texture for me).
>> > >
>> > > It seems to work with the directx debug dll, but maybe that is just a
>> > > symptom of something else.
>> > >
>> > > "Richard [Microsoft Direct3D MVP]" wrote:
>> > >
>> > >> [Please do not mail me a copy of your followup]
>> > >>
>> > >> =?Utf-8?B?Z2FtZU1ha2Vy?= <gameMaker@xxxxxxxxxxxxxxxxxxxxxxxxx> spake
>> > >> the
>> > >> secret code
>> > >> <E4C8A7D0-DD56-448E-88D9-3B74C3E5A47F@xxxxxxxxxxxxx> thusly:
>> > >>
>> > >> >I am copying a texture from SCRATCH memory to my texture every
>> > >> >frame.
>> > >> >This
>> > >> >works great with the directx debug dll. But, when I use the
>> > >> >release
>> > >> >version
>> > >> >of directx runtime, my texture looks like the wrong format and
>> > >> >after a
>> > >> >few
>> > >> >seconds crashes with an exception on this line. Does anybody know
>> > >> >why
>> > >> >the
>> > >> >retail version would be different?
>> > >>
>> > >> Are you also compiling your code in release?
>> > >> --
>> > >> "The Direct3D Graphics Pipeline"-- code samples, sample chapter,
>> > >> FAQ:
>> > >> <http://www.xmission.com/~legalize/book/>
>> > >> Pilgrimage: Utah's annual demoparty
>> > >> <http://pilgrimage.scene.org>
>> > >>
>> >
>> >
>> >


.



Relevant Pages

  • Re: Texture Problem
    ... > yes, pitch is always> width. ... the universe would not work properly ... Bare in mind that it is VERY format sensitive, ... > alpha texture from scratch. ...
    (microsoft.public.win32.programmer.directx.graphics)
  • Re: Culling using LPD3DXMESH?
    ... does that mean cutting up the texture file manually? ... > use the term 3D format to explain a file containg data for a 3D mesh. ... > data in the file along with the mesh such as the octree in its generated ...
    (microsoft.public.win32.programmer.directx.graphics)
  • Re: Displaying grey level images and video with OpenGL
    ... format, and run you controls via a simple shader. ... Starting with my glTexImage2Dfunction where I define my texture, ... float" pixel format... ...
    (comp.graphics.api.opengl)
  • Re: problems on clipped values in the texture used in a GLSL shader program
    ... What are the modes for handling the texture coordinates? ... I set the dataTex internal format as GL_ALPHA8, ... So I donot use any slices. ... texture coordinate that lies inside the region occupied by the slices, ...
    (comp.graphics.api.opengl)
  • Re: S3TC compression
    ... >> - If I load a texture and compress it with this format, ... >> save/reload the binary data created? ... > Yes - use glGetCompressedTexImageARB() ...
    (comp.graphics.api.opengl)