private void CreateTileData()
        {
            if( textureName.Equals( "zero.png" ) )
            {
                textureName = string.Format( "{0}_x{1}y{2}.{3}", parent.BaseName, m_tileLocationX, m_loadTileZ,
                                             parent.MosaicDesc.FileExt );

            }

            Image textureImage;
            Texture texture = TextureManager.Instance.GetByName(textureName);
            if( ResourceManager.HasCommonResourceData( textureName ) )
            {
                Stream s = ResourceManager.FindCommonResourceData(textureName);
                textureImage = Image.FromStream(s, parent.MosaicDesc.FileExt);
                s.Close();
            }
            else
            {
                // Create a new image
                int bpp = PixelUtil.GetNumElemBytes(DEFAULT_IMAGE_FORMAT);
                byte[] buffer = new byte[tileSizeSamples*tileSizeSamples*bpp];
                textureImage = Image.FromDynamicImage(buffer, tileSizeSamples, tileSizeSamples, DEFAULT_IMAGE_FORMAT);
                Modified = true;
            }

            // Cause the texture image to get refreshed
            dirtyImage = true;
            dirtyArea.X = 0;
            dirtyArea.Y = 0;
            dirtyArea.Width = textureImage.Width;
            dirtyArea.Height = textureImage.Height;

            // Popupate the tileData from the image
            switch (textureImage.Format)
            {
                case PixelFormat.A8:
                case PixelFormat.L8:
                    tileData = new TileData8(textureImage);
                    break;
                case PixelFormat.L16:
                    tileData = new TileData16(textureImage);
                    break;
                case PixelFormat.R8G8B8:
                case PixelFormat.B8G8R8:
                    tileData = new TileData24(textureImage);
                    break;
                case PixelFormat.A8B8G8R8:
                case PixelFormat.A8R8G8B8:
                case PixelFormat.B8G8R8A8:
                case PixelFormat.R8G8B8A8:
                case PixelFormat.X8R8G8B8:
                case PixelFormat.X8B8G8R8:
                    tileData = new TileData32(textureImage);
                    break;
                default:
                    throw new InvalidDataException("Unexpected pixel format: " + textureImage.Format);
            }
        }
        private void CreateTileData()
        {
            if (textureName.Equals("zero.png"))
            {
                textureName = string.Format("{0}_x{1}y{2}.{3}", parent.BaseName, m_tileLocationX, m_loadTileZ,
                                            parent.MosaicDesc.FileExt);
            }

            Image   textureImage;
            Texture texture = TextureManager.Instance.GetByName(textureName);

            if (ResourceManager.HasCommonResourceData(textureName))
            {
                Stream s = ResourceManager.FindCommonResourceData(textureName);
                textureImage = Image.FromStream(s, parent.MosaicDesc.FileExt);
                s.Close();
            }
            else
            {
                // Create a new image
                int    bpp    = PixelUtil.GetNumElemBytes(DEFAULT_IMAGE_FORMAT);
                byte[] buffer = new byte[tileSizeSamples * tileSizeSamples * bpp];
                textureImage = Image.FromDynamicImage(buffer, tileSizeSamples, tileSizeSamples, DEFAULT_IMAGE_FORMAT);
                Modified     = true;
            }

            // Cause the texture image to get refreshed
            dirtyImage       = true;
            dirtyArea.X      = 0;
            dirtyArea.Y      = 0;
            dirtyArea.Width  = textureImage.Width;
            dirtyArea.Height = textureImage.Height;

            // Popupate the tileData from the image
            switch (textureImage.Format)
            {
            case PixelFormat.A8:
            case PixelFormat.L8:
                tileData = new TileData8(textureImage);
                break;

            case PixelFormat.L16:
                tileData = new TileData16(textureImage);
                break;

            case PixelFormat.R8G8B8:
            case PixelFormat.B8G8R8:
                tileData = new TileData24(textureImage);
                break;

            case PixelFormat.A8B8G8R8:
            case PixelFormat.A8R8G8B8:
            case PixelFormat.B8G8R8A8:
            case PixelFormat.R8G8B8A8:
            case PixelFormat.X8R8G8B8:
            case PixelFormat.X8B8G8R8:
                tileData = new TileData32(textureImage);
                break;

            default:
                throw new InvalidDataException("Unexpected pixel format: " + textureImage.Format);
            }
        }