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


C# Gdk.Pixbuf.RotateSimple方法代码示例

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


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

示例1: OnDrawPage

		protected override void OnDrawPage (Gtk.PrintContext context, int page_nr)
		{
			base.OnDrawPage (context, page_nr);
			Context cr = context.CairoContext;	

			int ppx, ppy;
			switch (photos_per_page) {
			default:
			case 1: ppx = ppy =1; break;
			case 2: ppx = 1; ppy = 2; break;
			case 4: ppx = ppy = 2; break;
			case 9: ppx = ppy = 3; break;
			}

			//FIXME: if paper is landscape, swap ppx with ppy

			double w = context.Width / ppx;
			double h = context.Height / ppy;

			for (int x = 0; x <= ppx; x++) {
				for (int y = 0; y <= ppy; y++) {
					int p_index = repeat ? page_nr : page_nr * photos_per_page + y * ppx + x;
					if (crop_marks)
						DrawCropMarks (cr, x*w, y*h, w*.1);
					if (x == ppx || y == ppy || p_index >= selected_photos.Length)
						continue;
					using (ImageFile img = new ImageFile (selected_photos[p_index].DefaultVersionUri))
					{
						Gdk.Pixbuf pixbuf;
						try {
							pixbuf = img.Load ();
							FSpot.ColorManagement.ApplyPrinterProfile (pixbuf, img.GetProfile ());
						} catch (Exception e) {
							Log.Exception ("Unable to load image " + selected_photos[p_index].DefaultVersionUri + "\n", e);
							// If the image is not found load error pixbuf
							pixbuf = new Gdk.Pixbuf (PixbufUtils.ErrorPixbuf, 0, 0, 
										      PixbufUtils.ErrorPixbuf.Width, 
										      PixbufUtils.ErrorPixbuf.Height);
						}
						//Gdk.Pixbuf pixbuf = img.Load (100, 100);
						bool rotated = false;
						if (Math.Sign ((double)pixbuf.Width/pixbuf.Height - 1.0) != Math.Sign (w/h - 1.0)) {
							Gdk.Pixbuf d_pixbuf = pixbuf.RotateSimple (Gdk.PixbufRotation.Counterclockwise);
							pixbuf.Dispose ();
							pixbuf = d_pixbuf;
							rotated = true;
						}

						DrawImage (cr, pixbuf, x * w, y * h, w, h);
						DrawComment (context, (x + 1) * w, (rotated ? y : y + 1) * h, (rotated ? w : h) * .025, comment, rotated);
						pixbuf.Dispose ();
					}
				}
			}

		}
开发者ID:guadalinex-archive,项目名称:guadalinex-v6,代码行数:56,代码来源:PrintOperation.cs

示例2: OnDrawPage

        protected override void OnDrawPage(Gtk.PrintContext context, int page_nr)
        {
            base.OnDrawPage (context, page_nr);
            Context cr = context.CairoContext;

            int ppx, ppy;
            switch (photos_per_page) {
            default:
            case 1: ppx = ppy =1; break;
            case 2: ppx = 1; ppy = 2; break;
            case 4: ppx = ppy = 2; break;
            case 9: ppx = ppy = 3; break;
            case 12: ppx = 3; ppy = 4; break;
            case 20: ppx = 4; ppy = 5; break;
            case 30: ppx = 5; ppy = 6; break;
            }

            //FIXME: if paper is landscape, swap ppx with ppy

            double w = context.Width / ppx;
            double h = context.Height / ppy;

            // compute picture size using 4800DPI
            double mx=(w / 25.4) * 4800, my=(h / 25.4) * 4800;

            for (int x = 0; x <= ppx; x++) {
                for (int y = 0; y <= ppy; y++) {
                    int p_index = repeat ? page_nr : page_nr * photos_per_page + y * ppx + x;
                    if (crop_marks)
                        DrawCropMarks (cr, x*w, y*h, w*.1);
                    if (x == ppx || y == ppy || p_index >= selected_photos.Length)
                        continue;
                    using (var img = ImageFile.Create (selected_photos[p_index].DefaultVersion.Uri))
                    {
                        Gdk.Pixbuf pixbuf;
                        try {
                            pixbuf = img.Load ((int) mx, (int) my);
                            Cms.Profile printer_profile;
                            if (FSpot.ColorManagement.Profiles.TryGetValue (Preferences.Get<string> (Preferences.COLOR_MANAGEMENT_OUTPUT_PROFILE), out printer_profile))
                                FSpot.ColorManagement.ApplyProfile (pixbuf, img.GetProfile (), printer_profile);
                        } catch (Exception e) {
                            Log.Exception ("Unable to load image " + selected_photos[p_index].DefaultVersion.Uri + "\n", e);
                            // If the image is not found load error pixbuf
                            pixbuf = new Gdk.Pixbuf (PixbufUtils.ErrorPixbuf, 0, 0,
                                              PixbufUtils.ErrorPixbuf.Width,
                                              PixbufUtils.ErrorPixbuf.Height);
                        }
                        //Gdk.Pixbuf pixbuf = img.Load (100, 100);
                        bool rotated = false;
                        if (Math.Sign ((double)pixbuf.Width/pixbuf.Height - 1.0) != Math.Sign (w/h - 1.0)) {
                            Gdk.Pixbuf d_pixbuf = pixbuf.RotateSimple (Gdk.PixbufRotation.Counterclockwise);
                            pixbuf.Dispose ();
                            pixbuf = d_pixbuf;
                            rotated = true;
                        }

                        DrawImage (cr, pixbuf, x * w, y * h, w, h);

                        string tag_string = "";
                        foreach (Tag t in selected_photos[p_index].Tags)
                            tag_string = String.Concat (tag_string, t.Name);

                        string label = String.Format (print_label_format,
                                          comment,
                                          selected_photos[p_index].Name,
                                          selected_photos[p_index].Time.ToLocalTime ().ToShortDateString (),
                                          selected_photos[p_index].Time.ToLocalTime ().ToShortTimeString (),
                                          tag_string,
                                          selected_photos[p_index].Description);

                        DrawComment (context, (x + 1) * w, (rotated ? y : y + 1) * h, (rotated ? w : h) * .025, label, rotated);

                        pixbuf.Dispose ();
                    }
                }
            }
        }
