This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Reading .kra layer file

Tags: None
(comma "," separated)
Robin Theilade
Registered Member
Posts
2
Karma
0

Reading .kra layer file

Sun Sep 04, 2022 8:07 pm
I'm writing a program to export .kra file to the game I'm creating. Right now I'm able to convert most of the layer file, except for two tiles.

For each tile in the layer file I read the amount of bytes specified into one array and defines an output array of size tilewidth * tileheight * pixelsize + 1.

To decompress the bytes I use the lzff_decompress function found in this file
https://invent.kde.org/graphics/krita/- ... n.cpp#L173

After decompression I also delinearize the colors.

As mentioned there are two of the tiles in the layer I'm testing that does not export correctly. They both fail to decompress at this if-statement:
https://invent.kde.org/graphics/krita/- ... n.cpp#L223

Krita 5.0.8 opens and displays the .kra file just fine.

As I have not touched C++ since 1999 and currently working in C# I don't really know how to start Krita from an IDE to compare function parameters and otherwise step in the original code. I did however manage to compile the decompression function as a shared library and call that from C# so I'm quite sure the bug is not to be found there.

Does anyone know if my way to calculate output array size is correct or if there is some edge cases on how to read some of the tiles that I need to be aware of?

Last edited by Robin Theilade on Tue Sep 06, 2022 6:57 pm, edited 1 time in total.
Robin Theilade
Registered Member
Posts
2
Karma
0

Re: Reading .kra layer file  Topic is solved

Mon Sep 05, 2022 7:44 pm
I missed this if-statement check which also explains why I was reserving one more byte for the output array that I thought was logical
https://invent.kde.org/graphics/krita/- ... 2.cpp#L144

Now "everything" works!


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Google [Bot], Sogou [Bot], Yahoo [Bot]