Example #1
0
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            if (_lmvMyCallback != null && _lmvMyCallback.Image != null)
            {
                LeadRect destRect = LeadRect.Create(0, 0, this.ClientSize.Width, this.ClientSize.Height);

                using (RasterImage destImage = new RasterImage(RasterMemoryFlags.Conventional, this.ClientSize.Width, this.ClientSize.Height,
                                                               _lmvMyCallback.Image.BitsPerPixel, _lmvMyCallback.Image.Order, _lmvMyCallback.Image.ViewPerspective,
                                                               _lmvMyCallback.Image.GetPalette(), IntPtr.Zero, 0))
                {
                    // Resize the source image into the destination image
                    ResizeCommand command = new ResizeCommand();
                    command.DestinationImage = destImage;
                    command.Flags            = RasterSizeFlags.Bicubic;
                    command.Run(_lmvMyCallback.Image);

                    destRect = RasterImage.CalculatePaintModeRectangle(destImage.ImageWidth, destImage.ImageHeight, destRect, RasterPaintSizeMode.FitAlways, RasterPaintAlignMode.Center, RasterPaintAlignMode.Center);
                    LeadRect destClipRect = LeadRect.Create(e.ClipRectangle.X, e.ClipRectangle.Y, e.ClipRectangle.Width, e.ClipRectangle.Height);

                    using (RasterGraphics rg = RasterImagePainter.CreateGraphics(destImage))
                    {
                        rg.Graphics.DrawRectangle(new Pen(Color.Red), _lmvMyCallback.GuideRect.X, _lmvMyCallback.GuideRect.Y, _lmvMyCallback.GuideRect.Width, _lmvMyCallback.GuideRect.Height);
                    }

                    RasterImagePainter.Paint(destImage, e.Graphics, LeadRect.Empty, LeadRect.Empty, destRect, destClipRect, RasterPaintProperties.Default);
                }
            }
        }
Example #2
0
        protected override void OnPaint(PaintEventArgs e)
        {
            try
            {
                Rectangle dstRect = DestinationRectangle;

                RasterImagePainter.Paint(
                    _image,
                    e.Graphics,
                    Converters.ConvertRect(SourceRectangle),
                    LeadRect.Empty,
                    Converters.ConvertRect(dstRect),
                    Converters.ConvertRect(e.ClipRectangle),
                    _paintProperties);
            }
            catch
            {
            }
        }
Example #3
0
        protected override void OnPaint(PaintEventArgs e)
        {
            try
            {
                LeadRect dstRect = Leadtools.Demos.Converters.ConvertRect(DestinationRectangle);

#if LEADTOOLS_V17_OR_LATER
                RasterImagePainter.Paint(_image, e.Graphics,
#else
                _image.Paint(e.Graphics,
#endif // #if LEADTOOLS_V17_OR_LATER
                                         Leadtools.Demos.Converters.ConvertRect(SourceRectangle),
                                         LeadRect.Empty,
                                         dstRect,
                                         Leadtools.Demos.Converters.ConvertRect(e.ClipRectangle),
                                         RasterPaintProperties.Default);
            }
            catch
            {
            }
        }
Example #4
0
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            if (_sampleSymbologiesRasterImage == null)
            {
                return;
            }

            if (e.Index == -1)
            {
                return;
            }

            Rectangle rc = new Rectangle(e.Bounds.X + _delta, e.Bounds.Y + _delta, e.Bounds.Width - 10, e.Bounds.Height - _delta);

            if (_stringFormat == null)
            {
                _stringFormat               = new StringFormat();
                _stringFormat.Alignment     = StringAlignment.Center;
                _stringFormat.LineAlignment = StringAlignment.Far;
            }

            BarcodeSymbology symbology = (BarcodeSymbology)Items[e.Index];
            string           name      = BarcodeEngine.GetSymbologyFriendlyName(symbology);

            _sampleSymbologiesRasterImage.Page = (int)symbology;

            if (_itemPen == null)
            {
                _itemPen = new Pen(Brushes.Black, 2);
            }

            e.Graphics.DrawRectangle(_itemPen, rc);
            e.Graphics.FillRectangle(Brushes.White, rc);

            RasterPaintProperties paintProperties = RasterPaintProperties.Default;

            if (RasterSupport.IsLocked(RasterSupportType.Document))
            {
                paintProperties.PaintDisplayMode = RasterPaintDisplayModeFlags.Bicubic;
            }
            else
            {
                paintProperties.PaintDisplayMode = RasterPaintDisplayModeFlags.ScaleToGray;
            }

            LeadRect imageRect = new LeadRect(rc.X + 2, rc.Y + 2, rc.Width - 4, rc.Height * 2 / 3);

            imageRect = RasterImage.CalculatePaintModeRectangle(
                _sampleSymbologiesRasterImage.ImageWidth,
                _sampleSymbologiesRasterImage.ImageHeight,
                imageRect,
                RasterPaintSizeMode.FitAlways,
                RasterPaintAlignMode.CenterAlways,
                RasterPaintAlignMode.CenterAlways);

            if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
            {
                e.Graphics.FillRectangle(SystemBrushes.Highlight, rc);
                RasterImagePainter.Paint(_sampleSymbologiesRasterImage, e.Graphics, imageRect, paintProperties);
                e.Graphics.DrawRectangle(Pens.Black, imageRect.X, imageRect.Y, imageRect.Width, imageRect.Height);
                e.Graphics.DrawString(name, Font, SystemBrushes.HighlightText, rc, _stringFormat);
            }
            else
            {
                e.Graphics.FillRectangle(SystemBrushes.Control, rc);
                RasterImagePainter.Paint(_sampleSymbologiesRasterImage, e.Graphics, imageRect, paintProperties);
                e.Graphics.DrawRectangle(Pens.Black, imageRect.X, imageRect.Y, imageRect.Width, imageRect.Height);
                e.Graphics.DrawString(name, Font, SystemBrushes.ControlText, rc, _stringFormat);
            }
        }