DizzyThermal Posted yesterday at 01:49 AM Share Posted yesterday at 01:49 AM Hello! I'm trying to understand a binary format of an image transparency mask for NexusTK - a 2D MMORPG from 1996. (Disclaimer: I received help back in the XeNTaX days, and no longer have a way to contact who helped, so my understanding of this format is not great - that's why I'm asking here ). To build my transparency masks, I use the following code - it's GDScript so the code is python-ish: var STENCIL_MASK := 0x80 var mask_image := Image.create(width, height, false, Image.FORMAT_RGBA8) for i in range(height): var total_pixels := 0 while true: var pixel_count := read_u8() if pixel_count == 0x0: break # End of mask var should_draw := false if pixel_count > STENCIL_MASK: should_draw = true if should_draw: # Not sure why this works pixel_count = pixel_count ^ STENCIL_MASK for j in range(pixel_count): var pixel_color := Color.TRANSPARENT if should_draw: pixel_color = Color.BLACK mask_image.set_pixel(total_pixels, i, pixel_color) total_pixels += 1 if total_pixels < width: for j in range(width - total_pixels): mask_image.set_pixel(total_pixels, i, Color.TRANSPARENT) An example mask and image are: The mask is used to blit out the background pixels that aren't suppose to be rendered (pink pixels above). Is this image mask format common or custom (like I'm not sure why 0x80 is a special value)? Is there a better way I can build this transparency mask, instead of pixel by pixel? Thanks! -DizzyThermal Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now