PixbufCmsFormat() public static method

public static PixbufCmsFormat ( Pixbuf buf ) : FSpot.Cms.Format
buf Pixbuf
return FSpot.Cms.Format
コード例 #1
0
        public Pixbuf Adjust()
        {
            Gdk.Pixbuf final = new Gdk.Pixbuf(Gdk.Colorspace.Rgb,
                                              false, 8,
                                              Input.Width,
                                              Input.Height);
            Cms.Profile [] list = GenerateAdjustments().ToArray();

            if (Input.HasAlpha)
            {
                Pixbuf    alpha     = PixbufUtils.Flatten(Input);
                Transform transform = new Transform(list,
                                                    PixbufUtils.PixbufCmsFormat(alpha),
                                                    PixbufUtils.PixbufCmsFormat(final),
                                                    intent, 0x0000);
                PixbufUtils.ColorAdjust(alpha, final, transform);
                PixbufUtils.ReplaceColor(final, Input);
                alpha.Dispose();
                final.Dispose();
                final = Input;
            }
            else
            {
                Cms.Transform transform = new Cms.Transform(list,
                                                            PixbufUtils.PixbufCmsFormat(Input),
                                                            PixbufUtils.PixbufCmsFormat(final),
                                                            intent, 0x0000);

                PixbufUtils.ColorAdjust(Input, final, transform);
            }

            return(final);
        }
コード例 #2
0
        public Pixbuf Adjust()
        {
            var final = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, false, 8, Input.Width, Input.Height);

            Profile[] list = GenerateAdjustments().ToArray();

            if (Input.HasAlpha)
            {
                var inputCopy = (Gdk.Pixbuf)Input.Clone();
                var alpha     = PixbufUtils.Flatten(Input);
                var transform = new Transform(list, PixbufUtils.PixbufCmsFormat(alpha), PixbufUtils.PixbufCmsFormat(final), intent, 0x0000);
                PixbufUtils.ColorAdjust(alpha, final, transform);
                PixbufUtils.ReplaceColor(final, inputCopy);
                alpha.Dispose();
                final.Dispose();
                final = inputCopy;
            }
            else
            {
                var transform = new Transform(list, PixbufUtils.PixbufCmsFormat(Input), PixbufUtils.PixbufCmsFormat(final), intent, 0x0000);

                PixbufUtils.ColorAdjust(Input, final, transform);
            }

            return(final);
        }
コード例 #3
0
        public bool Convert(FilterRequest req)
        {
            Uri source = req.Current;

            using (ImageFile img = ImageFile.Create(source)) {
                pixbuf  = img.Load();
                profile = img.GetProfile();

                // If the image doesn't have an embedded profile assume it is sRGB
                if (profile == null)
                {
                    profile = Profile.CreateStandardRgb();
                }

                if (destination == null)
                {
                    destination = profile;
                }

                Gdk.Pixbuf final = new Gdk.Pixbuf(Gdk.Colorspace.Rgb,
                                                  false, 8,
                                                  pixbuf.Width,
                                                  pixbuf.Height);

                Profile [] list = Prepare(pixbuf);

                if (pixbuf.HasAlpha)
                {
                    Gdk.Pixbuf alpha     = PixbufUtils.Flatten(pixbuf);
                    Transform  transform = new Transform(list,
                                                         PixbufUtils.PixbufCmsFormat(alpha),
                                                         PixbufUtils.PixbufCmsFormat(final),
                                                         rendering_intent, 0x0000);
                    PixbufUtils.ColorAdjust(alpha, final, transform);
                    PixbufUtils.ReplaceColor(final, pixbuf);
                    alpha.Dispose();
                    final.Dispose();
                    final = pixbuf;
                }
                else
                {
                    Transform transform = new Transform(list,
                                                        PixbufUtils.PixbufCmsFormat(pixbuf),
                                                        PixbufUtils.PixbufCmsFormat(final),
                                                        rendering_intent, 0x0000);
                    PixbufUtils.ColorAdjust(pixbuf, final, transform);
                    pixbuf.Dispose();
                }

                Uri dest_uri = req.TempUri(Path.GetExtension(source.LocalPath));
                using (Stream output = File.OpenWrite(dest_uri.LocalPath)) {
                    img.Save(final, output);
                }
                final.Dispose();
                req.Current = dest_uri;

                return(true);
            }
        }
