Archived

This topic is now archived and is closed to further replies.

IFooBar

how would u load in an adobe photoshop image into a texture?

Recommended Posts

hello i was ondering how you would load in an adob photo shop image or maybe a corel photopain image into directx. something along teh lines of D3DXCreateTextureFromFile(...)? would you have to parse teh file yourself? and how would you do that? where do i start? thanks


Al **MY HQ**

Share this post


Link to post
Share on other sites
If you''re talking about loading a .PSD file, then you''d have to parse the file yourself (start at www.wotsit.org).

Alternatively you or the artist would simply save into a common format such as .TGA or .PNG and then use D3DXCreateTextureFromFile().

D3DXCreateTextureFromFile() won''t load .PSDs since they''re not a common format - that''s the internal format for Photoshop - it isn''t intended to be a final asset format.

--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites
hello

what if i want to export from PSD into my own format...say i name this format .ALF ? would i have to hack into Adobe photoshop to make an exporter to the .ALF format or are there some coomon steps that one must take to make an exporter?

where do i start?

thanks again





Al
**MY HQ**

Share this post


Link to post
Share on other sites
You can use the Photoshop SDK to learn how to create an export plugin, or you can use Photoshop to save in another format like BMP or TGA.

The D3DX library comes with functions to load textures from common formats like BMP and TGA.

So you don''t really need your own format.


Helpful links:
How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions

Share this post


Link to post
Share on other sites
yeah i know it does all that. but all those comemrcial games have formats that u cant open with a normal pain program...i wanna give a shot at something like that. after i make my own image format then ill try to make my own text file format.. so any advice on doing that ... do u even need directX to do that?? ie load teh image into a texture?






Al
**MY HQ**

Share this post


Link to post
Share on other sites
Or just save the file as RAW in Photoshop. Nothing can open that without knowing the format, which you do. You can still load them in DirectX using the D3DX functions. Just load the file into memory yourself then use the D3DX load-texture-from-memory function.

Sounds like you''re wasting time that would be better spent elsewhere in your project though.


Helpful links:
How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions

Share this post


Link to post
Share on other sites
Quick aside:

1. I''d always use binary .PPM files rather than plain .RAW. A .PPM file is simply raw data except it has a very simple ASCII header immediately before the data so you get raw data with the benefits of being able to pick any file and know its dimensions. PPMs are also dead easy to write (i.e. a single fprintf() for the header followed by an fwrite() for data.

2. Most PC games use common formats like TGA!. Sometimes the extensions might be different, and commonly they''ll be bundled into a large PAK files, but it simplifies the whole process to use a common format. A few games use some semi specialised formats such as .DXT/.S3TC (Direct3D/S3TC compressed textures & mipmap chains) or meshes with embedded textures (like RAD Gametools Granny).

For the PC there isn''t any justification for making your own image file format these days! Consoles however are a different matter because you know exactly what the destination hardware version of the texture is going to be like so you can pre-swizzle and block in your own format.

--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites
If having end users change your images is a real concern for you then just encrypt the image files with an external program and decrypt them either into memory or a temp file from your main game executable and load it as a texture from there. If someone knows your encryption algorithm, they''ll still be able to change your images but it''s highly unlikely that anyone will be bothered to do all that.

-Auron

Share this post


Link to post
Share on other sites
Just stick your pics and textures into a dll as resources.
There are many DX helper functions that can load them from
resources. It is real easy to make and use one.
It does encapsulate all of your pics into one file, but
that makes even more hard to hack.

Share this post


Link to post
Share on other sites
quote:
Original post by Taulin
Just stick your pics and textures into a dll as resources.
There are many DX helper functions that can load them from
resources. It is real easy to make and use one.
It does encapsulate all of your pics into one file, but
that makes even more hard to hack.



Please don''t mislead others with bad advice. Hacking resources in executables or DLLs is a piece of cake with Resource Hacker. I guess that protection scheme of yours just went out the window!

"If people are good only because they fear punishment and hope for reward, then we are a sorry lot indeed." - Albert Einstein

Share this post


Link to post
Share on other sites
Geeze core,
Take a chill pill. It was not bad advice. It sounded like the original poster was trying to get away from people easily browsing the game files and loading or modifying them. The casual browser will not go through the trouble of using a Resource Hacker, even if they knew one existed, which 99% of game users do not.

There are rippers out there for pretty much anything. Custom encryption is the best way to go, but de-crypting resources everytime you need to use them might get slow. No matter how good of a scheme you think you may have, if your game becomes even remotely popular, people WILL figure out the file format.

So, core, I guess everyone''s advice here was bad since most things are crackable. However, all of the suggestions here, including mine, will stop casual browsing.

Too bad you wasted our time trying to flame me and not even offering any advice.

Share this post


Link to post
Share on other sites
I did offer advice: avoid using resources as secure storage. You may have taken the last sentence of my post as inflammatory, but I was only trying to make a point. I did no ranting and raving, it was just a simple post. Go pick a fight with someone else.

"If people are good only because they fear punishment and hope for reward, then we are a sorry lot indeed." - Albert Einstein

Share this post


Link to post
Share on other sites
If the existance of "Resource Hacker" is the reason you are dismissing using a resource dll, then all methods or trying to hide your files are invalid since there are equal tools out there to do the same thing. Model viewers, image rippers, as you probably know, they all exist. Also, like I just said, if your game becomes popular, they will exist in a short period of time, even if you make a custom format (again, except for the encryption idea).

I am sorry if I came across a bit too heavy. You just need to realize that your justification of not using one method, because a tool exists, is invalid.

Share this post


Link to post
Share on other sites
I have to agree that a custom file format would eventually be cracked, and that complete security isn''t attainable. However, I personally think that the resource DLL approach is one of the worst solutions for secure storage. At least with a custom file format he (alfmga) would be one step ahead of the would-be crackers. With the DLL approach, his game''s asset security would be defeated before the game is even released. I see the Spyro: YOTD article as a good example.

"If people are good only because they fear punishment and hope for reward, then we are a sorry lot indeed." - Albert Einstein

Share this post


Link to post
Share on other sites
Well, I never suggested a resource dll was the best solution, but it is still better than others, and far from the worst.

Not everyone has the time, knowledge or resources to create their own file formats, so what would you suggest would be the best security for common file types?

Share this post


Link to post
Share on other sites