Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        private Pixbuf ProcessImpl(Pixbuf input, Cms.Profile input_profile, bool fast)
        {
            Pixbuf result;

            using (ImageInfo info = new ImageInfo(input)) {
                MemorySurface surface = new MemorySurface(Format.Argb32,
                                                          input.Width,
                                                          input.Height);

                Context ctx = new Context(surface);
                ctx.Matrix = info.Fill(info.Bounds, angle);
                SurfacePattern p = new SurfacePattern(info.Surface);
                if (fast)
                {
                    p.Filter = Filter.Fast;
                }
                ctx.Source = p;
                ctx.Paint();
                ((IDisposable)ctx).Dispose();
                p.Destroy();
                result = MemorySurface.CreatePixbuf(surface);
                surface.Flush();
            }
            return(result);
        }
Exemplo n.º 3
0
        private Pixbuf ProcessImpl(Pixbuf input, Cms.Profile input_profile, bool fast)
        {
            Pixbuf result;

            using (ImageInfo info = new ImageInfo(input)) {
                using (ImageSurface surface = new ImageSurface(Format.Argb32,
                                                               input.Width,
                                                               input.Height)) {
                    using (Context ctx = new Context(surface)) {
                        ctx.Matrix = info.Fill(info.Bounds, angle);
                        using (SurfacePattern p = new SurfacePattern(info.Surface)) {
                            if (fast)
                            {
                                p.Filter = Filter.Fast;
                            }
                            ctx.Source = p;
                            ctx.Paint();
                        }
                        result = surface.ToPixbuf();
                        surface.Flush();
                    }
                }
            }
            return(result);
        }
Exemplo n.º 4
0
 protected void LoadPhoto(Photo photo, out Pixbuf photo_pixbuf, out Cms.Profile photo_profile)
 {
     // FIXME: We might get this value from the PhotoImageView.
     using (ImageFile img = ImageFile.Create(photo.DefaultVersionUri)) {
         photo_pixbuf  = img.Load();
         photo_profile = img.GetProfile();
     }
 }
Exemplo n.º 5
0
 protected void LoadPhoto(Photo photo, out Pixbuf photo_pixbuf, out Cms.Profile photo_profile)
 {
     // FIXME: We might get this value from the PhotoImageView.
     using (var img = App.Instance.Container.Resolve <IImageFileFactory> ().Create(photo.DefaultVersion.Uri)) {
         photo_pixbuf  = img.Load();
         photo_profile = img.GetProfile();
     }
 }
Exemplo n.º 6
0
        protected override Pixbuf Process(Pixbuf input, Cms.Profile input_profile)
        {
            Gdk.Rectangle area = new Gdk.Rectangle(State.Selection.x, State.Selection.y,
                                                   State.Selection.width, State.Selection.height);
            int threshold = Preferences.Get <int> (Preferences.EDIT_REDEYE_THRESHOLD);

            return(PixbufUtils.RemoveRedeye(input, area, threshold));
        }
Exemplo n.º 7
0
        protected override Pixbuf Process(Pixbuf input, Cms.Profile input_profile)
        {
            Rectangle selection = FSpot.Utils.PixbufUtils.TransformOrientation((int)State.PhotoImageView.PixbufOrientation <= 4 ? input.Width : input.Height,
                                                                               (int)State.PhotoImageView.PixbufOrientation <= 4 ? input.Height : input.Width,
                                                                               State.Selection, State.PhotoImageView.PixbufOrientation);
            int threshold = Preferences.Get <int> (Preferences.EDIT_REDEYE_THRESHOLD);

            return(PixbufUtils.RemoveRedeye(input, selection, threshold));
        }