コード例 #4
0
        private void Adjust()
        {
            if (brightness_scale == null)
            {
                return;
            }

            if (AdjustedPixbuf == null)
            {
                return;
            }

            Cms.Profile    display_profile = Cms.Profile.GetScreenProfile(view.Screen);
            Cms.Profile [] list;

            if (display_profile == null)
            {
                display_profile = Cms.Profile.CreateStandardRgb();
            }

            if (!Changed || AdjustedPixbuf.HasAlpha)
            {
                if (AdjustedPixbuf.HasAlpha)
                {
                    System.Console.WriteLine("Cannot currently adjust images with an alpha channel");
                }

                list = new Cms.Profile [] { image_profile, display_profile };

                next_transform = new Cms.Transform(list,
                                                   PixbufUtils.PixbufCmsFormat(AdjustedPixbuf),
                                                   PixbufUtils.PixbufCmsFormat(AdjustedPixbuf),
                                                   Cms.Intent.Perceptual, 0x0000);
            }
            else
            {
                using (adjustment_profile = AdjustmentProfile()) {
                    list = new Cms.Profile [] { image_profile, adjustment_profile, display_profile };

                    next_transform = new Cms.Transform(list,
                                                       PixbufUtils.PixbufCmsFormat(AdjustedPixbuf),
                                                       PixbufUtils.PixbufCmsFormat(AdjustedPixbuf),
                                                       Cms.Intent.Perceptual, 0x0000);
                }
            }

            lock (AdjustedPixbuf) {
                PixbufUtils.ColorAdjust(ScaledPixbuf,
                                        AdjustedPixbuf,
                                        next_transform);
#if USE_THREAD
                expose_timeout.Start();
#else
                this.QueueDraw();
#endif
            }
        }
コード例 #5
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
        }
コード例 #6
0
        public static void ApplyProfile(Gdk.Pixbuf pixbuf, Profile imageProfile, Profile destinationProfile)
        {
            if (pixbuf == null || pixbuf.HasAlpha)
            {
                return;
            }

            imageProfile = imageProfile ?? Profile.CreateStandardRgb();

            Profile[] list      = { imageProfile, destinationProfile };
            var       transform = new Transform(list, PixbufUtils.PixbufCmsFormat(pixbuf), PixbufUtils.PixbufCmsFormat(pixbuf),
                                                Intent.Perceptual, 0x0000);

            PixbufUtils.ColorAdjust(pixbuf, pixbuf, transform);
        }
コード例 #7
0
//		public static void ApplyScreenProfile (Gdk.Pixbuf src, Gdk.Pixbuf dest)
//		{
//			PixbufUtils.ColorAdjust (src, dest, standart_transform);
//		}

        public static void ApplyPrinterProfile(Gdk.Pixbuf pixbuf, Cms.Profile image_profile)
        {
            if (IsEnabled && pixbuf != null && !pixbuf.HasAlpha)
            {
                if (image_profile == null)
                {
                    image_profile = Cms.Profile.CreateStandardRgb();
                }

                Cms.Profile [] list = new Cms.Profile [] { image_profile, destination_profile };

                Cms.Transform transform = new Cms.Transform(list,
                                                            PixbufUtils.PixbufCmsFormat(pixbuf),
                                                            PixbufUtils.PixbufCmsFormat(pixbuf),
                                                            Cms.Intent.Perceptual, 0x0000);
                PixbufUtils.ColorAdjust(pixbuf, pixbuf, transform);
            }
        }
コード例 #8
0
 //it works also but it uses the image_profile too
 public static void ApplyScreenProfile(Gdk.Pixbuf pixbuf, Cms.Profile image_profile)
 {
     if (IsEnabled && pixbuf != null && !pixbuf.HasAlpha)
     {
         if (image_profile == null)
         {
             ApplyScreenProfile(pixbuf);
         }
         else
         {
             Cms.Profile [] list      = new Cms.Profile [] { image_profile, display_profile };
             Cms.Transform  transform = new Cms.Transform(list,
                                                          PixbufUtils.PixbufCmsFormat(pixbuf),
                                                          PixbufUtils.PixbufCmsFormat(pixbuf),
                                                          Cms.Intent.Perceptual, 0x0000);
             PixbufUtils.ColorAdjust(pixbuf, pixbuf, transform);
         }
     }
 }
コード例 #9
0
        //this method create the Cms.Transform using image_profile and current screen profile
        public static Cms.Transform CreateTransform(Gdk.Pixbuf pixbuf, Cms.Profile image_profile)
        {
            if (IsEnabled && pixbuf != null)
            {
                if (image_profile == null)
                {
                    image_profile = Cms.Profile.CreateStandardRgb();
                }

                Cms.Profile [] list = new Cms.Profile [] { image_profile, display_profile };

                Cms.Transform transform = new Cms.Transform(list,
                                                            PixbufUtils.PixbufCmsFormat(pixbuf),
                                                            PixbufUtils.PixbufCmsFormat(pixbuf),
                                                            Cms.Intent.Perceptual, 0x0000);
                return(transform);
            }
            else
            {
                return(null);
            }
        }
