Loading Unique image formats

Started by
4 comments, last by philkills 17 years, 8 months ago
Hi, In many 2d games the images that are stored are stored in what seems to be a very unique image format. What i was looking to do was to somehow load these images and then pass them to directX functions so that i can display the data on screen. If anyone can suggest ways of converting unique files to a format that directX can utilise.. it would help me loads ^__^. I can already extract these files to edit them in paint etc... but i would like to be able to create my own unique format to protect the images from being stolen. The current format is as follows: header info containing: Amount of frames(for animations) Colour pallet in 16 bit(565) format(for reference to rest of file) Frame Info containing details such as: bytes to read for whole frames Image Dimensions Image Positioning for inside game The image also has a transparent colour of (in 16 bit format)63519. However, this is not located in the colour pallet.... instead it gives details whenever there should be transparent pixels, detailing the amount etc. Example: For each row their is 6 bytes detailing info about that row: GAPS(2 bytes) SPACES(2 bytes) PIXELS(2 bytes), if Gaps == 0 ... then a whole row is transparent. Gaps represents how many times after the pixel true pixel appears in that row that there are groups of transparent pixels. Spaces represents the amount of transparent pixels before the first pixel in the row. Pixels represents the amount of pixels to read after the first set of transparent pixels. If gaps > 1 then for each gap after the first set of pixels... there will be 4 more bytes detailing the spaces and pixels in the current gap. Thats about it.... Thank you to anyone that can help ^^
Advertisement
D3D only supports certain pixel formats. A8R8G8B8 is the most common. Look on MSDN for more.

You can load the pixel data however you want, but it needs to be stored in one of the d3d formats. You can create a texture and lock it the same way you do a vertex buffer. So once you load your file, lock the texture, and load in your pixel data into its format, and voila.

I think that is the best way to go about what you want to do. I'm pretty sure there isn't any good way to let d3d handle your textures for you. You need to use one of their formats, and let them handle the rest.

Hope that helps.
-------Harmotion - Free 1v1 top-down shooter!Double Jump StudiosBlog
im kinda new at DX.... how would you convert something into the format that DX can use....

sorry if this sounds kinda newbish =/
you move the data bits around so that they match the format it's using
P.S. your custom format above is kinda.... wierd
why not just use something standard and easy to load into DX
then to protect it from being stolen you just encrypt the files? have your program decrypt when loading
It's better than the 'security through obscurity' approach you're currently going for...
well the current approach benefits from also being a very good compression method.....

and what format is DX using? ... i know it can use different 1s.... but perhaps the simplest to convert to?

I'm assuming its in some sort of structure perhaps?
like:

struct
{
BYTE red;
BYTE green;
BYTE blue;
BYTE alpha; (??)
}

Or something?

btw thanx for your reply ^_^

This topic is closed to new replies.

Advertisement