private void RaiseBalanceColorEvent() { if (m_callback != null) { int cyan = m_red; int magenta = m_green; int yellow = m_blue; TINYIMAGE_TRANSFERMODE mode = m_mode; bool preserveLuminosity = m_preserveLuminosity; m_callback(cyan, magenta, yellow, mode, preserveLuminosity); } }
private void ColorBalanceCallBack(int cyan, int magenta, int yellow, TINYIMAGE_TRANSFERMODE mode, bool preserveLuminosity) { 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.BalanceColor(bitmapData.Scan0, bitmapData.Width, bitmapData.Height, bitmapData.Stride, m_bpp, cyan, magenta, yellow, mode, preserveLuminosity); m_editBitmap.UnlockBits(bitmapData); PictureBox.Image = m_editBitmap; } catch (System.Exception ex) { Console.WriteLine(ex.ToString()); } }
private void ColorMenuItem_Click(object sender, EventArgs e) { if (m_bitmap == null) { return; } GenerateThumbBitmap(); ColorBalanceForm form = new ColorBalanceForm(ColorBalanceCallBack); DialogResult result = form.ShowDialog(); if (result == DialogResult.OK) { int red = form.Red; int green = form.Green; int blue = form.Blue; TINYIMAGE_TRANSFERMODE mode = form.TransferMode; bool preserveLuminosity = form.PreserveLuminosity; StartImageProcess(); try { BitmapData bitmapData = m_bitmap.LockBits(new Rectangle(0, 0, m_bitmap.Width, m_bitmap.Height), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb); NativeMethods.BalanceColor(bitmapData.Scan0, bitmapData.Width, bitmapData.Height, bitmapData.Stride, m_bpp, red, green, blue, mode, preserveLuminosity); m_bitmap.UnlockBits(bitmapData); } catch (System.Exception ex) { Console.WriteLine(ex.Source.ToString()); } EndImageProcess(); } else { PictureBox.Image = m_bitmap; } }
public static extern void BalanceColor(IntPtr buf, int width, int height, int stride, int bpp, int cyan, int magenta, int yellow, TINYIMAGE_TRANSFERMODE mode, bool preserveLuminosity);
private void ShadowRadioButton_CheckedChanged(object sender, EventArgs e) { m_mode = TINYIMAGE_TRANSFERMODE.TINYIMAGE_TRANSFERMODE_SHADOWS; ResetSliders(); }
private void HighLightenRatioButton_CheckedChanged(object sender, EventArgs e) { m_mode = TINYIMAGE_TRANSFERMODE.TINYIMAGE_TRANSFERMODE_HIGHLIGHTS; ResetSliders(); }
private void MidtoneRadioButton_CheckedChanged(object sender, EventArgs e) { m_mode = TINYIMAGE_TRANSFERMODE.TINYIMAGE_TRANSFERMODE_MIDTONES; ResetSliders(); }