当前位置: 首页>>代码示例>>C#>>正文


C# Pixbuf.Save方法代码示例

本文整理汇总了C#中Gdk.Pixbuf.Save方法的典型用法代码示例。如果您正苦于以下问题:C# Pixbuf.Save方法的具体用法?C# Pixbuf.Save怎么用?C# Pixbuf.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Gdk.Pixbuf的用法示例。


在下文中一共展示了Pixbuf.Save方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestSizePath

        public void TestSizePath()
        {
            var png_file_path = ExtractPngFromResource ();
            string jpg_file_path = null;

            try {
                var artist_album_id = CoverArtSpec.CreateArtistAlbumId ("Metallica", "Master Of Puppets");
                jpg_file_path = CoverArtSpec.GetPathForSize (artist_album_id, CustomArtworkManager.SizeTest); // i.e.: /home/knocte/.cache/media-art/36/album-d33f25dbd7dfb4817a7e99f6bc2de49e.jpg"
                var pixbuf = new Pixbuf (png_file_path);

                var dir = System.IO.Path.GetDirectoryName (jpg_file_path);
                if (!System.IO.Directory.Exists (dir)) {
                    System.IO.Directory.CreateDirectory (dir);
                }

                pixbuf.Save (jpg_file_path, "jpeg");

                var artwork_manager = new CustomArtworkManager ();
                Assert.IsNull (artwork_manager.LookupScaleSurface (artist_album_id, 1, false),
                               "Should have got null at the first request, with an invalid size");
                Assert.IsNotNull (artwork_manager.LookupScaleSurface (artist_album_id, CustomArtworkManager.SizeTest, false),
                                  "Null at the second request, was null cached incorrectly?");

            } finally {
                File.Delete (png_file_path);
                if (File.Exists (jpg_file_path)) {
                    File.Delete (jpg_file_path);
                }
            }
        }
开发者ID:kelsieflynn,项目名称:banshee,代码行数:30,代码来源:ArtworkManagerTests.cs

示例2: DoSave

 protected virtual void DoSave(Pixbuf pb, string fileName, string fileType)
 {
     pb.Save (fileName, fileType);
 }
开发者ID:rikky,项目名称:Pinta,代码行数:4,代码来源:GdkPixbufFormat.cs

示例3: on_snapshot_mini_done

    private void on_snapshot_mini_done(Pixbuf pixbuf)
    {
        string tempSmallFileName = Path.Combine(Path.GetTempPath(), Constants.PhotoSmallTemp +
                Util.GetMultimediaExtension(Constants.MultimediaItems.PHOTO));

        pixbuf.Save(tempSmallFileName,"jpeg");

        //on windows there are problem using the fileNames that are not on temp
        if(!adding)
            File.Copy(tempSmallFileName, Util.GetPhotoFileName(true, currentPerson.UniqueID), true); //overwrite

        capturer.Close();
        capturer.Dispose();
        capturerWindow.Hide();

        person_win.Show();

        string tempFileName = Path.Combine(Path.GetTempPath(), Constants.PhotoSmallTemp +
            Util.GetMultimediaExtension(Constants.MultimediaItems.PHOTO));
        if(!adding) {
            //on windows there are problem using the fileNames that are not on temp
            string fileName = Util.GetPhotoFileName(true, currentPerson.UniqueID);
            File.Copy(fileName, tempFileName, true);
        }

        if(File.Exists(tempFileName)) {
            Pixbuf pixbuf2 = new Pixbuf (tempFileName); //from a file
            image_photo_mini.Pixbuf = pixbuf2;
        }
    }
开发者ID:GNOME,项目名称:chronojump,代码行数:30,代码来源:person.cs

示例4: on_snapshot_done

    private void on_snapshot_done(Pixbuf pixbuf)
    {
        string fileName = Path.Combine(Path.GetTempPath(), Constants.PhotoTemp +
                Util.GetMultimediaExtension(Constants.MultimediaItems.PHOTO));

        pixbuf.Save(fileName,"jpeg");

        //on windows there are problem using the fileNames that are not on temp
        if(!adding)
            File.Copy(fileName, Util.GetPhotoFileName(false, currentPerson.UniqueID), true); //overwrite

        button_zoom.Sensitive = true;
    }
开发者ID:GNOME,项目名称:chronojump,代码行数:13,代码来源:person.cs

示例5: SaveToSuitableFormat

 private static void SaveToSuitableFormat(SafeUri destination, Pixbuf pixbuf, uint jpeg_quality)
 {
     // FIXME: this needs to work on streams rather than filenames. Do that when we switch to
     // newer GDK.
     var extension = destination.GetExtension ().ToLower ();
     if (extension == ".png")
         pixbuf.Save (destination.LocalPath, "png");
     else if (extension == ".jpg" || extension == ".jpeg")
         pixbuf.Save (destination.LocalPath, "jpeg", jpeg_quality);
     else
         throw new NotImplementedException ("Saving this file format is not supported");
 }
