SDL2 - How to process assets with separate alpha channel file?

Viewed 47

I recently came across some assets of old games, back from when PNG images don't get an alpha channel, and assets must be provided with another greyscale image, white as opaque, black as full transparent, and grey as semi-transparent.

While editing them with C++ file write could get the job done, that's a last resort considering the efforts involved.

I'd like to load and process them to be a render-ready texture, or alternatively somehow process them to be before loading. Pure SDL would be great, as I'm not quite yet ready to pull my own rendering implement. But if that's not possible/very inelegant to, any neat workaround like an image processing library/software is good too.

1 Answers

I would consider a small python helper script that would take the PNGs and combine them with the alphas and export them in the format you would expect.

So then you would have no runtime overhead or hassle and the files would be easier to edit in programs like photoshop.

Probably cv2 could be used for image processing: https://gist.github.com/garybradski/fabe4ce7ed5c042988b748780393370c

Related