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


C# Pixbuf.Clone方法代码示例

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


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

示例1: Process

 protected override Pixbuf Process(Pixbuf input, Cms.Profile input_profile)
 {
     Pixbuf output = (Pixbuf) input.Clone ();
     return output.Flip (true);
 }
开发者ID:nathansamson,项目名称:F-Spot-Album-Exporter,代码行数:5,代码来源:FlipEditor.cs

示例2: EnhancedSimdSupport

        /*		static bool enhanced_support = EnhancedSimdSupport ();
        static bool EnhancedSimdSupport () { //require sse3
            return SimdRuntime.IsMethodAccelerated (typeof (VectorOperations), "HorizontalAdd", new Type[] {typeof (Vector4f), typeof (Vector4f)})
                   && SimdRuntime.IsMethodAccelerated (typeof (Vector4f), "op_Multiply");
        }*/
        protected override Pixbuf Process(Pixbuf input, Cms.Profile input_profile)
        {
            uint timer = Log.DebugTimerStart ();
            if (input.BitsPerSample != 8) {
                Log.Warning ("unsupported pixbuf format");
                return (Pixbuf)input.Clone ();
            }
            Pixbuf output = new Pixbuf (input.Colorspace, input.HasAlpha, input.BitsPerSample, input.Width, input.Height);
            Vector4f multiply = new Vector4f ((float)(r.Value/100.0), (float)(g.Value/100.0), (float)(b.Value/100.0), 0);
            Normalize (ref multiply);

            bool has_alpha = input.HasAlpha;
            int chan = input.NChannels;
            int rowstride_in = input.Rowstride;
            int rowstride_out = output.Rowstride;
            Vector4f v_in;
            Vector4f v_out = new Vector4f (0);
            float[] fcurve = new float [256];
            c.GetVector (fcurve.Length, fcurve);
            byte[] curve = new byte [fcurve.Length];
            for (int i = 0; i < fcurve.Length; i++)
                curve[i] = (byte)fcurve[i];
            unsafe {
                byte *pix_in = (byte *)input.Pixels;
                byte *pix_out = (byte *)output.Pixels;
                for (int i=0; i < input.Height; i++)
                    for (int j=0; j<input.Width; j++) {
                        v_in = new Vector4f (pix_in[i*rowstride_in + j*chan],
                                     pix_in[i*rowstride_in + j*chan + 1],
                                     pix_in[i*rowstride_in + j*chan + 2],
                                     0);
                        Desaturate (ref v_in, ref multiply, ref v_out);
                        pix_out[i*rowstride_out + j*chan] = curve [unchecked ((byte)v_out.X)];
                        pix_out[i*rowstride_out + j*chan + 1] = curve [unchecked ((byte)v_out.Y)];
                        pix_out[i*rowstride_out + j*chan + 2] = curve [unchecked ((byte)v_out.Z)];
                        if (has_alpha)
                            pix_out[i*rowstride_out + j*chan + 3] = pix_in[i*rowstride_in + j*chan + 3];
                    }
            }
            Log.DebugTimerPrint (timer, "Processing took {0}");
            return output;
        }
开发者ID:nathansamson,项目名称:F-Spot-Album-Exporter,代码行数:47,代码来源:BWEditor.cs

示例3: SaveThumbnail

 public static void SaveThumbnail(Pixbuf pixbuf, Uri image_uri, DateTime original_mtime)
 {
     cache[image_uri]=pixbuf.Clone() as Pixbuf;
 }
开发者ID:iainlane,项目名称:f-spot,代码行数:4,代码来源:ThumbnailFactory.cs

示例4: Process

 protected override Pixbuf Process(Pixbuf input, Cms.Profile input_profile)
 {
     Pixbuf output = (Pixbuf) input.Clone ();
     double ratio = (double)size.Value / Math.Max (output.Width, output.Height);
     return output.ScaleSimple ((int)(output.Width * ratio), (int)(output.Height * ratio), InterpType.Bilinear);
 }
开发者ID:h4ck3rm1k3,项目名称:f-spot,代码行数:6,代码来源:ResizeEditor.cs

示例5: getDiff

        static Pixbuf getDiff(Pixbuf A, Pixbuf B, out string diffstring, out double r2)
        {
            // r2 as in http://en.wikipedia.org/wiki/Coefficient_of_determination

            diffstring = "";
            r2 = 0;

            if (A.Width != B.Width || A.Height != B.Height) {
                B = B.ScaleSimple (A.Width, A.Height, Gdk.InterpType.Nearest);
                diffstring = string.Format ("Different sizes.\n");
            }
            if (A.HasAlpha != B.HasAlpha) {
                if (A.HasAlpha && !B.HasAlpha)
                    diffstring += string.Format ("Reference image doesn't have an alpha channel. But the new image does.\n");
                else
                    diffstring += string.Format ("Reference image has an alpha channel. But the new image doesn't.\n");
            } else {
                if (A.Rowstride != B.Rowstride) {
                    diffstring += string.Format ("Different rowstride.\n");
                }
            }
            if (A.NChannels - (A.HasAlpha ? 1 : 0) != B.NChannels - (B.HasAlpha ? 1 : 0)) {
                diffstring += string.Format ("Different number of channels.");
                return null;
            }

            if (A.BitsPerSample != B.BitsPerSample) {
                diffstring += string.Format ("Different bits per sample\n");
                return null;
            }

            if (A.BitsPerSample != 8) {
                diffstring += string.Format ("Only support diffs of images with 8 bits per sample, got {1}.", A.BitsPerSample);
                return null;
            }
            Gdk.Pixbuf C = (Gdk.Pixbuf)A.Clone ();
            double v = 0;
            double amean = 0;
            double cmean = 0;
            double asum = 0;
            unsafe {
                byte* a = (byte*)A.Pixels;
                byte* b = (byte*)B.Pixels;
                byte* c = (byte*)C.Pixels;
                int bnc = B.NChannels;
                int anc = A.NChannels;
                int nc = bnc < anc ? bnc : anc;
                int w = A.Width;
                for (int y=0; y<A.Height; ++y) {
                    int oa = y * A.Rowstride;
                    int ob = y * B.Rowstride;
                    for (int n=0; n<w; ++n)
                    {
                        for (int m=0; m<nc; ++m) {
                            int o = oa + n*anc + m;
                            int d = ((int)a [o]) - (int)b [ob + n*bnc + m];
                            if (d < 0) d = -d;
                            amean += a [o];
                            c [o] = (byte)d;
                            cmean += d;
                            v += d * d;
                        }
                        if (C.HasAlpha)
                            c [oa + n*anc + anc-1] = 255;
                    }
                }
                amean /= (double)A.Height * A.Width * A.NChannels;
                cmean /= (double)C.Height * C.Width * C.NChannels;

                double scale = Math.Max(1, 32.0/cmean);
                // Compute R2 denominator sum from 'a', and normalize 'c'
                for (int y=0; y<A.Height; ++y) {
                    int o = y * A.Rowstride; // C is a copy of A and thus have the same Rowstride.
                    for (int x=0; x<anc*w; ++x) {
                        double d = a[o+x] - amean;
                        asum += d*d;
                        c[o+x] = (byte)Math.Min (255.0, c[o+x]*scale);
                    }
                }
            }

            r2 = 1 - v/asum;
            diffstring += r2.ToString("G");

            return C;
        }
开发者ID:gustafsson,项目名称:imgdiff,代码行数:86,代码来源:PixbufDiff.cs


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