0xC0000054 / pdn-heicfiletype-plus

A Paint.NET filetype plugin that allows HEIC images to be loaded and saved with transparency.
https://forums.getpaint.net/topic/116873-heic-filetype-plus/
GNU General Public License v3.0
38 stars 1 forks source link

The plugin works well in paint.net, but I tried in my app and got InvalidFile #2

Closed sati32 closed 2 years ago

sati32 commented 2 years ago

I tried this:

    HEIFInterface           heifInterface;

    if (heifInterface.isValid())
    {
        heif_context    *context;

        context = heifInterface.createContext();

        if (context)
        {
            IOCallbacks fileIO;
            Status      stat;

            _myFile = file;
            fileIO.GetPosition = MyGetPosition;
            fileIO.GetSize = MyGetSize;
            fileIO.Read = MyRead;
            fileIO.Seek = MySeek;
            fileIO.Write = MyWrite;

            stat = heifInterface.loadFileIntoContext(context, &fileIO);

but stat gives always an InvalidFile. Do you know why?

0xC0000054 commented 2 years ago

My only guess is that you may need to seek to the beginning of the file before calling loadFileIntoContext.

sati32 commented 2 years ago

Thank you for your help. But this is not the solution. My file callbacks are called GetPosition and returns 0, GetSize and Read (4 Bytes and gives the first 4 Bytes of the file). I will try to check the source of LibHeic.

sati32 commented 2 years ago

OK, the problem was my Read-Callback function. It has to return "0" for no error, not the amount of bytes read, as expected.

sati32 commented 2 years ago

Works fine now. May I ask if there is a way to get 16 bit per channel instead of 8? Is there a way to get data without alpha or is there a way to detect if alpha is present?

0xC0000054 commented 2 years ago

You would have to modify the C++ wrapper code to add those features.

Paint.NET uses 8-bit RGBA as its native image format, so the C++ wrapper code used by this plugin only supports that format. There was no point in adding features to the wrapper that Paint.NET does not support.