Example #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());
            }
        }
Example #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;
            }
        }
Example #3
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);
Example #4
0
 private void ModeCombox_SelectedIndexChanged(object sender, EventArgs e)
 {
     m_blendMode = (TINYIMAGE_BLENDMODE)ModeCombox.SelectedIndex;
     RaiseBlendEvent();
 }