开发者ID:GNOME,项目名称:f-spot,代码行数:77,代码来源:PrintOperation.cs

示例3: UpdatePreview

        protected void UpdatePreview()
        {
            thumb_image.Clear();
            FileIsGood = false;

            int size = 200, margins = 30;

            if (System.IO.File.Exists(mFilename))  // Selected item is a file
            {
                origsize_label.Markup = "";

                GLib.Timeout.Add(100, new GLib.TimeoutHandler(delegate {

                    Gdk.Pixmap pm = null;
                    Gdk.GC gc = null;
                    Gdk.Pixbuf pb = null;
                    try
                    {
                        pm = new Gdk.Pixmap(thumb_image.GdkWindow, size + margins, size + margins, -1);
                        gc = new Gdk.GC(thumb_image.GdkWindow);
                        pm.DrawRectangle(gc, true, new Gdk.Rectangle(0, 0, size + margins, size + margins));

                        RawDescriptionLoader rdl = RawDescriptionLoader.FromFile(mFilename);

                        string idtext = "";
                        try
                        {
                            idtext += "Shot has been taken\n" +
                                      "   on <b>" + rdl.TimeStamp.ToString("MMMM, d, yyyy") + "</b> at <b>" + rdl.TimeStamp.ToString("h:mm:ss tt") + "</b>,\n";

                            idtext += "   with <b>" + rdl.CameraMaker + " " + rdl.CameraModel + "</b>\n\n";
                            idtext += "ISO speed: <b>" + rdl.ISOSpeed.ToString("0") + "</b>\n";
                            if (rdl.Shutter > 1)
                                idtext += "Shutter: <b>" + rdl.Shutter.ToString("0.0") + "</b> sec\n";
                            else
                                idtext += "Shutter: <b>1/" + (1.0 / (rdl.Shutter + 0.000001)).ToString("0") + "</b> sec\n";

                            idtext += "Aperture: <b>" + rdl.Aperture.ToString("0.0") + "</b>\n" +
                                      "Focal length: <b>" + rdl.FocalLength.ToString("0") + "</b> mm\n";

                            if (rdl.Artist != "") idtext += "Artist: <b>" + rdl.Artist + "</b>\n";
                            if (rdl.Description != "") idtext += "Description: <b>" + rdl.Description + "</b>\n";

                            Console.WriteLine(rdl.Flip);

                            // Creating the thumbnail pixbuf
                            pb = new Gdk.Pixbuf(rdl.ThumbnailData);

                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Can't load the thumbnail: " + ex.Message);
                            idtext += "\n<i>Can't load the thumbnail.</i>";
                        }
                        identification_label.Markup = idtext;

                        if (pb != null)
                        {
                            // Scaling the thumbnail
                            Gdk.Pixbuf pbold = pb;
                            int imgw = pb.Width, imgh = pb.Height;
                            if (pb.Width > pb.Height)
                                pb = pb.ScaleSimple(size, (int)((double)pb.Height / pb.Width * size), Gdk.InterpType.Bilinear);
                            else
                                pb = pb.ScaleSimple((int)((double)pb.Width / pb.Height * size), size, Gdk.InterpType.Bilinear);

                            pbold.Dispose();

                            // Rotating the thumbnail
                            if (rdl.Flip != RawDescriptionLoader.FlipValues.None)
                            {
                                pbold = pb;

                                if (rdl.Flip == RawDescriptionLoader.FlipValues.UpsideDown)
                                    pb = pb.RotateSimple(Gdk.PixbufRotation.Upsidedown);
                                else if (rdl.Flip == RawDescriptionLoader.FlipValues.Clockwise)
                                {
                                    int t = imgw;
                                    imgw = imgh;
                                    imgh = t;
                                    pb = pb.RotateSimple(Gdk.PixbufRotation.Clockwise);
                                }
                                else if (rdl.Flip == RawDescriptionLoader.FlipValues.Counterclockwise)
                                {
                                    int t = imgw;
                                    imgw = imgh;
                                    imgh = t;
                                    pb = pb.RotateSimple(Gdk.PixbufRotation.Counterclockwise);
                                }

                                pbold.Dispose();
                            }

                            origsize_label.Markup = "Image size: <b>" + imgw + "</b> x <b>" + imgh + "</b>";
                            pm.DrawPixbuf(gc, pb, 0, 0,
                                          (size + margins) / 2 - pb.Width / 2,
                                          (size + margins) / 2 - pb.Height / 2,
                                          pb.Width, pb.Height, Gdk.RgbDither.Max, 0, 0);
                            thumb_image.SetFromPixmap(pm, null);
                            pb.Dispose();
//.........这里部分代码省略.........
开发者ID:bigfatbrowncat,项目名称:CatEye,代码行数:101,代码来源:RawPreviewWidget.cs


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