gdiplus: Store an ImageAttributes in texture brushes.
This commit is contained in:
parent
8fdf64e882
commit
86d58dc6c8
|
@ -164,8 +164,14 @@ GpStatus WINGDIPAPI GdipCloneBrush(GpBrush *brush, GpBrush **clone)
|
||||||
GpStatus stat;
|
GpStatus stat;
|
||||||
GpTexture *texture = (GpTexture*)brush;
|
GpTexture *texture = (GpTexture*)brush;
|
||||||
GpTexture *new_texture;
|
GpTexture *new_texture;
|
||||||
|
UINT width, height;
|
||||||
|
|
||||||
stat = GdipCreateTexture(texture->image, texture->wrap, &new_texture);
|
stat = GdipGetImageWidth(texture->image, &width);
|
||||||
|
if (stat != Ok) return stat;
|
||||||
|
stat = GdipGetImageHeight(texture->image, &height);
|
||||||
|
if (stat != Ok) return stat;
|
||||||
|
|
||||||
|
stat = GdipCreateTextureIA(texture->image, texture->imageattributes, 0, 0, width, height, &new_texture);
|
||||||
|
|
||||||
if (stat == Ok)
|
if (stat == Ok)
|
||||||
{
|
{
|
||||||
|
@ -773,7 +779,7 @@ GpStatus WINGDIPAPI GdipCreateTexture(GpImage *image, GpWrapMode wrapmode,
|
||||||
GpTexture **texture)
|
GpTexture **texture)
|
||||||
{
|
{
|
||||||
UINT width, height;
|
UINT width, height;
|
||||||
GpImageAttributes attributes;
|
GpImageAttributes *attributes;
|
||||||
GpStatus stat;
|
GpStatus stat;
|
||||||
|
|
||||||
TRACE("%p, %d %p\n", image, wrapmode, texture);
|
TRACE("%p, %d %p\n", image, wrapmode, texture);
|
||||||
|
@ -785,10 +791,20 @@ GpStatus WINGDIPAPI GdipCreateTexture(GpImage *image, GpWrapMode wrapmode,
|
||||||
if (stat != Ok) return stat;
|
if (stat != Ok) return stat;
|
||||||
stat = GdipGetImageHeight(image, &height);
|
stat = GdipGetImageHeight(image, &height);
|
||||||
if (stat != Ok) return stat;
|
if (stat != Ok) return stat;
|
||||||
attributes.wrap = wrapmode;
|
|
||||||
|
|
||||||
return GdipCreateTextureIA(image, &attributes, 0, 0, width, height,
|
stat = GdipCreateImageAttributes(&attributes);
|
||||||
|
|
||||||
|
if (stat == Ok)
|
||||||
|
{
|
||||||
|
attributes->wrap = wrapmode;
|
||||||
|
|
||||||
|
stat = GdipCreateTextureIA(image, attributes, 0, 0, width, height,
|
||||||
texture);
|
texture);
|
||||||
|
|
||||||
|
GdipDisposeImageAttributes(attributes);
|
||||||
|
}
|
||||||
|
|
||||||
|
return stat;
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
|
@ -797,14 +813,25 @@ GpStatus WINGDIPAPI GdipCreateTexture(GpImage *image, GpWrapMode wrapmode,
|
||||||
GpStatus WINGDIPAPI GdipCreateTexture2(GpImage *image, GpWrapMode wrapmode,
|
GpStatus WINGDIPAPI GdipCreateTexture2(GpImage *image, GpWrapMode wrapmode,
|
||||||
REAL x, REAL y, REAL width, REAL height, GpTexture **texture)
|
REAL x, REAL y, REAL width, REAL height, GpTexture **texture)
|
||||||
{
|
{
|
||||||
GpImageAttributes attributes;
|
GpImageAttributes *attributes;
|
||||||
|
GpStatus stat;
|
||||||
|
|
||||||
TRACE("%p %d %f %f %f %f %p\n", image, wrapmode,
|
TRACE("%p %d %f %f %f %f %p\n", image, wrapmode,
|
||||||
x, y, width, height, texture);
|
x, y, width, height, texture);
|
||||||
|
|
||||||
attributes.wrap = wrapmode;
|
stat = GdipCreateImageAttributes(&attributes);
|
||||||
return GdipCreateTextureIA(image, &attributes, x, y, width, height,
|
|
||||||
|
if (stat == Ok)
|
||||||
|
{
|
||||||
|
attributes->wrap = wrapmode;
|
||||||
|
|
||||||
|
stat = GdipCreateTextureIA(image, attributes, x, y, width, height,
|
||||||
texture);
|
texture);
|
||||||
|
|
||||||
|
GdipDisposeImageAttributes(attributes);
|
||||||
|
}
|
||||||
|
|
||||||
|
return stat;
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
|
@ -854,16 +881,25 @@ GpStatus WINGDIPAPI GdipCreateTextureIA(GpImage *image,
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (imageattr)
|
||||||
|
{
|
||||||
|
status = GdipCloneImageAttributes(imageattr, &(*texture)->imageattributes);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
status = GdipCreateImageAttributes(&(*texture)->imageattributes);
|
||||||
|
if (status == Ok)
|
||||||
|
(*texture)->imageattributes->wrap = WrapModeTile;
|
||||||
|
}
|
||||||
|
if (status != Ok)
|
||||||
|
goto exit;
|
||||||
|
|
||||||
(*texture)->brush.lb.lbStyle = BS_PATTERN;
|
(*texture)->brush.lb.lbStyle = BS_PATTERN;
|
||||||
(*texture)->brush.lb.lbColor = 0;
|
(*texture)->brush.lb.lbColor = 0;
|
||||||
(*texture)->brush.lb.lbHatch = (ULONG_PTR)hbm;
|
(*texture)->brush.lb.lbHatch = (ULONG_PTR)hbm;
|
||||||
|
|
||||||
(*texture)->brush.gdibrush = CreateBrushIndirect(&(*texture)->brush.lb);
|
(*texture)->brush.gdibrush = CreateBrushIndirect(&(*texture)->brush.lb);
|
||||||
(*texture)->brush.bt = BrushTypeTextureFill;
|
(*texture)->brush.bt = BrushTypeTextureFill;
|
||||||
if (imageattr)
|
|
||||||
(*texture)->wrap = imageattr->wrap;
|
|
||||||
else
|
|
||||||
(*texture)->wrap = WrapModeTile;
|
|
||||||
(*texture)->image = new_image;
|
(*texture)->image = new_image;
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
|
@ -876,6 +912,7 @@ exit:
|
||||||
if (*texture)
|
if (*texture)
|
||||||
{
|
{
|
||||||
GdipDeleteMatrix((*texture)->transform);
|
GdipDeleteMatrix((*texture)->transform);
|
||||||
|
GdipDisposeImageAttributes((*texture)->imageattributes);
|
||||||
GdipFree(*texture);
|
GdipFree(*texture);
|
||||||
*texture = NULL;
|
*texture = NULL;
|
||||||
}
|
}
|
||||||
|
@ -984,6 +1021,7 @@ GpStatus WINGDIPAPI GdipDeleteBrush(GpBrush *brush)
|
||||||
case BrushTypeTextureFill:
|
case BrushTypeTextureFill:
|
||||||
GdipDeleteMatrix(((GpTexture*)brush)->transform);
|
GdipDeleteMatrix(((GpTexture*)brush)->transform);
|
||||||
GdipDisposeImage(((GpTexture*)brush)->image);
|
GdipDisposeImage(((GpTexture*)brush)->image);
|
||||||
|
GdipDisposeImageAttributes(((GpTexture*)brush)->imageattributes);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -1277,7 +1315,7 @@ GpStatus WINGDIPAPI GdipGetTextureWrapMode(GpTexture *brush, GpWrapMode *wrapmod
|
||||||
if(!brush || !wrapmode)
|
if(!brush || !wrapmode)
|
||||||
return InvalidParameter;
|
return InvalidParameter;
|
||||||
|
|
||||||
*wrapmode = brush->wrap;
|
*wrapmode = brush->imageattributes->wrap;
|
||||||
|
|
||||||
return Ok;
|
return Ok;
|
||||||
}
|
}
|
||||||
|
@ -1757,7 +1795,7 @@ GpStatus WINGDIPAPI GdipSetTextureWrapMode(GpTexture *brush, GpWrapMode wrapmode
|
||||||
if(!brush)
|
if(!brush)
|
||||||
return InvalidParameter;
|
return InvalidParameter;
|
||||||
|
|
||||||
brush->wrap = wrapmode;
|
brush->imageattributes->wrap = wrapmode;
|
||||||
|
|
||||||
return Ok;
|
return Ok;
|
||||||
}
|
}
|
||||||
|
|
|
@ -215,7 +215,7 @@ struct GpTexture{
|
||||||
GpBrush brush;
|
GpBrush brush;
|
||||||
GpMatrix *transform;
|
GpMatrix *transform;
|
||||||
GpImage *image;
|
GpImage *image;
|
||||||
WrapMode wrap; /* not used yet */
|
GpImageAttributes *imageattributes;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GpPath{
|
struct GpPath{
|
||||||
|
|
Loading…
Reference in New Issue