Exemplo n.º 1
0
        private void BlendModeCallback(TINYIMAGE_BLENDMODE mode, double opacity, TINYIMAGE_CHANNEL channel, bool invert)
        {
            try
            {
                m_editBitmap.Dispose();
                m_editBitmap = GetEditBitmap();
                Bitmap blendBitmap = (Bitmap)m_editBitmap.Clone();
                if (invert)
                {
                    InvertBitmap(blendBitmap);
                }

                BitmapData bitmapData = m_editBitmap.LockBits(new Rectangle(0, 0, m_editBitmap.Width, m_editBitmap.Height),
                                                              ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);

                BitmapData blendBitmapData = blendBitmap.LockBits(new Rectangle(0, 0, blendBitmap.Width, blendBitmap.Height),
                                                                  ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);


                NativeMethods.BlendMode(bitmapData.Scan0, bitmapData.Width, bitmapData.Height, bitmapData.Stride, m_bpp, TINYIMAGE_CHANNEL.TINYIMAGE_CHANEL_RGB,
                                        blendBitmapData.Scan0, blendBitmapData.Width, blendBitmapData.Height, blendBitmapData.Stride, m_bpp, channel,
                                        mode, opacity);

                blendBitmap.UnlockBits(blendBitmapData);
                m_editBitmap.UnlockBits(bitmapData);
                blendBitmap.Dispose();
                PictureBox.Image = m_editBitmap;
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
Exemplo n.º 2
0
        private void BlendMenuItem_Click(object sender, EventArgs e)
        {
            if (m_bitmap == null)
            {
                return;
            }
            GenerateThumbBitmap();
            BlendForm    form   = new BlendForm(BlendModeCallback);
            DialogResult result = form.ShowDialog();

            if (result == DialogResult.OK)
            {
                bool invert = form.Invert;
                TINYIMAGE_CHANNEL   channel = form.Channel;
                TINYIMAGE_BLENDMODE mode    = form.BlendMode;
                double blendOpacity         = form.BlendOpacity;

                StartImageProcess();
                try
                {
                    Bitmap blendBitmap = (Bitmap)m_bitmap.Clone();
                    if (invert)
                    {
                        InvertBitmap(blendBitmap);
                    }
                    BitmapData bitmapData = m_bitmap.LockBits(new Rectangle(0, 0, m_bitmap.Width, m_bitmap.Height),
                                                              ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
                    BitmapData blendBitmapData = blendBitmap.LockBits(new Rectangle(0, 0, blendBitmap.Width, blendBitmap.Height),
                                                                      ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);

                    NativeMethods.BlendMode(bitmapData.Scan0, bitmapData.Width, bitmapData.Height, bitmapData.Stride, m_bpp, TINYIMAGE_CHANNEL.TINYIMAGE_CHANEL_RGB,
                                            blendBitmapData.Scan0, blendBitmapData.Width, blendBitmapData.Height, blendBitmapData.Stride, m_bpp, channel,
                                            mode, blendOpacity);
                    blendBitmap.UnlockBits(blendBitmapData);
                    m_bitmap.UnlockBits(bitmapData);
                    blendBitmap.Dispose();
                }
                catch (System.Exception ex)
                {
                    Console.WriteLine(ex.Source.ToString());
                }
                EndImageProcess();
            }
            else
            {
                PictureBox.Image = m_bitmap;
            }
        }
Exemplo n.º 3
0
 private void AdjustLevelCallback(int black, int white, double gamma, TINYIMAGE_CHANNEL channel)
 {
     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.AdjustLevels(bitmapData.Scan0, bitmapData.Width, bitmapData.Height, bitmapData.Stride, m_bpp,
                                    black, white, gamma, channel);
         m_editBitmap.UnlockBits(bitmapData);
         PictureBox.Image = m_editBitmap;
     }
     catch (System.Exception ex)
     {
         Console.WriteLine(ex.ToString());
     }
 }
Exemplo n.º 4
0
        private void AdjustLevelMenuItem_Click(object sender, EventArgs e)
        {
            if (m_bitmap == null)
            {
                return;
            }
            GenerateThumbBitmap();
            LevelsForm   form   = new LevelsForm(AdjustLevelCallback);
            DialogResult result = form.ShowDialog();

            if (result == DialogResult.OK)
            {
                int               blackThreshold = form.BlackThreshold;
                int               whiteThreshold = form.WhiteThreshold;
                double            gamma          = form.Gamma;
                TINYIMAGE_CHANNEL channel        = form.Channel;

                StartImageProcess();
                try
                {
                    BitmapData bitmapData = m_bitmap.LockBits(new Rectangle(0, 0, m_bitmap.Width, m_bitmap.Height),
                                                              ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
                    NativeMethods.AdjustLevels(bitmapData.Scan0, bitmapData.Width, bitmapData.Height, bitmapData.Stride, m_bpp,
                                               blackThreshold, whiteThreshold, gamma, channel);
                    m_bitmap.UnlockBits(bitmapData);
                }
                catch (System.Exception ex)
                {
                    Console.WriteLine(ex.Source.ToString());
                }
                EndImageProcess();
            }
            else
            {
                PictureBox.Image = m_bitmap;
            }
        }
Exemplo n.º 5
0
 public static extern void       AdjustLevels(IntPtr buf, int width, int height, int stride, int bpp,
                                              int blackThreshold, int whiteThreshold, double gamma, TINYIMAGE_CHANNEL channel);
Exemplo n.º 6
0
 public static extern void BlendMode(IntPtr buf, int width, int height, int stride, int bpp, TINYIMAGE_CHANNEL srcChannel,
                                     IntPtr blendBuf, int blendWidth, int blendHeight, int blendStride, int blendBpp, TINYIMAGE_CHANNEL blendChannel,
                                     TINYIMAGE_BLENDMODE mode, double opacity);
Exemplo n.º 7
0
 private void ChannelBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     m_channel = (TINYIMAGE_CHANNEL)ChannelBox.SelectedIndex;
     AdjustLevels();
 }
Exemplo n.º 8
0
 private void ChannelCombox_SelectedIndexChanged(object sender, EventArgs e)
 {
     m_channel = (TINYIMAGE_CHANNEL)ChannelCombox.SelectedIndex;
     RaiseBlendEvent();
 }