Esempio n. 1
0
        protected override void InnerDraw(GraphicsDisplay display, GeoStar.Core.TrackCancel cancel)
        {
            if (m_TileList.Count == 0)
            {
                return;
            }

            List <QuadTile> vList = new List <QuadTile>();

            lock (this)
            {
                vList.AddRange(m_TileList);
            }
            System.Windows.Media.DrawingContext dc = display.DrawingContext;
            foreach (var item in vList)
            {
                Box box = m_Pyramid.TileExtent(item.Level, item.Row, item.Col);
                System.Windows.Rect rect = display.DT.FromMapWPF(box);

                dc.DrawRectangle(null,
                                 new System.Windows.Media.Pen(System.Windows.Media.Brushes.Red, 1), rect);

                System.Windows.Media.FormattedText formattedText = new System.Windows.Media.FormattedText(
                    string.Format(" {0},{1},{2}", item.Level, item.Row, item.Col),
                    System.Globalization.CultureInfo.CurrentCulture,
                    System.Windows.FlowDirection.LeftToRight,
                    new  System.Windows.Media.Typeface("微软雅黑"),
                    12,
                    System.Windows.Media.Brushes.Black);


                dc.DrawText(formattedText, rect.Location);
            }
        }
Esempio n. 2
0
 public static System.Windows.Size MeasureTextBlockSize(TextBlock textblock)
 {
     System.Windows.Media.Typeface      typeFace      = new System.Windows.Media.Typeface(textblock.FontFamily, textblock.FontStyle, textblock.FontWeight, textblock.FontStretch);
     System.Windows.Media.FormattedText formattedText = new System.Windows.Media.FormattedText(textblock.Text, CultureInfo.CurrentCulture, FlowDirection.LeftToRight,
                                                                                               typeFace, textblock.FontSize, textblock.Foreground);
     return(new System.Windows.Size(formattedText.Width, formattedText.Height));
 }
Esempio n. 3
0
        public static List <string> WrapText(this string text, double pixels, string fontFamily, float emSize, out double actualHeight)
        {
            string[] originalLines = text.Split(new string[] { " " },
                                                StringSplitOptions.None);

            List <string> wrappedLines = new List <string>();

            StringBuilder actualLine  = new StringBuilder();
            double        actualWidth = 0;

            actualHeight = 0;
            foreach (var item in originalLines)
            {
                System.Windows.Media.FormattedText formatted = new System.Windows.Media.FormattedText(item,
                                                                                                      CultureInfo.CurrentCulture,
                                                                                                      System.Windows.FlowDirection.LeftToRight,
                                                                                                      new System.Windows.Media.Typeface(fontFamily),
                                                                                                      emSize,
                                                                                                      System.Windows.Media.Brushes.Black,
                                                                                                      1.0); // FIXME: 1.0 is probably not correct


                actualWidth += formatted.Width;
                actualHeight = formatted.Height;

                if (actualWidth > pixels)
                {
                    wrappedLines.Add(actualLine.ToString());
                    actualLine.Clear();
                    actualWidth = 0;
                    actualLine.Append(item + " ");
                    actualWidth += formatted.Width;
                }
                else if (item == Environment.NewLine || item == "\n")
                {
                    wrappedLines.Add(actualLine.ToString());
                    actualLine.Clear();
                    actualWidth = 0;
                }
                else
                {
                    actualLine.Append(item + " ");
                }
            }
            if (actualLine.Length > 0)
            {
                wrappedLines.Add(actualLine.ToString());
            }

            return(wrappedLines);
        }