コード例 #10
0
        public void Adjust()
        {
            bool create_version = photo.DefaultVersionId == Photo.OriginalVersionId;

            using (ImageFile img = ImageFile.Create(photo.DefaultVersionUri)) {
                if (image == null)
                {
                    image = img.Load();
                }

                if (image_profile == null)
                {
                    image_profile = img.GetProfile();
                }
            }

            if (image_profile == null)
            {
                image_profile = Cms.Profile.CreateStandardRgb();
            }

            if (destination_profile == null)
            {
                destination_profile = image_profile;
            }

            Gdk.Pixbuf final = new Gdk.Pixbuf(Gdk.Colorspace.Rgb,
                                              false, 8,
                                              image.Width,
                                              image.Height);

            Cms.Profile    adjustment_profile = GenerateProfile();
            Cms.Profile [] list;
            if (adjustment_profile != null)
            {
                list = new Cms.Profile [] { image_profile, adjustment_profile, destination_profile }
            }
            ;
            else
            {
                list = new Cms.Profile [] { image_profile, destination_profile }
            };

            if (image.HasAlpha)
            {
                Pixbuf    alpha     = PixbufUtils.Flatten(image);
                Transform transform = new Transform(list,
                                                    PixbufUtils.PixbufCmsFormat(alpha),
                                                    PixbufUtils.PixbufCmsFormat(final),
                                                    intent, 0x0000);
                PixbufUtils.ColorAdjust(alpha, final, transform);
                PixbufUtils.ReplaceColor(final, image);
                alpha.Dispose();
                final.Dispose();
                final = image;
            }
            else
            {
                Cms.Transform transform = new Cms.Transform(list,
                                                            PixbufUtils.PixbufCmsFormat(image),
                                                            PixbufUtils.PixbufCmsFormat(final),
                                                            intent, 0x0000);

                PixbufUtils.ColorAdjust(image, final, transform);
                image.Dispose();
            }

            photo.SaveVersion(final, create_version);
            final.Dispose();
        }
    }
コード例 #11
0
        public void Save()
        {
            if (!Changed)
            {
                this.Dialog.Destroy();
                return;
            }

            if (!view.Item.IsValid)
            {
                return;
            }

            Console.WriteLine("Saving....");

            Photo photo = (Photo)view.Item.Current;

            try {
                bool create_version = photo.DefaultVersionId == Photo.OriginalVersionId;

                Gdk.Pixbuf orig  = view.CompletePixbuf();
                Gdk.Pixbuf final = new Gdk.Pixbuf(Gdk.Colorspace.Rgb,
                                                  false, 8,
                                                  orig.Width,
                                                  orig.Height);

                Cms.Profile abs = AdjustmentProfile();

                // FIXME this shouldn't use the screen as the destination profile.
                Cms.Profile destination = Cms.Profile.GetScreenProfile(view.Screen);
                if (destination == null)
                {
                    destination = Cms.Profile.CreateStandardRgb();
                }

                Cms.Profile [] list      = new Cms.Profile [] { image_profile, abs, destination };
                Cms.Transform  transform = new Cms.Transform(list,
                                                             PixbufUtils.PixbufCmsFormat(orig),
                                                             PixbufUtils.PixbufCmsFormat(final),
                                                             Cms.Intent.Perceptual, 0x0000);

                PixbufUtils.ColorAdjust(orig,
                                        final,
                                        transform);

                photo.SaveVersion(final, create_version);
                ((PhotoQuery)view.Query).Commit(view.Item.Index);
                final.Dispose();
            } catch (System.Exception e) {
                string msg  = Catalog.GetString("Error saving adjusted photo");
                string desc = String.Format(Catalog.GetString("Received exception \"{0}\". Unable to save photo {1}"),
                                            e.Message, photo.Name);

                HigMessageDialog md = new HigMessageDialog((Gtk.Window)Dialog.Toplevel,
                                                           DialogFlags.DestroyWithParent,
                                                           Gtk.MessageType.Error, ButtonsType.Ok,
                                                           msg,
                                                           desc);
                md.Run();
                md.Destroy();
            }

            this.Dialog.Sensitive = false;
            this.Dialog.Destroy();
        }