Exemplo n.º 8
0
 public static void SetScreenProfile(Screen screen, Cms.Profile profile)
 {
     byte [] data = profile.Save();
     ChangeProperty(screen.RootWindow,
                    Atom.Intern("_ICC_PROFILE", false),
                    Atom.Intern("CARDINAL", false),
                    PropMode.Replace,
                    data);
 }
        public override Gdk.Pixbuf ToPixbuf(Cms.Profile destination_profile)
        {
#if true //USE_LCMS
            profile = Cms.Profile.CreateStandardRgb();
            Cms.Profile [] list   = new Cms.Profile [] { profile, destination_profile };
            Gdk.Pixbuf     pixbuf = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, false, 8,
                                                   width, height);

            Cms.Transform t = new Cms.Transform(list,
                                                Cms.Format.Rgb16,
                                                PixbufUtils.PixbufCmsFormat(pixbuf),
                                                Cms.Intent.Perceptual, 0x0);

            unsafe
            {
                fixed(ushort *srcpix = &data[0])
                {
                    byte *destpix = (byte *)pixbuf.Pixels;

                    for (int row = 0; row < height; row++)
                    {
                        t.Apply((IntPtr)(srcpix + row * rowstride),
                                (IntPtr)(destpix + row * pixbuf.Rowstride),
                                (uint)width);
                    }
                }
            }

            return(pixbuf);
#else
            Gdk.Pixbuf pixbuf = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, false, 8,
                                               width, height);

            unsafe
            {
                fixed(ushort *src = &data[0])
                {
                    ushort *srcpix  = src;
                    byte *  destpix = (byte *)pixbuf.Pixels;

                    for (int row = 0; row < height; row++)
                    {
                        for (int col = 0; col < width * nchannels; col++)
                        {
                            destpix [col] = (byte)(srcpix [col] >> 8);
                        }

                        srcpix  += rowstride;
                        destpix += pixbuf.Rowstride;
                    }
                }
            }

            return(pixbuf);
#endif
        }
Exemplo n.º 10
0
		protected override Pixbuf Process (Pixbuf input, Cms.Profile input_profile)
		{
			Rectangle selection = Utils.PixbufUtils.TransformOrientation ((int)State.PhotoImageView.PixbufOrientation <= 4 ? input.Width : input.Height,
												(int)State.PhotoImageView.PixbufOrientation <= 4 ? input.Height : input.Width,
												State.Selection, State.PhotoImageView.PixbufOrientation);
			var edited = new Pixbuf (input.Colorspace, input.HasAlpha, input.BitsPerSample, selection.Width, selection.Height);

			input.CopyArea (selection.X, selection.Y, selection.Width, selection.Height, edited, 0, 0);
			return edited;
		}
Exemplo n.º 11
0
        protected override Pixbuf Process(Pixbuf input, Cms.Profile input_profile)
        {
            Pixbuf edited = new Pixbuf(input.Colorspace,
                                       input.HasAlpha, input.BitsPerSample,
                                       State.Selection.width, State.Selection.height);

            input.CopyArea(State.Selection.x, State.Selection.y,
                           State.Selection.width, State.Selection.height, edited, 0, 0);
            return(edited);
        }
Exemplo n.º 12
0
        protected override Pixbuf Process(Pixbuf input, Cms.Profile input_profile)
        {
            Pixbuf output = input.Copy();

            Pixbuf sub = new Pixbuf(output, State.Selection.X, State.Selection.Y,
                                    State.Selection.Width, State.Selection.Height);

            sub.Fill(0x00000000);
            return(output);
        }
Exemplo n.º 13
0
 public FullColorAdjustment(Pixbuf input, Cms.Profile input_profile, double exposure, double brightness, double contrast,
                            double hue, double saturation, Cms.ColorCIEXYZ src_wp, Cms.ColorCIEXYZ dest_wp) : base(input, input_profile)
 {
     this.exposure   = exposure;
     this.brightness = brightness;
     this.contrast   = contrast;
     this.hue        = hue;
     this.saturation = saturation;
     this.src_wp     = src_wp;
     this.dest_wp    = dest_wp;
 }
Exemplo n.º 14
0
/*		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);
        }
Exemplo n.º 15
0
        protected override Pixbuf Process(Pixbuf input, Cms.Profile input_profile)
        {
            Pixbuf output = input.Copy();

            Pixbuf sub = new Pixbuf(output, State.Selection.X, State.Selection.Y,
                                    State.Selection.Width, State.Selection.Height);
            /* lazy man's pixelate: scale down and then back up */
            Pixbuf down = sub.ScaleSimple(State.Selection.Width / 75, State.Selection.Height / 75,
                                          InterpType.Nearest);
            Pixbuf up = down.ScaleSimple(State.Selection.Width, State.Selection.Height,
                                         InterpType.Nearest);

            up.CopyArea(0, 0, State.Selection.Width, State.Selection.Height, sub, 0, 0);
            return(output);
        }