Esempio n. 4
0
 /// <summary>
 /// 计算文本显示宽、高
 /// </summary>
 /// <param name="text">The text.</param>
 /// <param name="fontFamily">The font family.</param>
 /// <param name="fontStyle">The font style.</param>
 /// <param name="fontWeight">The font weight.</param>
 /// <param name="fontStretch">The font stretch.</param>
 /// <param name="fontSize">Size of the font.</param>
 /// <returns></returns>
 public static MeasureSize MeasureTextSize(
     string text,
     System.Windows.Media.FontFamily fontFamily,
     System.Windows.FontStyle fontStyle,
     System.Windows.FontWeight fontWeight,
     System.Windows.FontStretch fontStretch,
     double fontSize)
 {
     System.Windows.Media.FormattedText ft = new System.Windows.Media.FormattedText(text,
                                                                                    System.Globalization.CultureInfo.CurrentCulture,
                                                                                    System.Windows.FlowDirection.LeftToRight,
                                                                                    new System.Windows.Media.Typeface(fontFamily, fontStyle, fontWeight, fontStretch),
                                                                                    fontSize,
                                                                                    System.Windows.Media.Brushes.Black);
     return(new MeasureSize(ft.Width, ft.Height));
 }
        private static Shape CreateTextShape(string text, double placeX, double placeY, double fontSize, System.Windows.Media.Color color)
        {
            Shape textShape;

            System.Windows.Media.FontFamily fontFamily = new System.Windows.Media.FontFamily("Times New Roman");
            Typeface typeface = new Typeface(fontFamily, FontStyles.Normal, FontWeights.Bold, new FontStretch());

            FormattedText fText = new FormattedText(text, CultureInfo.CurrentCulture, System.Windows.FlowDirection.LeftToRight, typeface, fontSize, System.Windows.Media.Brushes.Black);

            System.Windows.Point textPosition1;
            textPosition1 = new System.Windows.Point(placeX, placeY);
            Path path = new Path();

            path.Data = fText.BuildGeometry(textPosition1);
            path.Fill = new SolidColorBrush(color);
            textShape = path;
            return(textShape);
        }
        /// <summary>Draw Text to canvas according coordinates and label</summary>
        public void DrawText(string label, float x, float y, float xmin, float ymin, float xmax, float ymax)
        {
            if (_fillColor.Color.A > 0)
            {
                // Create formatted text in a particular font at a particular size
                var typeFace = new System.Windows.Media.Typeface(_fontFamily, _fontStyle, _fontWeight, _fontStretch);
                var ft       = new System.Windows.Media.FormattedText
                               (
                    label, System.Globalization.CultureInfo.CurrentCulture,
                    FlowDirection.LeftToRight, typeFace, _fontSize, _fillColor
                               );

                ft.TextAlignment = TextAlignment.Left;

                // Draw the text
                var clipped = PushRenderStates();
                _drawingContext.DrawText(ft, new System.Windows.Point(x, y - _baseline));
                PopRenderStates(clipped);
            }
        }
        public TxtYearVisibilityConverter()
        {
            try
            {
                var formattedText = new System.Windows.Media.FormattedText(
                    "2222",
                    CultureInfo.CurrentCulture,
                    FlowDirection.LeftToRight,
                    new System.Windows.Media.Typeface("Verdana"),
                    this.FontSize == 0 ? 14d : this.FontSize,
                    System.Windows.Media.Brushes.Black,
                    new System.Windows.Media.NumberSubstitution(),
                    1);

                this.txtWidth = formattedText.Width;
            }
            catch (Exception e)
            {
                ;
            }
        }
Esempio n. 8
0
        public override void Draw(CellDrawingContext dc)
        {
#if DEBUG
            Stopwatch sw = Stopwatch.StartNew();
#endif

            if (!Visible ||          //|| visibleGridRegion == GridRegion.Empty
                bounds.Width <= 0 || bounds.Height <= 0)
            {
                return;
            }

            //bool needClip = this.Parent == null
            //	|| this.bounds != this.Parent.Bounds;

            //bool needTranslate = this.Parent == null
            //	|| this.viewStart.X != this.Parent.ViewLeft
            //	|| this.ViewStart.Y != this.Parent.ViewTop;

            var g = dc.Graphics;

            if (PerformTransform)
            {
                g.PushClip(this.bounds);
                g.PushTransform();
                g.TranslateTransform(bounds.Left - ScrollViewLeft * this.scaleFactor, bounds.Top - ScrollViewTop * this.scaleFactor);
            }

            DrawView(dc);

            if (this.PerformTransform)
            {
                g.PopTransform();
                g.PopClip();
            }

#if VP_DEBUG
#if WINFORM
            if (this is SheetViewport ||
                this is ColumnHeaderView
                //|| this is RowHeaderView
                || this is RowOutlineView)
            {
                //var rect = this.bounds;
                //rect.Width--;
                //rect.Height--;
                //dc.Graphics.DrawRectangle(this.bounds, this is SheetViewport ? SolidColor.Blue : SolidColor.Purple);

                var msg = $"{ this.GetType().Name }\n" +
                          $"{visibleRegion.ToRange()}\n" +
                          $"{this.ViewLeft}, {this.ViewTop}, ({ScrollX}, {ScrollY}), {this.Width}, {this.Height}\n" +
                          $"{this.ScrollableDirections}";

                dc.Graphics.PlatformGraphics.DrawString(msg,
                                                        System.Drawing.SystemFonts.DefaultFont, System.Drawing.Brushes.Blue, this.Left + Width / 2, Top + Height / 2);
            }
#elif WPF
            var msg = string.Format("VR {0},{1}-{2},{3} VS X{4},Y{5}\nSD {6}", this.visibleRegion.startRow,
                                    this.visibleRegion.startCol, this.visibleRegion.endRow, this.visibleRegion.endCol, this.ViewLeft, this.ViewTop,
                                    this.ScrollableDirections.ToString());

            var ft = new System.Windows.Media.FormattedText(msg, System.Globalization.CultureInfo.CurrentCulture, System.Windows.FlowDirection.LeftToRight,
                                                            new System.Windows.Media.Typeface("Arial"), 12, System.Windows.Media.Brushes.Blue, 96);

            dc.Graphics.PlatformGraphics.DrawText(ft, new System.Windows.Point(this.Left + 1, this.Top + ((this is CellsViewport) ? 30 : this.Height / 2)));
#endif // WPF
#endif // VP_DEBUG

#if DEBUG
            sw.Stop();
            if (sw.ElapsedMilliseconds > 20)
            {
                Debug.WriteLine("draw viewport takes " + sw.ElapsedMilliseconds + " ms. visible region: rows: " + visibleRegion.Rows + ", cols: " + visibleRegion.Cols);
            }
#endif // Debug
        }
