Add libisyntax_get_data_model_major_version#55
Merged
Conversation
Member
|
Should we also expose the minor version? This could also be relevant because some files have "100.4" instead of "100.5" (also see this issue). |
Contributor
Author
|
Good idea, updated with a Here is a test util that is helpful to verify this. #include <libisyntax.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/*
Print a formatted error and exit.
*/
#define ERR_EXIT(...) \
do { \
fprintf(stderr, __VA_ARGS__); \
fprintf(stderr, "\n"); \
goto cleanup; \
} while (0)
int main(int argc, char **argv) {
// Set line buffering mode on stdout/stderr.
setvbuf(stdout, NULL, _IOLBF, 0);
setvbuf(stderr, NULL, _IOLBF, 0);
isyntax_t *isyntax = NULL;
int exit_status = EXIT_FAILURE;
if (argc != 2)
ERR_EXIT("Incorrect number of arguments: got %d, want 1", argc - 1);
if (libisyntax_init() != LIBISYNTAX_OK)
ERR_EXIT("Failed to initialize libisyntax");
if (libisyntax_open(argv[1], 0, &isyntax) != LIBISYNTAX_OK)
ERR_EXIT("Failed to open file: %s", argv[1]);
char *filename = strrchr(argv[1], '/');
if (!filename)
filename = argv[1];
else
filename++;
isyntax_image_t const *image = libisyntax_get_wsi_image(isyntax);
int32_t num_levels = libisyntax_image_get_level_count(image);
isyntax_level_t const *level0 = NULL;
level0 = libisyntax_image_get_level(image, 0);
if (!level0)
ERR_EXIT("Failed to get the first level in the image");
int32_t width = libisyntax_level_get_width(level0);
int32_t height = libisyntax_level_get_height(level0);
int32_t tile_width = libisyntax_get_tile_width(isyntax);
int32_t tile_height = libisyntax_get_tile_height(isyntax);
const char *manufacturer = libisyntax_get_manufacturer(isyntax);
const char *model = libisyntax_get_manufacturers_model_name(isyntax);
const char *serial = libisyntax_get_device_serial_number(isyntax);
bool mpp_is_known = libisyntax_get_is_mpp_known(isyntax);
double mppx = 0.0;
double mppy = 0.0;
if (mpp_is_known) {
mppx = libisyntax_level_get_mpp_x(level0);
mppy = libisyntax_level_get_mpp_y(level0);
}
const char *software_version;
if (libisyntax_get_software_versions_count(isyntax) > 0) {
software_version = libisyntax_get_software_versions(isyntax, 0);
} else {
software_version = "unknown";
}
printf("%s\n| %dx%d\n| %d levels\n", filename, width, height, num_levels);
printf("| %dx%d tiles\n", tile_width, tile_height);
if (mpp_is_known)
printf("| x %.3f mpp, y %.3f mpp\n", mppx, mppy);
printf("| software version %s\n", software_version);
printf("| data model version: %d.%d\n",
libisyntax_get_data_model_major_version(isyntax),
libisyntax_get_data_model_minor_version(isyntax));
if (strlen(manufacturer) > 0)
printf("| %s %s %s\n", manufacturer, model, serial);
else
printf("| Unknown Scanner\n");
printf("| Levels:\n");
for (int32_t i = 0; i < num_levels; i++) {
const isyntax_level_t *_level = libisyntax_image_get_level(image, i);
int32_t _lvlw = libisyntax_level_get_width(_level);
int32_t _lvlh = libisyntax_level_get_height(_level);
double _scale = libisyntax_level_get_downsample_factor(_level);
printf("|_ Level %d: %dx%d (%f)\n", i, _lvlw, _lvlh, _scale);
}
exit_status = EXIT_SUCCESS;
cleanup:
if (isyntax != NULL)
libisyntax_close(isyntax);
return exit_status;
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This value is useful for identifying the isyntax file format version. Use case for exposing this value in the API would be to validate and reject invalid/unexpected formats when reading the image.