Example #1
0
        public static Image getScaleImage(string imagePath, Control v)
        {
            FileStream fileStream = File.Open(imagePath, FileMode.Open);
            Image      original   = Image.FromStream((Stream)fileStream);

            fileStream.Close();
            fileStream.Dispose();
            Bitmap bmp    = new Bitmap(original);
            Bitmap bitmap = HuionRender.blowupImage(HuionRender.compressImageWithRate(bmp, v.Width, v.Height),
                                                    DpiHelper.getInstance().XDpi);

            original.Dispose();
            if (bitmap == bmp)
            {
                return((Image)bitmap);
            }
            bmp.Dispose();
            return((Image)bitmap);
        }
Example #2
0
        public static Image getDllScaleImage(string imageName, Control v)
        {
            Stream stream = new Depot().loadImage(imageName);

            Console.WriteLine(imageName);
            Console.WriteLine(stream.ToString());
            Image original = Image.FromStream(stream);

            stream.Close();
            stream.Dispose();
            Bitmap bmp    = new Bitmap(original);
            Bitmap bitmap = HuionRender.blowupImage(HuionRender.compressImageWithRate(bmp, v.Width, v.Height),
                                                    DpiHelper.getInstance().XDpi);

            original.Dispose();
            if (bitmap == bmp)
            {
                return((Image)bitmap);
            }
            bmp.Dispose();
            return((Image)bitmap);
        }
Example #3
0
        private void meassure(int refreshPart)
        {
            this.mScreenshot =
                HuionRender.compressImageWithRate(this.mScreenshot, this.ScreenshotMaxWidth, this.ScreenshotMaxHeight);
            if (this.mScreenshot != null)
            {
                this.mScreenshotRect        = new Rectangle();
                this.mScreenshotRect.Width  = this.mScreenshot.Width;
                this.mScreenshotRect.Height = this.mScreenshot.Height;
                this.mScreenshotRect.X      = 0;
                this.mScreenshotRect.Y      = 0;
            }

            this.mDeviceImage4Draw =
                HuionRender.rotateImageCenter(this.mDeviceImage, (float)this.mRotate, Color.Transparent);
            this.mDeviceImage4Draw = HuionRender.compressImageWithRate(this.mDeviceImage4Draw, this.DeviceImageMaxWidth,
                                                                       this.DeviceImageMaxHeight);
            if (this.mDeviceImage4Draw != null)
            {
                this.mDeviceImageRect        = new Rectangle();
                this.mDeviceImageRect.Width  = this.mDeviceImage4Draw.Width;
                this.mDeviceImageRect.Height = this.mDeviceImage4Draw.Height;
                this.mDeviceImageRect.X      = (this.mScreenshotRect.Width - this.mDeviceImage4Draw.Width) / 2;
                this.mDeviceImageRect.Y      = this.mScreenshotRect.Y + this.mScreenshotRect.Height + this.mIntervalSpace;
            }

            if (this.mDeviceImageRect.X < 0)
            {
                this.mDeviceImageRect.X = 0;
            }
            this.Width = this.mDeviceImageRect.Width > this.mScreenshotRect.Width
                ? this.mDeviceImageRect.Width
                : this.mScreenshotRect.Width;
            this.Height = this.mDeviceImageRect.Bottom;
            if (this.Width > this.mScreenshotRect.Width)
            {
                this.mScreenshotRect.X = (this.Width - this.mScreenshotRect.Width) / 2;
            }
            if (this.mDeviceImage4Draw != null && this.mDeviceSize.cx > 0 && this.mDeviceSize.cy > 0)
            {
                this.mPenWorkRect = Utils.swapLayout(this.mDeviceImage4Draw.Size,
                                                     Utils.rotateSize(this.mDeviceSize, this.mRotate),
                                                     Utils.rotateRect(this.mPenWorkarea, this.mDeviceSize, this.mRotate));
                this.mPenWorkRect.X += this.mDeviceImageRect.X;
                this.mPenWorkRect.Y += this.mDeviceImageRect.Y;
            }

            if ((refreshPart & 1) == 1)
            {
                this.Invalidate(new Rectangle(0, 0, this.Width, this.mScreenshotRect.Bottom));
            }
            else if ((refreshPart & 2) == 2)
            {
                this.Invalidate(new Rectangle(0, this.mDeviceImageRect.Y, this.Width, this.mDeviceImageRect.Height));
            }
            else
            {
                this.Invalidate();
            }
            if (this.Callback == null)
            {
                return;
            }
            this.Callback((object)this, (EventArgs)PictureViewEventArgs.getInstance(this.Rotate));
        }