Пример #1
0
/* Partitions the given character sequence into one or more unidirectional
 * fragments and invokes the given callback function for each fragment.
 */
void fz_bidi_fragment_text(fz_context *ctx,
		const uint32_t *text,
		size_t textlen,
		fz_bidi_direction *baseDir,
		fz_bidi_fragment_callback *callback,
		void *arg,
		int flags)
{
	size_t startOfFragment;
	size_t i;
	fz_bidi_level *levels;

	if (text == NULL || callback == NULL || textlen == 0)
		return;

	DBUGH(("fz_bidi_fragment_text('%S', len = %d)\n", text, textlen));

	levels = create_levels(ctx, text, textlen, baseDir, FALSE, flags);

	/* We now have an array with an embedding level
	 * for each character in text.
	 */
	assert(levels != NULL);

	fz_try(ctx)
	{
		startOfFragment = 0;
		for (i = 1; i < textlen; i++)
		{
			if (levels[i] != levels[i-1])
			{
				/* We've gone past the end of the fragment.
				 * Create a text object for it, then start
				 * a new fragment.
				 */
				split_at_script(&text[startOfFragment],
						i - startOfFragment,
						levels[startOfFragment],
						arg,
						callback);
				startOfFragment = i;
			}
		}
		/* Now i == textlen. Deal with the final (or maybe only) fragment. */
		/* otherwise create 1 fragment */
		split_at_script(&text[startOfFragment],
				i - startOfFragment,
				levels[startOfFragment],
				arg,
				callback);
	}
	fz_always(ctx)
	{
		fz_free(ctx, levels);
	}
	fz_catch(ctx)
	{
		fz_rethrow(ctx);
	}
}
Пример #2
0
int main(int argc, char **argv)
{
	ExceptionInfo exception;
	ImageInfo *image_info;
	Image *image;
	char *ext;
	char image_name[NAME_MAX + 1];
	char deepzoom_directory[NAME_MAX + 1];
	char dzi[NAME_MAX];
	int opt;

	while ((opt = getopt(argc, argv, "t:o:h")) != -1) {
		switch (opt) {
		case 't':
			tile_sz = atoi(optarg);
			break;
		case 'o':
			overlap = atoi(optarg);
			break;
		case 'h':
			print_usage();
			exit(EXIT_SUCCESS);
		}
	}

	if (optind < argc) {
		snprintf(image_name, sizeof(image_name), "%s", argv[optind]);
	} else {
		print_usage();
		exit(EXIT_FAILURE);
	}

	InitializeMagick(NULL);
	GetExceptionInfo(&exception);
	image_info = CloneImageInfo((ImageInfo *)NULL);
	snprintf(image_info->filename, sizeof(image_info->filename), "%s",
		image_name);
	image = ReadImage(image_info, &exception);
	if (exception.severity != UndefinedException)
		CatchImageException(image);

	ext = rindex(image_name, '.');
	snprintf(deepzoom_directory, strlen(image_name) - strlen(ext) + 1,
		"%s", image_name);
	strcpy(dzi, deepzoom_directory);
	strncat(deepzoom_directory, "_files",
		NAME_MAX - strlen(deepzoom_directory));
	printf("Creating directory: %s\n", deepzoom_directory);
	mkdir(deepzoom_directory, 0777);
	chdir(deepzoom_directory);
	create_levels(image, ext + 1, image->columns, image->rows);
	chdir("..");

	strncat(dzi, ".dzi", NAME_MAX - strlen(dzi));
	printf("Writing DZI: %s\n", dzi);
	write_dzi(dzi, ext + 1, image->columns, image->rows);

	DestroyImage(image);
	DestroyImageInfo(image_info);
	DestroyExceptionInfo(&exception);
	DestroyMagick();

	exit(EXIT_SUCCESS);
}
Пример #3
0
inline void MultiGrid::level_required(int lvl)
{
	if(m_hierarchy.num_subsets() <= lvl){
		create_levels(lvl - m_hierarchy.num_subsets() + 1);
	}
}