AngusJohnson / TQoiImage

Delphi TGraphic support for QOI images
MIT License
35 stars 15 forks source link

Cross platform #4

Closed dbyoung720 closed 2 years ago

dbyoung720 commented 2 years ago

Qoi encoding and decoding itself can be cross platform. If you package it like this, it can only be used under windows. It is recommended that qoi encoding and decoding be independent and cross platform. Then write VCL / FMX package.

AngusJohnson commented 2 years ago

Hi again. Given the design of VCL.Graphics and FMX.Graphics, I can't see an easy way to support both frameworks. I could separate out the existing QOI streaming class methods into non-class functions (which I've already been considering). But I don't have any idea on how to add new image formats to the FMX framework. Can you offer any suggestions there?

dbyoung720 commented 2 years ago

I 'm sorry. I don't know.

dbyoung720 commented 2 years ago

I refined the codec based on your code, Make it cross platform. The next step is to parallelize it.

db.QOI.zip

AngusJohnson commented 2 years ago

Hi again and thanks for the code. However I believe it'll be much slower that my current code. Using generic functions like your qoi_encode_pascal and qoi_decode_pascal above that are blind to the internal layout of TBitmap will require copying images more than once and will also requre inverting the loaded or saved images.

dbyoung720 commented 2 years ago

Look at my test code, which is a little faster than yours code.

https://github.com/dbyoung720/TestQOI.git

AngusJohnson commented 2 years ago

Look at my test code, which is a little faster than yours code.

It's only a little faster because you've excluded allocating memory and GetBitmapBits / SetBitmapBits from the timing of your code and also, your encoding / decoding bypasses the TBitmap inverted image issue. By loading the inverted image from memory and reading this inverted image back again everything looks fine. But I believe if you read and write to a properly formatted QOI file you'll need to modify your algorithm.

Edit: I've just tested the streaming to file with your code and I was wrong about the image being stored inverted. However the Red and Blue colour channels still need to be swapped (and the incorrectly stored image width and height also needs fixing).