Beispiel #1
0
        private void UpdateImage()
        {
            if (bmp.Handle != IntPtr.Zero) //以下代码将原始图像数据用来进行图像!
            {
                Win32Api.CopyMemory((IntPtr)bmp.Pointer, (IntPtr)DataCopy, bmp.Stride * bmp.Height);
            }
            switch (method)
            {
            case "Bin":
                AdjustEffect.Bin(bmp, (int)trbValue.Value);
                break;

            case "Gama":
                AdjustEffect.Gama(bmp, (int)trbValue.Value);
                break;

            case "FilmStyle":
                AdjustEffect.FilmStyle(bmp, (int)trbValue.Value);
                break;
            }
            Graphics G   = canvas.CreateGraphics();
            IntPtr   Hdc = G.GetHdc();

            bmp.DrawImage(Hdc, 0, 0, canvas.Width, canvas.Height, 0, 0, bmp.Width, bmp.Height);
            G.ReleaseHdc();
            G.Dispose();
            canvas.Invalidate();
        }
        /// <summary>
        ///     Implements the Apply code for the Brightness Filet
        /// </summary>
        /// <param name="graphics"></param>
        /// <param name="applyBitmap"></param>
        /// <param name="rect"></param>
        /// <param name="renderMode"></param>
        public override void Apply(Graphics graphics, Bitmap applyBitmap, NativeRect rect, RenderMode renderMode)
        {
            var applyRect = BitmapHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert);

            if (applyRect.Width == 0 || applyRect.Height == 0)
            {
                // nothing to do
                return;
            }

            var state = graphics.Save();

            if (Invert)
            {
                graphics.SetClip(applyRect);
                graphics.ExcludeClip(rect);
            }
            var brightness = GetFieldValueAsFloat(FieldType.BRIGHTNESS);

            using (var ia = AdjustEffect.CreateAdjustAttributes(brightness, 1f, 1f))
            {
                graphics.DrawImage(applyBitmap, applyRect, applyRect.X, applyRect.Y, applyRect.Width, applyRect.Height, GraphicsUnit.Pixel, ia);
            }
            graphics.Restore(state);
        }
Beispiel #3
0
        private void EffectInvert_Click(object sender, EventArgs e)
        {
            Stopwatch Sw = new Stopwatch();

            Sw.Start();
            AdjustEffect.Invert(bmp);
            Sw.Stop();
            this.Text = Sw.ElapsedMilliseconds.ToString();
            this.Canvas.Invalidate();
        }