Exemple #1
0
        private void HueSaturationMenuItem_Click(object sender, EventArgs e)
        {
            if (m_bitmap == null)
            {
                return;
            }
            GenerateThumbBitmap();
            HueSaturationForm form   = new HueSaturationForm(AdjustHueSaturationCallBack);
            DialogResult      result = form.ShowDialog();

            if (result == DialogResult.OK)
            {
                int hue        = form.Hue;
                int saturation = form.Saturation;
                int lightness  = form.Lightness;
                TINYIMAGE_HUERANGE hueRange = form.HueRange;
                StartImageProcess();
                try
                {
                    BitmapData bitmapData = m_bitmap.LockBits(new Rectangle(0, 0, m_bitmap.Width, m_bitmap.Height),
                                                              ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
                    NativeMethods.AdjustHueSaturation(bitmapData.Scan0, bitmapData.Width, bitmapData.Height, bitmapData.Stride, m_bpp,
                                                      hue, saturation, lightness, hueRange);
                    m_bitmap.UnlockBits(bitmapData);
                }
                catch (System.Exception ex)
                {
                    Console.WriteLine(ex.Source.ToString());
                }
                EndImageProcess();
            }
            else
            {
                PictureBox.Image = m_bitmap;
            }
        }
Exemple #2
0
 private void AdjustHueSaturationCallBack(int hue, int saturation, int lightness, TINYIMAGE_HUERANGE hueRange)
 {
     try
     {
         m_editBitmap.Dispose();
         m_editBitmap = GetEditBitmap();
         BitmapData bitmapData = m_editBitmap.LockBits(new Rectangle(0, 0, m_editBitmap.Width, m_editBitmap.Height),
                                                       ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
         NativeMethods.AdjustHueSaturation(bitmapData.Scan0, bitmapData.Width, bitmapData.Height, bitmapData.Stride, m_bpp,
                                           hue, saturation, lightness, hueRange);
         m_editBitmap.UnlockBits(bitmapData);
         PictureBox.Image = m_editBitmap;
     }
     catch (System.Exception ex)
     {
         Console.WriteLine(ex.ToString());
     }
 }
Exemple #3
0
 public static extern void AdjustHueSaturation(IntPtr buf, int width, int height, int stride, int bpp,
                                               int hue, int saturation, int lightness, TINYIMAGE_HUERANGE hueRange);
 private void HueRangeCombox_SelectedIndexChanged(object sender, EventArgs e)
 {
     m_hueRange = (TINYIMAGE_HUERANGE)HueRangeCombox.SelectedIndex;
     AdjustHueSaturation();
 }