Jump to content

Merge a grayscale image as an alpha channel


Recommended Posts

I am trying to "hack" the spritesheets limitations by using JPG images with alpha channel.

The process is simple:
- I have a starting PNG with alpha channel
- from this PNG I save a JPG (with varying fill colour for originally transparent areas)
- from the PNG I extract the alpha channel and save it as an opaque indexed colour grayscale image
- I load the new JPG and the grayscale PNG, and use the PNG as alpha channel for the JPG.


These are the two images, the JPG and the grayscale PNG
0a1a8fa3dc4f75ed.jpg 548c90a06bbb7b08.png


animBitmapData is BitmapData from the JPG
animBitmapData_ALPHA is BitmapData from the grayscale PNG


I did everything, but the last step doesn't work, animBitmapData is still opaque

animBitmapData.copyChannel(animBitmapData_ALPHA, animBitmapData_ALPHA.rect, new Point(0, 0), BitmapDataChannel.ALPHA, BitmapDataChannel.RED);

animBitmapData.transparent returns false, could this be the problem?

Or maybe it is not correct to use a grayscale image as alpha channel?


- Coding in Haxe + OpenFl -

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...