コード例 #1
0
/* coverity[+alloc : arg-*6] */
GpStatus WINGDIPAPI
GdipCreateTexture2I (GpImage *image, GpWrapMode wrapMode, int x, int y, int width, int height, GpTexture **texture)
{
	int bmpWidth;
	int bmpHeight;
	GpStatus status;
	GpImage *resized_image = NULL;

	if (!image || !texture)
		return InvalidParameter;

	if (image->type != ImageTypeBitmap)
		return NotImplemented;

	bmpWidth = image->active_bitmap->width;
	bmpHeight = image->active_bitmap->height;

	/* MS behaves this way */
	if ((x < 0) || (y < 0) || (width <= 0) || (height <= 0) || (bmpWidth < (x + width)) || (bmpHeight < (y + height)))
		return OutOfMemory;

	status = GdipCloneBitmapAreaI (x, y, width, height, image->active_bitmap->pixel_format, image, &resized_image);
	if (status != Ok)
		return status;

	status = GdipCreateTexture (resized_image, wrapMode, texture);
	GdipDisposeImage (resized_image);
	return status;
}
コード例 #2
0
ファイル: texturebrush.c プロジェクト: mono/libgdiplus
/* coverity[+alloc : arg-*6] */
GpStatus WINGDIPAPI
GdipCreateTexture2I (GpImage *image, GpWrapMode wrapmode, INT x, INT y, INT width, INT height, GpTexture **texture)
{
	GpImage *textureImage;
	GpStatus status;

	if (!gdiplusInitialized)
		return GdiplusNotInitialized;

	if (!image || !texture)
		return InvalidParameter;

	if (wrapmode > WrapModeClamp) {
		*texture = NULL;
		return OutOfMemory;
	}

	switch (image->type) {
	case ImageTypeBitmap: {
		INT bmpWidth = image->active_bitmap->width;
		INT bmpHeight = image->active_bitmap->height;
		if ((x < 0) || (y < 0) || (width <= 0) || (height <= 0) || (bmpWidth < (x + width)) || (bmpHeight < (y + height))) {
			*texture = NULL;
			return OutOfMemory;
		}

		status = GdipCloneBitmapAreaI (x, y, width, height, image->active_bitmap->pixel_format, image, &textureImage);
		if (status != Ok)
			return status;
		break;
	}
	case ImageTypeMetafile:
		status = gdip_get_bitmap_from_metafile ((GpMetafile *) image, width, height, &textureImage);
		if (status != Ok)
			return status;
		break;
	default:
		return GenericError;
	}
	
	return gdip_texture_create_from_cloned_image (textureImage, wrapmode, texture);
}