mono / SkiaSharp

SkiaSharp is a cross-platform 2D graphics API for .NET platforms based on Google's Skia Graphics Library. It provides a comprehensive 2D API that can be used across mobile, server and desktop models to render images.
MIT License
4.25k stars 526 forks source link

[QUESTION] Alpha channel in jpeg files #1437

Open Drake53 opened 3 years ago

Drake53 commented 3 years ago

Hi, I am trying to open .blp files for a project I'm currently working on. This file type has multiple formats, one of which contains embedded jpg data. The problem I have is that this jpg data can have an alpha channel, but when I load the byte array using SkiaSharp, this information is lost. Instead of fully transparent white pixels, I'm getting opaque black pixels. I tried using different SKColorSpaces and setting SKImageInfo.AlphaType, but nothing seems to work. Am I missing something, or is this simply not supported at the moment? If it's not supported, I'd love to see this feature added.

In case you need it, I have some test files here: https://github.com/Drake53/War3Net/tree/master/tests/War3Net.Common.Testing/TestData/Blp The file "VillageFallStonePath" is the one with an alpha channel. The .blp file is the original, the .jpg I created by writing the byte array directly to a file, and the correct .png file I saved using a tool called BlpLab.

Related/additional reading: https://www.hiveworkshop.com/threads/the-evil-that-is-blp.269997/ https://www.hiveworkshop.com/threads/blp-specifications-wc3.279306/

mattleibow commented 3 years ago

Not gonna lie, that transparent jpeg threw me a bit. I didn't know that was even a thing.

This is a discussion for the native skia team: https://groups.google.com/g/skia-discuss