Exemplo n.º 16
0
        protected override Pixbuf Process(Pixbuf input, Cms.Profile input_profile)
        {
            Cms.ColorCIEXYZ src_wp;
            Cms.ColorCIEXYZ dest_wp;

            src_wp  = Cms.ColorCIExyY.WhitePointFromTemperature(5000).ToXYZ();
            dest_wp = Cms.ColorCIExyY.WhitePointFromTemperature((int)temp_scale.Value).ToXYZ();
            Cms.ColorCIELab dest_lab = dest_wp.ToLab(src_wp);
            dest_lab.a += temptint_scale.Value;
            dest_wp     = dest_lab.ToXYZ(src_wp);

            FullColorAdjustment adjust = new FullColorAdjustment(input, input_profile,
                                                                 exposure_scale.Value, brightness_scale.Value, contrast_scale.Value,
                                                                 hue_scale.Value, sat_scale.Value, src_wp, dest_wp);

            return(adjust.Adjust());
        }
Exemplo n.º 17
0
 public static void ProfileNameDataFunc(CellLayout layout, CellRenderer renderer, TreeModel model, TreeIter iter)
 {
     if (model.GetValue(iter, 0) != null)
     {
         Cms.Profile profile = (Cms.Profile)model.GetValue(iter, 0);
         if (profile.ProductName.Length < NameLenth)
         {
             (renderer as Gtk.CellRendererText).Text = profile.ProductName;
         }
         else
         {
             (renderer as Gtk.CellRendererText).Text = profile.ProductName.Substring(0, NameLenth) + "...";
         }
     }
     else
     {
         (renderer as Gtk.CellRendererText).Text = "";
     }
 }
Exemplo n.º 18
0
        Pixbuf ProcessImpl(Pixbuf input, Cms.Profile inputProfile, bool fast)
        {
            Pixbuf result;

            using (var info = new ImageInfo(input)) {
                using (var soft = new SoftFocus(info)) {
                    soft.Radius = radius;

                    using (var surface = new ImageSurface(Format.Argb32, input.Width, input.Height)) {
                        using (var ctx = new Context(surface)) {
                            soft.Apply(ctx, info.Bounds);
                        }

                        result = surface.ToPixbuf();
                        surface.Flush();
                    }
                }
            }
            return(result);
        }
Exemplo n.º 19
0
        private Pixbuf ProcessImpl(Pixbuf input, Cms.Profile input_profile, bool fast)
        {
            Pixbuf result;

            using (ImageInfo info = new ImageInfo(input)) {
                Widgets.SoftFocus soft = new Widgets.SoftFocus(info);
                soft.Radius = radius;

                MemorySurface surface = new MemorySurface(Format.Argb32,
                                                          input.Width,
                                                          input.Height);

                Context ctx = new Context(surface);
                soft.Apply(ctx, info.Bounds);
                ((IDisposable)ctx).Dispose();

                result = MemorySurface.CreatePixbuf(surface);
                surface.Flush();
            }
            return(result);
        }
Exemplo n.º 20
0
        public UInt16Buffer(Gdk.Pixbuf pixbuf, Cms.Profile profile)
        {
            this.profile   = profile;
            width          = pixbuf.Width;
            height         = pixbuf.Height;
            this.nchannels = pixbuf.HasAlpha ? 4 : 3;

            depth = PixelBufferDepth.UInt16;

            data = new ushort [width * height * nchannels];

            unsafe {
                byte *src_pixels = (byte *)pixbuf.Pixels;
                int   src_stride = pixbuf.Rowstride;
                int   count      = pixbuf.Width * nchannels;

                for (int row = 0; row < height; row++)
                {
                    Fill8(row, 0, src_pixels, row * src_stride, count);
                }
            }
        }
Exemplo n.º 21
0
        protected override Pixbuf Process(Pixbuf input, Cms.Profile input_profile)
        {
            SepiaTone sepia = new SepiaTone(input, input_profile);

            return(sepia.Adjust());
        }
