fix utf-16 reading and make it work on android

This commit is contained in:
2019-02-10 20:55:26 +01:00
parent 1d6c26f2ba
commit 6e41263600
9 changed files with 95 additions and 26 deletions

View File

@@ -1,5 +1,6 @@
#include "pch.h"
#include "abr.h"
#include "log.h"
bool ABR::section_desc()
{
@@ -20,7 +21,11 @@ bool ABR::section_desc()
m_presets.push_back(desc);
}
auto out = presets->str(0, "");
std::cout << out << '\n';
auto lines = split(out, '\n');
for (const auto& l : lines)
{
LOG("%s", l.c_str());
}
}
return true;
}
@@ -63,7 +68,7 @@ bool ABR::section_patt()
auto image_mode = ru32();
if (!(image_mode == 1 || image_mode == 3))
{
printf("PATT: skip image mode %d\n", image_mode);
LOG("PATT: skip image mode %d\n", image_mode);
skip(patt_length - 8);
snap();
continue;
@@ -83,7 +88,7 @@ bool ABR::section_patt()
int nc = std::min((int)vm->channels.size(), 3);
if (nc != image_mode)
{
printf("PATT: image_mode (%d) and number of channels (%d) not matching\n",
LOG("PATT: image_mode (%d) and number of channels (%d) not matching\n",
image_mode, vm->channels.size());
}
if (auto img = vm->image(true))
@@ -135,12 +140,13 @@ std::vector<std::shared_ptr<Brush>> ABR::compute_brushes(const std::string& path
//b->m_blend_mode = i.m_blend_mode;
//b->m_name.resize(i.m_name_len);
//b->m_stencil_path.resize(i.m_stencil_path_len);
auto& tip_uid = wstr2str(samp->value<String>("sampledData"));
auto tip_uid = wstr2str(samp->value<String>("sampledData"));
LOG("tip uid %d %s", tip_uid.size(), tip_uid.c_str());
b->m_brush_path = path + "/brushes/" + tip_uid + ".png";
b->m_brush_thumb_path = path + "/brushes/thumbs/" + tip_uid + ".png";
if (auto patt = p->get<Descriptor>("Txtr"))
{
auto& patt_uid = wstr2str(patt->value<String>("Idnt"));
auto patt_uid = wstr2str(patt->value<String>("Idnt"));
b->m_stencil_path = path + "/patterns/" + patt_uid + ".png";
//b->m_brush_thumb_path = path + "/patterns/thumbs/" + patt_uid + ".png";
b->m_tip_stencil = p->value<UnitFloat>("textureDepth") * 0.01f;
@@ -179,7 +185,7 @@ std::shared_ptr<ABR::VMArray> ABR::parse_vmem()
auto compression = ru8(); // 1 = zip
if (depth != 8)
{
printf("unsupported depth %d bits\n", depth);
LOG("unsupported depth %d bits\n", depth);
skip(length - 23);
continue;
}
@@ -208,7 +214,7 @@ std::shared_ptr<ABR::VMArray> ABR::parse_vmem()
}
else
{
printf("unsupported compression mode %d\n", compression);
LOG("unsupported compression mode %d\n", compression);
skip(length - 23);
continue;
}
@@ -257,7 +263,7 @@ std::shared_ptr<ABR::Descriptor> ABR::parse_objc()
if (!property)
return nullptr;
if (ret->props.find(key) != ret->props.end())
printf("DUPLICATE prop %d\n", key.c_str());
LOG("DUPLICATE prop %d\n", key.c_str());
ret->props[key] = property;
}
return ret;
@@ -336,7 +342,7 @@ bool ABR::open(const std::string& path)
init(asset.read_all(), asset.m_len, BinaryStream::ByteOrder::BigEndian);
auto version_major = ru16();
auto version_minor = ru16();
printf("ABR %d.%d\n", version_major, version_minor);
LOG("ABR %d.%d\n", version_major, version_minor);
while (!eof())
{
if (rstring(4) != "8BIM")
@@ -356,7 +362,7 @@ bool ABR::open(const std::string& path)
}
else
{
printf("skip section %s\n", t.c_str());
LOG("skip section %s\n", t.c_str());
skip(align4(ru32()));
}
}