public static DefineShape createShapeForImage(DefineBits tag, BitmapGraphicNode node)
{
double width = node.width;
double height = node.height;
boolean repeat = node.repeat;
FillMode fillMode = node.fillMode;
FXGVersion fileVersion = node.getFileVersion();
// Use default width/height information if none specified
if (Double.isNaN(width))
width = tag.width;
if (Double.isNaN(height))
height = tag.height;
// Create Fill Style
Matrix matrix = new Matrix();
matrix.scaleX = (int)(SwfConstants.TWIPS_PER_PIXEL * SwfConstants.FIXED_POINT_MULTIPLE);
matrix.scaleY = (int)(SwfConstants.TWIPS_PER_PIXEL * SwfConstants.FIXED_POINT_MULTIPLE);
matrix.hasScale = true; // Apply runtime scale of 20x for twips
FillStyle fs = null;
if (fileVersion.equalTo(FXGVersion.v1_0))
{
if (repeat)
fs = new FillStyle(FillStyle.FILL_BITS, matrix, tag);
else
fs = new FillStyle(FillStyle.FILL_BITS | FillStyle.FILL_BITS_CLIP, matrix, tag);
}
else
{
if (fillMode.equals(FillMode.REPEAT))
{
fs = new FillStyle(FillStyle.FILL_BITS, matrix, tag);
}
else if (fillMode.equals(FillMode.CLIP))
{
fs = new FillStyle(FillStyle.FILL_BITS | FillStyle.FILL_BITS_CLIP, matrix, tag);
}
else if (fillMode.equals(FillMode.SCALE))
{
//override the scale for matrix
matrix.scaleX = (int)StrictMath.rint((width*SwfConstants.TWIPS_PER_PIXEL * SwfConstants.FIXED_POINT_MULTIPLE)/(double)tag.width);
matrix.scaleY = (int)StrictMath.rint((height*SwfConstants.TWIPS_PER_PIXEL * SwfConstants.FIXED_POINT_MULTIPLE)/(double)tag.height);