本文整理汇总了C#中Gdk.Pixbuf.Save方法的典型用法代码示例。如果您正苦于以下问题:C# Gdk.Pixbuf.Save方法的具体用法?C# Gdk.Pixbuf.Save怎么用?C# Gdk.Pixbuf.Save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gdk.Pixbuf
的用法示例。
在下文中一共展示了Gdk.Pixbuf.Save方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExportAsPngImage
/// <summary>
/// Exports image in PNG format.
/// </summary>
static void ExportAsPngImage (ImageInfo image, string path)
{
int width = image.ImageObject.Elements.GetInteger (PdfImage.Keys.Width);
int height = image.ImageObject.Elements.GetInteger (PdfImage.Keys.Height);
try {
byte [] data = image.ImageObject.Stream.UnfilteredValue;
using (var pixbuf = new Gdk.Pixbuf (data, Gdk.Colorspace.Rgb, false, 8, width, height, width*3)) {
pixbuf.Save (path, "png");
}
} catch (Exception e) {
Hyena.Log.Exception ("Unable to load PNG from embedded PDF object", e);
}
}
示例2: AlbumArtExists
private bool AlbumArtExists(TrackInfo currentTrack)
{
image = artwork_manager_service.LookupPixbuf(current_track.ArtworkId);
if (image == null || !image.Save(albumWallpaper, "png"))
return false;
else
return true;
}
示例3: Save
public void Save ()
{
Gdk.Pixbuf test = new Gdk.Pixbuf (null, "f-spot-32.png");
string path = ImageFile.TempPath ("joe.png");
test.Save (path, "png");
PngFile pimg = new PngFile (path);
string desc = "this is a png test";
string desc2 = "\000xa9 Novell Inc.";
pimg.SetDescription (desc);
using (Stream stream = File.OpenWrite (path)) {
pimg.Save (stream);
}
PngFile mod = new PngFile (path);
Assert.AreEqual (mod.Orientation, PixbufOrientation.TopLeft);
Assert.AreEqual (mod.Description, desc);
pimg.SetDescription (desc2);
using (Stream stream = File.OpenWrite (path)) {
pimg.Save (stream);
}
mod = new PngFile (path);
Assert.AreEqual (mod.Description, desc2);
File.Delete (path);
}
示例4: 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;
}
}