Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/312.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 将位图转换为Pixbuf_C#_Gtk# - Fatal编程技术网

C# 将位图转换为Pixbuf

C# 将位图转换为Pixbuf,c#,gtk#,C#,Gtk#,我计划在gtk图像中显示生成的位图 但它只支持Pixbuf。 如何将中的位图转换为Pixbuf 我可以用TypeConverter来做这件事吗?用不同的方法来做。 除了转换,我已经重新加载了图像 protected void OnBtnGenClicked (object sender, EventArgs e) { Bitmap bmp = new Bitmap(300, 300); using (Graphics g = Graphics.FromImage(bmp))

我计划在gtk图像中显示生成的位图

但它只支持Pixbuf。 如何将中的位图转换为Pixbuf

我可以用TypeConverter来做这件事吗?

用不同的方法来做。 除了转换,我已经重新加载了图像

protected void OnBtnGenClicked (object sender, EventArgs e)
{
    Bitmap bmp = new Bitmap(300, 300);
    using (Graphics g = Graphics.FromImage(bmp))
    {
        Font font = new Font("Arial", 20, FontStyle.Bold, GraphicsUnit.Point);
        g.Clear(Color.White);
        g.DrawString(txtMessage.Text, font, Brushes.Black, 0, 0);
    }
    bmp.Save("d:/image.png", ImageFormat.Png);
    var buffer = System.IO.File.ReadAllBytes ("d:/image.png");
    var pixbuf = new Gdk.Pixbuf (buffer);
    image1.Pixbuf = pixbuf;
}