开发者ID:GNOME,项目名称:f-spot,代码行数:12,代码来源:PixbufUtils.cs

示例6: SetCache

    private string SetCache(ImageSize size)
    {
        string fileAux = null;
        StringBuilder cacheDir;
        Gdk.Pixbuf pixbuf;

        if (this.coverPixbuf != null) {
            pixbuf = new Pixbuf (coverPixbuf);
            switch (size) {
                case ImageSize.Small:
                    if (pixbuf.Height > pixbuf.Width) {
                        int x = 50*pixbuf.Width/pixbuf.Height;
                        pixbuf = pixbuf.ScaleSimple (x, 50, InterpType.Hyper);
                    }
                    else {
                        int x = 50*pixbuf.Height/pixbuf.Width;
                        pixbuf = pixbuf.ScaleSimple (50, x, InterpType.Hyper);
                    }
                    cacheDir = new StringBuilder (Conf.HomeDir);
                    cacheDir = cacheDir.Append ("/cache");
                    cacheDir = cacheDir.Append ("/small/");
                    cacheDir = cacheDir.Append (System.IO.Path.GetFileName(cover));
                    cacheDir = cacheDir.Append (".png");
                    fileAux = cacheDir.ToString();
                    pixbuf.Save (fileAux, "png");
                    break;
                case ImageSize.Medium:
                    if (pixbuf.Height > pixbuf.Width) {
                        int x = 100*pixbuf.Width/pixbuf.Height;
                        pixbuf = pixbuf.ScaleSimple (x, 100, InterpType.Hyper);
                    }
                    else {
                        int x = 100*pixbuf.Height/pixbuf.Width;
                        pixbuf = pixbuf.ScaleSimple (100, x, InterpType.Hyper);
                    }
                    cacheDir = new StringBuilder (Conf.HomeDir);
                    cacheDir = cacheDir.Append ("/cache");
                    cacheDir = cacheDir.Append ("/medium/");
                    cacheDir = cacheDir.Append (System.IO.Path.GetFileName(cover));
                    cacheDir = cacheDir.Append (".png");
                    fileAux = cacheDir.ToString();
                    pixbuf.Save (fileAux, "png");

                    break;
                case ImageSize.Large:
                    cacheDir = new StringBuilder (Conf.HomeDir);
                    cacheDir = cacheDir.Append ("/cache");
                    cacheDir = cacheDir.Append ("/large/");
                    cacheDir = cacheDir.Append (System.IO.Path.GetFileName(cover));
                    cacheDir = cacheDir.Append (".png");
                    fileAux = cacheDir.ToString();
                    pixbuf.Save (fileAux, "png");
                    break;
            }
        }
        else {
            fileAux = null;
        }

        return fileAux;
    }
开发者ID:MonoBrasil,项目名称:historico,代码行数:61,代码来源:Item.cs

示例7: MainWindow

    public MainWindow()
        : base(Gtk.WindowType.Toplevel)
    {
        Init = true;

        Build ();
        forumsGallery.PagesModel = pagesModel;
        forumsGallery.OnForumClick = OpenForum;
        forumsGallery.OnPageChanged = SetPageUrl;

        var items_string = File.ReadAllText ("Resources/items.json");
        celebrities = JsonConvert.DeserializeObject<List<CelebrityItemJson>> (items_string)
            .OrderBy ((x) => x.Name).ToList ();

        wndCelebrityList.OnSelect += (string obj) => {
            edtQuery.Text = obj;
            Find ();
        };

        galleryPreview.OnGalleryItemClick += (GalleryItem item) => {
            imagePreview.Url = item.url;
        };
        galleryPreview.OnSaveClick += (string itemPath, ImageLoader loader) => {
            HostingManager.GetImage (itemPath, () => {
                loader.StartLoadAnimation ();
                loader.ShowButtons = false;
            }, (byte[] buffer, string image_src) => {
                var fileName = System.IO.Path.GetFileName (image_src);
                try {
                    var pixbuf = new Pixbuf (buffer);

                    var fileDir = System.IO.Path.Combine (settings.SaveDir, CelebrityName);
                    System.IO.Directory.CreateDirectory (fileDir);

                    pixbuf.Save (System.IO.Path.Combine (fileDir, fileName), "jpeg");
                } catch (Exception e) {
                    log.Error (e);
                }
                loader.StopLoadAnimation ();
            });
        };

        this.FocusOutEvent += (o, args) => {
            wndCelebrityList.Hide ();
        };

        LoadSettings ();
        randomLine.OnRandomButtonClick = (RandomCelebs obj) => {
            randomLine.GenRandom (celebrities);
        };
        randomLine.OnItemClick = (CelebrityItemJson obj) => {
            Init = true;
            this.edtQuery.Text = obj.Name;
            Find ();
            Init = false;
        };
        randomLine.GenRandom (celebrities);

        Init = false;
    }
开发者ID:SevenLines,项目名称:csharp-superiorpics,代码行数:60,代码来源:MainWindow.cs


注:本文中的Gdk.Pixbuf.Save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。