Example #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)
            {
                Gdk.Pixbuf input_copy = (Gdk.Pixbuf)Input.Clone();
                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_copy);
                alpha.Dispose();
                final.Dispose();
                final = input_copy;
            }
            else
            {
                Cms.Transform transform = new Cms.Transform(list,
                                                            PixbufUtils.PixbufCmsFormat(Input),
                                                            PixbufUtils.PixbufCmsFormat(final),
                                                            intent, 0x0000);

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

            return(final);
        }
        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
        }
		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
		}
Example #4
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 ();
	}
Example #5
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) {
                Gdk.Pixbuf input_copy = (Gdk.Pixbuf)Input.Clone ();
                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_copy);
                alpha.Dispose ();
                final.Dispose ();
                final = input_copy;
            } else {
                Cms.Transform transform = new Cms.Transform (list,
                                         PixbufUtils.PixbufCmsFormat (Input),
                                         PixbufUtils.PixbufCmsFormat (final),
                                         intent, 0x0000);

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

            return final;
        }