コード例 #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;
}
コード例 #2
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;
}