Skip to content

Commit

Permalink
Merge branch 'openslide:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
josiah-lunit authored Sep 11, 2023
2 parents 8e07e46 + cba7702 commit c6c9682
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 0 deletions.
18 changes: 18 additions & 0 deletions misc/imhex/hamamatsu-vms-opt.hexpat
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#pragma description Hamamatsu VMS .opt files

#include <std/core.pat>
#include <std/io.pat>
#include <std/mem.pat>

#pragma endian little

struct Optimisation {
u32 offset;
padding[36];
} [[format_read("read_optimisation")]];

fn read_optimisation(Optimisation v) {
return std::format("{} (0x{:08X})", v.offset, v.offset);
};

Optimisation optimisations[while(!std::mem::eof())] @ 0;
73 changes: 73 additions & 0 deletions misc/imhex/mirax-index.hexpat
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#pragma description MIRAX Index.dat

#include <std/io.pat>
#include <std/mem.pat>

#pragma endian little
#pragma eval_depth 1024

// configured by the user in the Settings tab.
// only the Slidedat knows how many records we have.
u32 hier_record_count in;
u32 nonhier_record_count in;

struct HierEntry {
u32 image;
u32 offset;
u32 length;
u32 file;
} [[format_read("format_hier_entry"), static]];

fn format_hier_entry(HierEntry e) {
return std::format("[{}. {}, {}, {}]", e.image, e.offset, e.length, e.file);
};

struct NonHierEntry {
u32 padding1;
u32 padding2;
u32 offset;
u32 length;
u32 file;
} [[format_read("format_nonhier_entry"), static]];

fn format_nonhier_entry(NonHierEntry e) {
return std::format("[{}, {}, {}]", e.offset, e.length, e.file);
};

u32 cur_page = 0;
struct Page<Entry> {
u32 page_num = cur_page;
u32 count;
u32 next;
Entry entries[count];
} [[format_read("format_page"), name(std::format("[{}]", page_num))]];

fn format_page(auto p) {
return std::format("[{} entries]", p.count);
};

struct Pages<Entry> {
Page<Entry> page;
if (page.next != 0) {
cur_page = cur_page + 1;
Pages<Entry> next_page @ page.next [[inline]];
}
} [[inline]];

struct Record<Entry> {
if (std::mem::read_unsigned($, 4) != 0) {
cur_page = 0;
Pages<Entry> *pages : u32;
} else {
padding[4];
}
};

struct File {
char version[5];
char slide_id[32];
Record<HierEntry> *hier_records[hier_record_count] : u32;
Record<NonHierEntry> *nonhier_records[nonhier_record_count] : u32;
} [[inline]];

File file @ 0;
32 changes: 32 additions & 0 deletions misc/imhex/mirax-position.hexpat
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#pragma description MIRAX VIMSLIDE_POSITION_BUFFER non-hierarchical section

// TODO: support StitchingIntensityLevel, automatically inflating with
// https://github.com/Jusb3/ImHex-Zlib-Plugin

#include <std/io.pat>
#include <std/mem.pat>

#pragma endian little

struct Position {
u8 flags;
s32 x;
s32 y;
} [[format_read("format_position"), static]];

fn format_position(Position p) {
if (p.x == 0 && p.y == 0 && p.flags == 0) {
return "-0-";
}
return std::format("({}, {}) [{:x}]", p.x, p.y, p.flags);
};

struct File {
char version[5];
char slide_id[32];
char file[3];
padding[256];
Position positions[while(!std::mem::eof())];
} [[inline]];

File file @ 0;

0 comments on commit c6c9682

Please sign in to comment.