mirror of
https://invent.kde.org/frameworks/kimageformats.git
synced 2025-05-25 07:50:23 -04:00
Deal with different offsets in kra and ora
Because of a change in zip library, the location of the mimetype is different for different versions of krita.
This commit is contained in:
parent
56376ffd66
commit
b89c2d1b70
@ -18,6 +18,11 @@
|
||||
|
||||
static constexpr char s_magic[] = "application/x-krita";
|
||||
static constexpr int s_magic_size = sizeof(s_magic) - 1; // -1 to remove the last \0
|
||||
static constexpr int s_krita3_offset = 0x26;
|
||||
static constexpr int s_krita4_offset = 0x2B;
|
||||
static constexpr int s_krita4_64_offset = 0x40;
|
||||
static constexpr int s_krita5_offset = 0x26;
|
||||
static constexpr int s_krita5_64_offset = 0x3A;
|
||||
|
||||
KraHandler::KraHandler()
|
||||
{
|
||||
@ -58,10 +63,8 @@ bool KraHandler::canRead(QIODevice *device)
|
||||
return false;
|
||||
}
|
||||
|
||||
char buff[57];
|
||||
if (device->peek(buff, sizeof(buff)) == sizeof(buff)) {
|
||||
return memcmp(buff + 0x26, s_magic, s_magic_size) == 0;
|
||||
}
|
||||
ByteArray ba = device->peek(43 + s_magic_size);
|
||||
return (ba.contains(s_magic));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -17,6 +17,11 @@
|
||||
|
||||
static constexpr char s_magic[] = "image/openraster";
|
||||
static constexpr int s_magic_size = sizeof(s_magic) - 1; // -1 to remove the last \0
|
||||
static constexpr int s_krita3_offset = 0x26;
|
||||
static constexpr int s_krita4_offset = 0x2B;
|
||||
static constexpr int s_krita4_64_offset = 0x40;
|
||||
static constexpr int s_krita5_offset = 0x26;
|
||||
static constexpr int s_krita5_64_offset = 0x3A;
|
||||
|
||||
OraHandler::OraHandler()
|
||||
{
|
||||
@ -57,10 +62,11 @@ bool OraHandler::canRead(QIODevice *device)
|
||||
return false;
|
||||
}
|
||||
|
||||
char buff[54];
|
||||
if (device->peek(buff, sizeof(buff)) == sizeof(buff)) {
|
||||
return memcmp(buff + 0x26, s_magic, s_magic_size) == 0;
|
||||
}
|
||||
if (device->peek(s_krita3_offset + s_magic_size).contains(s_magic)) return true;
|
||||
if (device->peek(s_krita4_offset + s_magic_size).contains(s_magic)) return true;
|
||||
if (device->peek(s_krita4_64_offset + s_magic_size).contains(s_magic)) return true;
|
||||
if (device->peek(s_krita5_offset + s_magic_size).contains(s_magic)) return true;
|
||||
if (device->peek(s_krita5_64_offset + s_magic_size).contains(s_magic)) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user