Esempio n. 9
0
 public static WpfText SetBold(this WpfText text)
 {
     text.SetFontWeight(FontWeights.Bold);
     return(text);
 }
Esempio n. 10
0
 public static WpfText SetItalic(this WpfText text)
 {
     text.SetFontStyle(FontStyles.Italic);
     return(text);
 }
Esempio n. 11
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (imageViewerControl != null)
            {
                imageViewerControl.Disconnect();
                imageViewerControl.Close();
                imageViewerControl.Dispose();
                imageViewerControl = null;
            }

            ItemPickerForm picker = new ItemPickerForm();

            picker.KindFilter = Kind.Camera;
            picker.Init(Configuration.Instance.GetItems());

            if (picker.ShowDialog() == DialogResult.OK)
            {
                selectedItem = picker.SelectedItem;
                _item        = picker.SelectedItem;
                label2.Text  = selectedItem.Name;

                if (_item != null && _path != null)
                {
                    buttonExport.Enabled = true;
                }

                try
                {
                    imageViewerControl      = ClientControl.Instance.GenerateImageViewerControl();
                    imageViewerControl.Dock = DockStyle.Fill;
                    panel1.Controls.Clear();
                    panel1.Controls.Add(imageViewerControl);
                    imageViewerControl.CameraFQID        = selectedItem.FQID;
                    imageViewerControl.EnableDigitalZoom = true;

                    imageViewerControl.EnableVisibleHeader = false;

                    imageViewerControl.Initialize();
                    imageViewerControl.Connect();

                    //add overlay text on top of video
                    var fontFamily = new System.Windows.Media.FontFamily("Open Sans Semibold");
                    var typeface   = new System.Windows.Media.Typeface(fontFamily, System.Windows.FontStyles.Normal, System.Windows.FontWeights.Bold, new System.Windows.FontStretch());
                    var fText      = new System.Windows.Media.FormattedText(selectedItem.Name, System.Globalization.CultureInfo.CurrentCulture, System.Windows.FlowDirection.LeftToRight, typeface, 25, System.Windows.Media.Brushes.White);
                    var path       = new System.Windows.Shapes.Path()
                    {
                        Data = fText.BuildGeometry(new System.Windows.Point(20, 160)), Fill = System.Windows.Media.Brushes.White
                    };
                    var id = imageViewerControl.ShapesOverlayAdd(new List <System.Windows.Shapes.Shape> {
                        path
                    }, new ShapesOverlayRenderParameters()
                    {
                        ZOrder = 100
                    });
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Exception " + ex);
                }
            }
        }
