Sign in to follow this  
NextEpisode1

Auto BMP masking

Recommended Posts

Hy , im currently working on a 8 direction isometric game (still project phase) , so i got my sprites , but due to their complexity (detail and shadows) drawing an individual mask for each manually and loading them to resources will be at least time and resource waste,

does any1 know a link where is described how to programatically edit/create a *.bmp so i can develop an algorithm for automated masking. Thanks in advance


Cheers

Share this post


Link to post
Share on other sites
I think bmp is one of the easiest formats to handle, you just have to figure out how to read the header and then the rest of the bytes are just sitting there in memory for reading.

Do you understand binary file i/o? If so then I think a wikipedia article for BMP might be all that you need.

Alternatively, are you sure you need a specialized mask? What do the backgrounds of your sprites look like? If they are a certain color you can just filter that out pretty easily without having to create custom masks for each sprite.

Share this post


Link to post
Share on other sites
perhaps you can create new images from the originals where you change all pixels that are not of a certain color to black, then either save the images or do this on the fly or at loading time.

Share this post


Link to post
Share on other sites
Quote:
Original post by karwosts

If they are a certain color you can just filter that out pretty easily without having to create custom masks for each sprite.


thats interesting ,they actually are how do you suggest to mask a certain color?

Share this post


Link to post
Share on other sites
Quote:

how do you suggest to mask a certain color?


It really just depends on how you're drawing the graphics. Are you using opengl, directx, sdl, some software blitting, or what?

EDIT:

Well actually its probably the same scenario for any case. If you are using DX/OGL then you could use a pixel shader to reject pixels of a given color. Alternatively, you can just expand your RGB image to an RGBA image and set A=0 for your unwanted pixels. Then use alpha reject to throw out the fragments with 0 alpha (this should be applicable to any graphics engine).

[Edited by - karwosts on September 30, 2010 2:15:44 PM]

Share this post


Link to post
Share on other sites
Quote:
Original post by karwosts
Quote:

how do you suggest to mask a certain color?


It really just depends on how you're drawing the graphics. Are you using opengl, directx, sdl, some software blitting, or what?


None , im using a custom double-buffer and the win32 api blitting functions , well directx will ease the work a lot but i just started to learn about it ,so im not proficient at all using that lib.

Share this post


Link to post
Share on other sites
Does your render target support alpha channels? I'm not that familiar with Win32 blitting. If it doesn't I think you'd need to move to a proper graphics API.

Share this post


Link to post
Share on other sites
Quote:
Original post by karwosts
Does your render target support alpha channels? I'm not that familiar with Win32 blitting. If it doesn't I think you'd need to move to a proper graphics API.


http://msdn.microsoft.com/en-us/library/dd145141(v=vs.85).aspx

i didnt know that was already done. Thanks for the hints regarding this issue. i ow you :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this