本文整理汇总了C#中Gdk.Pixbuf.GetFromDrawable方法的典型用法代码示例。如果您正苦于以下问题:C# Gdk.Pixbuf.GetFromDrawable方法的具体用法?C# Gdk.Pixbuf.GetFromDrawable怎么用?C# Gdk.Pixbuf.GetFromDrawable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gdk.Pixbuf
的用法示例。
在下文中一共展示了Gdk.Pixbuf.GetFromDrawable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetScreenshot
public static byte[] GetScreenshot(int compressionLevel)
{
var root = Gdk.Global.DefaultRootWindow;
int width, height;
root.GetSize (out width, out height);
var tmp = new Gdk.Pixbuf (Gdk.Colorspace.Rgb, false, 8, width, height);
var screenshot = tmp.GetFromDrawable (root, root.Colormap, 0, 0, 0, 0, width, height);
if (compressionLevel == 0) {
// return uncompressed
}
screenshot.Save ("screen.jpg", "jpeg");
screenshot.Save ("screen.bmp", "bmp");
return screenshot.SaveToBuffer ("jpeg");
}
示例2: takeSnapShot
/// <summary>
/// Take screenshot and save it as PNG image to defined directory
/// </summary>
public void takeSnapShot()
{
Gdk.Window window = Gdk.Global.DefaultRootWindow;
if (window != null)
{
Gdk.Pixbuf pixBuf = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, false, 8, window.Screen.Width, window.Screen.Height);
pixBuf.GetFromDrawable(window, Gdk.Colormap.System, 0, 0, 0, 0, window.Screen.Width, window.Screen.Height);
var now = DateTime.Now;
// 2012-12-28
var dayPath = String.Format("{0:0000}-{1:00}-{2:00}", now.Year, now.Month, now.Day);
// 235911,213
var fileName = String.Format("{0:00}{1:00}{2:00},{3}", now.Hour, now.Minute, now.Second, now.Millisecond);
var savePath = settings.directory + "\\" + dayPath;
if(!Directory.Exists(savePath))
{
// Generate directory
Directory.CreateDirectory(savePath);
}
savePath += "\\" + fileName + ".png";
// Save screenshot
pixBuf.Save(savePath, "png");
lastFileName = savePath;
}
}