Esempio n. 12
0
        private void Create_WPF_Window()
        {
            //int scrnHeight = Convert.ToInt32(System.Windows.SystemParameters.PrimaryScreenHeight);
            int scrnWidth = Convert.ToInt32(System.Windows.SystemParameters.PrimaryScreenWidth);

            /****************************
            * WPF Window
            ****************************/
            WPFControl1 n = new WPFControl1();

            n.Left   = GetCursorPosition().X;
            n.Top    = GetCursorPosition().Y + 5;
            n.Height = 200;
            n.Width  = 450;
            n.Show();


            /****************************
            * Label for WPF content
            ****************************/
            System.Windows.Controls.Label _fs = new System.Windows.Controls.Label();
            _fs.Foreground = System.Windows.Media.Brushes.White;
            //_fs.Foreground = System.Windows.Media.Brushes.
            _fs.Foreground = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(SMS_ToolTip.fontColor[0], SMS_ToolTip.fontColor[1], SMS_ToolTip.fontColor[2], SMS_ToolTip.fontColor[3]));
            _fs.FontFamily = new System.Windows.Media.FontFamily("Segoe UI");
            _fs.FontSize   = 18;
            _fs.FontWeight = System.Windows.FontWeights.Bold;
            _fs.Effect     = new DropShadowEffect
            {
                Color = new System.Windows.Media.Color {
                    A = 255, R = 0, G = 0, B = 0
                },
                Direction   = 0,
                ShadowDepth = 0,
                Opacity     = 1
            };
            _fs.Opacity = 1;
            n.Content   = _fs;


            /****************************
            * Timer to lock window to
            * cursor pos and keep
            * label.text up to date
            ****************************/
            System.Windows.Forms.Timer _t1 = new System.Windows.Forms.Timer();
            int _tt = 0;

            _t1.Tick += (sender, e) =>
            {
                if (_tt >= 220)
                {
                    _t1.Enabled = false;
                    DoubleAnimation anim = new DoubleAnimation(0, (System.Windows.Duration)TimeSpan.FromSeconds(1));
                    anim.Completed += (s, _) => n.Close();
                    n.BeginAnimation(System.Windows.UIElement.OpacityProperty, anim);

                    return;
                }
                string[] lines = ((RichTextBox)Threads[SMS_ToolTip.SelectedTab].richBox).Lines;
                int      v;
                string   sample;

                _fs.Content = string.Format("Name: {0}\r\nRecommended Value: {1}", lines.Length > 1 ? lines[1] : "E", ((Label)Threads[SMS_ToolTip.SelectedTab].valueBox).Text);
                v           = string.Format("Name: {0}", lines.Length > 1 ? lines[1] : "E").Length > string.Format("Recommended Value: {0}", ((Label)Threads[SMS_ToolTip.SelectedTab].valueBox).Text).Length ? 1 : 2;

                if (v == 2)
                {
                    sample = string.Format("Recommended Value: {0}", ((Label)Threads[SMS_ToolTip.SelectedTab].valueBox).Text);
                }
                else
                {
                    sample = string.Format("Name: {0}", lines.Length > 1 ? lines[1] : "E");
                }


                System.Windows.Media.Typeface      myTypeface = new System.Windows.Media.Typeface("Segoe UI");
                System.Windows.Media.FormattedText ft         = new System.Windows.Media.FormattedText(sample, CultureInfo.CurrentCulture, System.Windows.FlowDirection.LeftToRight, myTypeface, 20, System.Windows.Media.Brushes.White);

                if ((GetCursorPosition().X + ft.Width) + 25 > scrnWidth)
                {
                    n.Left = (GetCursorPosition().X - 25) - ft.Width;
                    n.Top  = GetCursorPosition().Y;
                }
                else
                {
                    n.Left = GetCursorPosition().X + 25;
                    n.Top  = GetCursorPosition().Y;
                }
                _tt++;
            };
            _t1.Interval = 10;
            _t1.Enabled  = true;
        }
