예제 #1
0
파일: rdtk_font.c 프로젝트: BUGgs/FreeRDP
rdtkFont* rdtk_embedded_font_new(rdtkEngine* engine, BYTE* imageData, int imageSize, BYTE* descriptorData, int descriptorSize)
{
	int size;
	int status;
	BYTE* buffer;
	rdtkFont* font;

	font = (rdtkFont*) calloc(1, sizeof(rdtkFont));

	if (!font)
		return NULL;

	font->engine = engine;

	font->image = winpr_image_new();

	if (!font->image)
	{
		free(font);
		return NULL;
	}

	status = winpr_image_read_buffer(font->image, imageData, imageSize);

	if (status < 0)
	{
		winpr_image_free(font->image, TRUE);
		free(font);
		return NULL;
	}

	size = descriptorSize;
	buffer = (BYTE*) malloc(size);

	if (!buffer)
	{
		winpr_image_free(font->image, TRUE);
		free(font);
		return NULL;
	}

	CopyMemory(buffer, descriptorData, size);

	status = rdtk_font_parse_descriptor_buffer(font, buffer, size);

	free(buffer);

	return font;
}
BYTE* test_progressive_load_bitmap(char* path, char* file, UINT32* size, int quarter)
{
	int status;
	BYTE* buffer;
	wImage* image;
	char* filename;

	filename = GetCombinedPath(path, file);

	if (!filename)
		return NULL;

	image = winpr_image_new();

	if (!image)
		return NULL;

	status = winpr_image_read(image, filename);

	if (status < 0)
		return NULL;

	buffer = image->data;
	*size = image->height * image->scanline;

	test_fill_image_alpha_channel(image->data, image->width, image->height, 0xFF);
	test_image_fill_unused_quarters(image->data, image->scanline, image->width, image->height, quarter, 0xFF000000);

	winpr_image_free(image, FALSE);
	free(filename);

	return buffer;
}
예제 #3
0
파일: TestImage.c 프로젝트: abma/FreeRDP
static wImage *get_image(const char *src)
{
	int status;
	wImage* image = NULL;

	image = winpr_image_new();

	if (!image)
	{
		fprintf(stderr, "Failed to create image!");
		goto cleanup;
	}

	status = winpr_image_read(image, src);

	if (status < 0)
	{
		fprintf(stderr, "Failed to read image %s!", src);
		winpr_image_free(image, TRUE);
		image = NULL;
	}

cleanup:

	return image;
}
예제 #4
0
파일: TestImage.c 프로젝트: FreeRDP/FreeRDP
static int create_test(const char* src, const char* dst_png, const char* dst_bmp)
{
	int rc = -1;
	int ret = -1;
	int status;
	size_t bsize;
	void* buffer = NULL;
	wImage* image = NULL, *image2 = NULL, *image3 = NULL, *image4 = NULL;

	if (!PathFileExistsA(src))
	{
		fprintf(stderr, "File %s does not exist!", src);
		return -1;
	}

	image = get_image(src);

	/* Read from file using image methods. */
	if (!image)
		goto cleanup;

	/* Write different formats to tmp. */
	image->type = WINPR_IMAGE_BITMAP;
	status = winpr_image_write(image, dst_bmp);

	if (status < 0)
	{
		fprintf(stderr, "Failed to write image %s!\n", dst_bmp);
		goto cleanup;
	}

	image->type = WINPR_IMAGE_PNG;
	status = winpr_image_write(image, dst_png);

	if (status < 0)
	{
		fprintf(stderr, "Failed to write image %s!\n", dst_png);
		goto cleanup;
	}

	/* Read image from buffer, compare. */
	buffer = read_image(src, &bsize);

	if (!buffer)
	{
		fprintf(stderr, "Failed to read image %s!\n", src);
		goto cleanup;
	}

	image2 = winpr_image_new();

	if (!image2)
	{
		fprintf(stderr, "Failed to create image!\n");
		goto cleanup;
	}

	status = winpr_image_read_buffer(image2, buffer, bsize);

	if (status < 0)
	{
		fprintf(stderr, "Failed to read buffer!\n");
		goto cleanup;
	}

	rc = img_compare(image, image2, TRUE);

	if (rc)
		goto cleanup;

	image3 = get_image(dst_png);

	if (!image3)
		goto cleanup;

	rc = img_compare(image, image3, TRUE);

	if (rc)
		goto cleanup;

	image4 = get_image(dst_bmp);

	if (!image4)
		goto cleanup;

	rc = img_compare(image, image4, TRUE);

	if (rc)
		goto cleanup;

	ret = 0;
cleanup:

	if (image)
		winpr_image_free(image, TRUE);

	if (image2)
		winpr_image_free(image2, TRUE);

	if (image3)
		winpr_image_free(image3, TRUE);

	if (image4)
		winpr_image_free(image4, TRUE);

	free(buffer);
	return ret;
}
예제 #5
0
파일: rdtk_font.c 프로젝트: BUGgs/FreeRDP
rdtkFont* rdtk_font_new(rdtkEngine* engine, const char* path, const char* file)
{
	int status;
	int length;
	rdtkFont* font = NULL;
	char* fontBaseFile = NULL;
	char* fontImageFile = NULL;
	char* fontDescriptorFile = NULL;

	fontBaseFile = GetCombinedPath(path, file);

	if (!fontBaseFile)
		goto cleanup;

	length = strlen(fontBaseFile);

	fontImageFile = (char*) malloc(length + 8);

	if (!fontImageFile)
		goto cleanup;

	strcpy(fontImageFile, fontBaseFile);
	strcpy(&fontImageFile[length], ".png");

	fontDescriptorFile = (char*) malloc(length + 8);

	if (!fontDescriptorFile)
		goto cleanup;

	strcpy(fontDescriptorFile, fontBaseFile);
	strcpy(&fontDescriptorFile[length], ".xml");

	free(fontBaseFile);

	if (!PathFileExistsA(fontImageFile))
		goto cleanup;

	if (!PathFileExistsA(fontDescriptorFile))
		goto cleanup;

	font = (rdtkFont*) calloc(1, sizeof(rdtkFont));

	if (!font)
		goto cleanup;

	font->engine = engine;

	font->image = winpr_image_new();

	if (!font->image)
		goto cleanup;

	status = winpr_image_read(font->image, fontImageFile);

	if (status < 0)
		goto cleanup;

	status = rdtk_font_load_descriptor(font, fontDescriptorFile);

	free(fontImageFile);
	free(fontDescriptorFile);

	return font;

cleanup:
	free(fontImageFile);
	free(fontDescriptorFile);
	if (font)
	{
		if (font->image)
			winpr_image_free(font->image, TRUE);
		free (font);
	}

	return NULL;
}