protected override ITexture2D this[char ch] { get { if ( noneList.Contains ( ch ) ) return null; if ( readedImage.ContainsKey ( ch ) ) return readedImage [ ch ]; if ( ch == ' ' ) { Color [] buffer = new Color [ fontSizeOfPixel * ( fontSizeOfPixel / 3 ) ]; ImageInfo imageInfo = new ImageInfo () { Width = fontSizeOfPixel / 3, Height = fontSizeOfPixel, ImageDecoder = new ImageDirectCopyDecoder ( buffer ), }; ITexture2D texture = LiqueurSystem.GraphicsDevice.CreateTexture2D ( imageInfo ); readedImage.Add ( ch, texture ); return texture; } else { int width, height, xOffset, yOffset; byte [] data = trueType.GetCodepointBitmap ( ch, fontSize, fontSize, out width, out height, out xOffset, out yOffset ); if ( data == null ) { noneList.Add ( ch ); return null; } int extendedHeight = Math.Abs ( yOffset ) * ( width/* + xOffset*/ ); Color [] buffer = new Color [ ( width/* + xOffset*/ ) * fontSizeOfPixel ]; for ( int x = 0; x < width; x++ ) { for ( int y = 0; y < height; y++ ) { int dataIndex = ( y * width ) + x; int index = ( ( y + ( fontSizeOfPixel / 3 * 2 ) + yOffset ) * ( width/* + xOffset*/ ) ) + x; if ( index >= buffer.Length || index < 0 ) continue; buffer [ index ] = data [ dataIndex ] > 0 ? new Color ( 255, 255, 255, data [ dataIndex ] ) : new Color ( 0, 0, 0, 0 ); } } ImageInfo imageInfo = new ImageInfo () { Width = width/* + xOffset*/, Height = fontSizeOfPixel, ImageDecoder = new ImageDirectCopyDecoder ( buffer ), }; ITexture2D texture = LiqueurSystem.GraphicsDevice.CreateTexture2D ( imageInfo ); readedImage.Add ( ch, texture ); return texture; } } }
public Texture2D( IGraphicsDevice graphicsDevice, ImageInfo imageInfo, Color? colorKey = null ) : this(graphicsDevice, imageInfo.Width, imageInfo.Height) { Buffer = imageInfo.GetPixel ( colorKey ); }
public SpriteNode( ImageInfo imageInfo, Color? colorKey = null ) : this(LiqueurSystem.GraphicsDevice.CreateTexture2D ( imageInfo, colorKey )) { }