Esempio n. 13
0
        /*
         * // Windows Forms版 TODO: 直書きあり
         * public static void DrawString(string str, double fontSize)
         * {
         *  var window = System.Windows.Application.Current.MainWindow;
         *
         *  double[] glDoubleColor = new double[4];
         *  GL.GetDouble(GetPName.CurrentColor, glDoubleColor);
         *  byte glR = (byte)(glDoubleColor[0] * 255);
         *  byte glG = (byte)(glDoubleColor[1] * 255);
         *  byte glB = (byte)(glDoubleColor[2] * 255);
         *  byte glA = (byte)(glDoubleColor[3] * 255); //255;
         *  var glColor = System.Drawing.Color.FromArgb(glA, glR, glG, glB);
         *  System.Drawing.Brush foreground = new System.Drawing.SolidBrush(glColor);
         *
         *  //var font = new System.Drawing.Font("Arial", 12);
         *  //var font = new System.Drawing.Font(window.FontFamily.Source, (int)window.FontSize);
         *  // 1 point  =  1 / 72.0 inch = (1 / 72.0) * 96  = 1.333333 pixel
         *  var font = new System.Drawing.Font(window.FontFamily.Source, (int)(fontSize / 1.333333));
         *  // サイズ取得用に生成
         *  var bmp = new System.Drawing.Bitmap(1, 1, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
         *  System.Drawing.SizeF size;
         *  using (var g = System.Drawing.Graphics.FromImage(bmp))
         *  {
         *      g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
         *
         *      size = g.MeasureString(str, font);
         *  }
         *
         *  // 再生成
         *  {
         *      int width = (int)size.Width;
         *      //int height = (int)size.Height;
         *      // TODO: テキストのY座標がずれている : 画像の高さが大きすぎる
         *      int height = (int)(size.Height * 0.75);
         *      bmp = new System.Drawing.Bitmap(width, height,
         *          System.Drawing.Imaging.PixelFormat.Format32bppArgb);
         *  }
         *
         *  using (var g = System.Drawing.Graphics.FromImage(bmp))
         *  {
         *      g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
         *
         *      g.DrawString(str, font, foreground, new System.Drawing.Point(0, 0));
         *  }
         *
         *  // check
         *  //bmp.Save("1.bmp");
         *
         *  // 上下反転する
         *  bmp.RotateFlip(System.Drawing.RotateFlipType.RotateNoneFlipY);
         *
         *  var bitmapData = bmp.LockBits(new System.Drawing.Rectangle(0, 0, bmp.Width, bmp.Height),
         *      System.Drawing.Imaging.ImageLockMode.ReadOnly,
         *      System.Drawing.Imaging.PixelFormat.Format32bppArgb);
         *  int bmpWidth = bitmapData.Width;
         *  int bmpHeight = bitmapData.Height;
         *
         *  bool isTexture = GL.IsEnabled(EnableCap.Texture2D);
         *  bool isBlend = GL.IsEnabled(EnableCap.Blend);
         *  GL.Enable(EnableCap.Texture2D);
         *  GL.Enable(EnableCap.Blend);
         *  GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha);
         *
         *  int texture = GL.GenTexture();
         *  GL.BindTexture(TextureTarget.Texture2D, texture);
         *  GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter,
         *      (int)TextureMinFilter.Linear);
         *  GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter,
         *      (int)TextureMagFilter.Linear);
         *  GL.TexImage2D(TextureTarget.Texture2D, 0,
         *      PixelInternalFormat.Rgba,
         *      bmpWidth, bmpHeight, 0,
         *      PixelFormat.Bgra, PixelType.UnsignedByte, bitmapData.Scan0);
         *
         *  GL.PushMatrix();
         *  OpenTK.Matrix4d m;
         *  GL.GetDouble(GetPName.ModelviewMatrix, out m);
         *  //GL.Translate(0, 0, -m.M14);
         *  GL.Scale(1.0 / m.M11, 1.0 / m.M22, 1.0 / m.M33);
         *  GL.Scale(FontScale, FontScale, 1.0); // TODO: これを計算で求める必要がある
         *
         *  GL.Begin(PrimitiveType.Quads);
         *  GL.TexCoord2(0, 0);
         *  GL.Vertex2(0, 0);
         *
         *  GL.TexCoord2(1, 0);
         *  GL.Vertex2(bmpWidth, 0);
         *
         *  GL.TexCoord2(1, 1);
         *  GL.Vertex2(bmpWidth, bmpHeight);
         *
         *  GL.TexCoord2(0, 1);
         *  GL.Vertex2(0, bmpHeight);
         *  GL.End();
         *  GL.PopMatrix();
         *
         *  bmp.UnlockBits(bitmapData);
         *
         *  if (!isTexture)
         *  {
         *      GL.Disable(EnableCap.Texture2D);
         *  }
         *  if (!isBlend)
         *  {
         *      GL.Disable(EnableCap.Blend);
         *  }
         * }
         */

        // WPF版 TODO: 直書きあり
        public static void DrawString(string str, double fontSize)
        {
            var window = System.Windows.Application.Current.MainWindow;

            double[] glDoubleColor = new double[4];
            GL.GetDouble(GetPName.CurrentColor, glDoubleColor);
            var glColor = new System.Windows.Media.Color();

            glColor.R = (byte)(glDoubleColor[0] * 255);
            glColor.G = (byte)(glDoubleColor[1] * 255);
            glColor.B = (byte)(glDoubleColor[2] * 255);
            glColor.A = (byte)(glDoubleColor[3] * 255); //255;
            System.Windows.Media.Brush foreground = new System.Windows.Media.SolidColorBrush(glColor);
            //System.Windows.Media.Brush foreground = window.Foreground;

            var text = new System.Windows.Media.FormattedText(
                str,
                new System.Globalization.CultureInfo("en-us"),
                System.Windows.FlowDirection.LeftToRight,
                new System.Windows.Media.Typeface(
                    window.FontFamily,
                    System.Windows.FontStyles.Normal,
                    System.Windows.FontWeights.Normal,
                    new System.Windows.FontStretch()),
                fontSize, //window.FontSize,
                foreground);
            var drawingVisual = new System.Windows.Media.DrawingVisual();

            using (System.Windows.Media.DrawingContext drawingContext = drawingVisual.RenderOpen())
            {
                drawingContext.DrawText(text, new System.Windows.Point(0, 0));
            }

            System.Windows.Media.Imaging.RenderTargetBitmap bmp = null;
            {
                int width  = (int)text.Width;
                int height = (int)text.Height;
                int dpiX   = 96;
                int dpiY   = 96;
                bmp = new System.Windows.Media.Imaging.RenderTargetBitmap(
                    width, height, dpiX, dpiY, System.Windows.Media.PixelFormats.Pbgra32);
            }

            bmp.Render(drawingVisual);

            int bmpWidth  = bmp.PixelWidth;
            int bmpHeight = bmp.PixelHeight;
            int stride    = bmpWidth * 4;

            byte[] tmpbits   = new byte[stride * bmpHeight];
            var    rectangle = new System.Windows.Int32Rect(0, 0, bmpWidth, bmpHeight);

            bmp.CopyPixels(rectangle, tmpbits, stride, 0);
            // 上下反転する
            byte[] bits = new byte[stride * bmpHeight];
            for (int h = 0; h < bmpHeight; h++)
            {
                for (int w = 0; w < stride; w++)
                {
                    bits[h * stride + w] = tmpbits[(bmpHeight - 1 - h) * stride + w];
                }
            }

            // check
            //var png = new System.Windows.Media.Imaging.PngBitmapEncoder();
            //png.Frames.Add(System.Windows.Media.Imaging.BitmapFrame.Create(bmp));
            //using (var fs = new FileStream("1.png", FileMode.Create))
            //{
            //    png.Save(fs);
            //}

            bool isTexture = GL.IsEnabled(EnableCap.Texture2D);
            bool isBlend   = GL.IsEnabled(EnableCap.Blend);

            GL.Enable(EnableCap.Texture2D);
            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha);

            int texture = GL.GenTexture();

            GL.BindTexture(TextureTarget.Texture2D, texture);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter,
                            (int)TextureMinFilter.Linear);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter,
                            (int)TextureMagFilter.Linear);
            GL.TexImage2D(TextureTarget.Texture2D, 0,
                          PixelInternalFormat.Rgba,
                          bmpWidth, bmpHeight, 0,
                          PixelFormat.Bgra, PixelType.UnsignedByte, bits);

            GL.PushMatrix();
            OpenTK.Matrix4d m;
            GL.GetDouble(GetPName.ModelviewMatrix, out m);
            GL.Scale(1.0 / m.M11, 1.0 / m.M22, 1.0 / m.M33);
            GL.Scale(FontScale, FontScale, 1.0); // TODO: これを計算で求める必要がある

            GL.Begin(PrimitiveType.Quads);
            GL.TexCoord2(0, 0);
            GL.Vertex2(0, 0);

            GL.TexCoord2(1, 0);
            GL.Vertex2(bmpWidth, 0);

            GL.TexCoord2(1, 1);
            GL.Vertex2(bmpWidth, bmpHeight);

            GL.TexCoord2(0, 1);
            GL.Vertex2(0, bmpHeight);
            GL.End();
            GL.PopMatrix();

            if (!isTexture)
            {
                GL.Disable(EnableCap.Texture2D);
            }
            if (!isBlend)
            {
                GL.Disable(EnableCap.Blend);
            }
        }