Helper to make NinePatchMirage around a box
git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@883 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
@@ -22,6 +22,7 @@ package com.threerings.media.image;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.geom.AffineTransform;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
/**
|
||||
@@ -46,6 +47,19 @@ public class NinePatchMirage
|
||||
_height = height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new Mirage that's a NinePatch stretched and positioned to contain the given
|
||||
* Rectangle.
|
||||
*/
|
||||
public static Mirage newNinePatchContaining(NinePatch ninePatch, Rectangle content)
|
||||
{
|
||||
Rectangle bounds = ninePatch.getBoundsSurrounding(content);
|
||||
|
||||
Mirage mirage = new NinePatchMirage(ninePatch, bounds.width, bounds.height);
|
||||
return new TransformedMirage(mirage,
|
||||
AffineTransform.getTranslateInstance(bounds.x, bounds.y), false);
|
||||
}
|
||||
|
||||
public long getEstimatedMemoryUsage ()
|
||||
{
|
||||
return ImageUtil.getEstimatedMemoryUsage(_ninePatch._img.getRaster());
|
||||
|
||||
Reference in New Issue
Block a user