Exemplo n.º 22
0
	public static unsafe void ColorAdjust (Pixbuf src, Pixbuf dest, 
					       double brightness, double contrast,
					       double hue, double saturation, 
					       int src_color, int dest_color)
	{
		if (src.Width != dest.Width || src.Height != dest.Height)
			throw new Exception ("Invalid Dimensions");

		//Cms.Profile eos10d = new Cms.Profile ("/home/lewing/ICCProfiles/EOS-10D-True-Color-Non-Linear.icm");
		Cms.Profile srgb = Cms.Profile.CreateStandardRgb ();

		Cms.Profile bchsw = Cms.Profile.CreateAbstract (256, 
								0.0, 
								brightness, contrast,
								hue, saturation, src_color, 
								dest_color);

		Cms.Profile [] list = new Cms.Profile [] { srgb, bchsw, srgb };
		Cms.Transform trans = new Cms.Transform (list, 
							 PixbufCmsFormat (src),
							 PixbufCmsFormat (dest),
							 Cms.Intent.Perceptual, 0x0100);

		ColorAdjust (src, dest, trans);

		trans.Dispose ();
		srgb.Dispose ();
		bchsw.Dispose ();
	}
Exemplo n.º 23
0
 protected abstract Pixbuf Process(Pixbuf input, Cms.Profile input_profile);
Exemplo n.º 24
0
 protected override Pixbuf ProcessFast(Pixbuf input, Cms.Profile input_profile)
 {
     return(ProcessImpl(input, input_profile, true));
 }
Exemplo n.º 25
0
 protected Adjustment(Pixbuf input, Cms.Profile input_profile)
 {
     Input        = input;
     InputProfile = input_profile;
 }
Exemplo n.º 26
0
 protected override Pixbuf Process(Pixbuf input, Cms.Profile input_profile)
 {
     return(ProcessImpl(input, input_profile, false));
 }
Exemplo n.º 27
0
        protected override Pixbuf Process(Pixbuf input, Cms.Profile input_profile)
        {
            Desaturate desaturate = new Desaturate(input, input_profile);

            return(desaturate.Adjust());
        }
Exemplo n.º 28
0
        protected override Pixbuf Process(Pixbuf input, Cms.Profile input_profile)
        {
            Pixbuf output = (Pixbuf)input.Clone();

            return(output.Flip(true));
        }
Exemplo n.º 29
0
        protected override Pixbuf Process(Pixbuf input, Cms.Profile input_profile)
        {
            AutoStretch autostretch = new AutoStretch(input, input_profile);

            return(autostretch.Adjust());
        }
Exemplo n.º 30
0
 public Adjustment(Pixbuf input, Cms.Profile input_profile)
 {
     Input        = input;
     InputProfile = input_profile;
 }
Exemplo n.º 31
0
		public override Gdk.Pixbuf ToPixbuf (Cms.Profile destination_profile)
		{
#if true //USE_LCMS
			profile = Cms.Profile.CreateStandardRgb ();
			Cms.Profile [] list = new Cms.Profile [] { profile, destination_profile };
			Gdk.Pixbuf pixbuf = new Gdk.Pixbuf (Gdk.Colorspace.Rgb, false, 8, 
							    width, height);
			
			Cms.Transform t = new Cms.Transform (list,
							     Cms.Format.Rgb16,
							     PixbufUtils.PixbufCmsFormat (pixbuf),
							     Cms.Intent.Perceptual, 0x0);
			
			unsafe {
				fixed (ushort * srcpix  = &data[0]) {
					byte * destpix = (byte *) pixbuf.Pixels;
					
					for (int row = 0; row < height; row++)
						t.Apply ((IntPtr) (srcpix + row * rowstride),
							 (IntPtr) (destpix + row * pixbuf.Rowstride),
							 (uint)width);
				}
			}

			return pixbuf;
#else
			Gdk.Pixbuf pixbuf = new Gdk.Pixbuf (Gdk.Colorspace.Rgb, false, 8, 
							    width, height);

			unsafe {
				fixed (ushort * src  = &data[0]) {
					ushort * srcpix = src;
					byte * destpix = (byte *) pixbuf.Pixels;
					
					for (int row = 0; row < height; row++) {
						for (int col = 0; col < width * nchannels; col++)
							destpix [col] = (byte) (srcpix [col] >> 8);
						
						srcpix += rowstride;
						destpix += pixbuf.Rowstride;
					}
				}
			}

			return pixbuf;
#endif
		}
Exemplo n.º 32
0
 protected virtual Pixbuf ProcessFast(Pixbuf input, Cms.Profile input_profile)
 {
     return(Process(input, input_profile));
 }