BitmapSource GetBitmapGfx(BitmapGfx gfx, int size)
{
int xoff;
int tileSize = 0;
for (int i = 0; i < m_bitmapSizes.Length; ++i)
{
if (size <= m_bitmapSizes[i])
{
tileSize = m_bitmapSizes[i];
break;
}
}
if (tileSize == 0)
tileSize = m_bitmapSizes.Max();
xoff = 1;
for (int i = 0; i < m_bitmapSizes.Length; ++i)
{
if (tileSize == m_bitmapSizes[i])
break;
xoff += m_bitmapSizes[i] + 3;
}
BitmapSource bmp = new CroppedBitmap(m_bitmap, new Int32Rect(xoff, 1 + 35 * gfx.BitmapIndex, tileSize, tileSize));
if (size != tileSize)
{
double scale = (double)size / tileSize;
bmp = new TransformedBitmap(bmp, new ScaleTransform(scale, scale));
}
return bmp;
}