示例#1
0
        public TestItem1()
        {
            InitializeComponent();
            //重設長寬
            ResizeUtil.Resize(this);

            t.c        = this.button1;;
            TestObj.CC = this.button1;
        }
        public override Task ConvertAsync(IList <Image <Rgba32> > images, Stream outputStream, CancellationToken cancellationToken)
        {
            if (images is null)
            {
                throw new ArgumentNullException(nameof(images));
            }
            if (images.Count != 2)
            {
                throw new ArgumentException("Exactly two images are required for this format.", nameof(images));
            }
            if (outputStream is null)
            {
                throw new ArgumentNullException(nameof(outputStream));
            }

            // This format appears to use 9 mipmaps. The first is the biggest at 256x256 (this is the max supported).
            // Each subsequent one is half as wide and high, ending with 1x1. This makes 9 images.
            // `Math.Log(256, 2) + 1` (+ 1 because 2^0 = 1 and that's still a slot we need) can be
            // used to calculate this value, but since we're going up against file size limits anyway,
            // hard-coding is fine.

            const int totalImages = 9;
            var       sizedImages = new List <Image <Rgba32> >(totalImages);

            sizedImages.AddRange(images.Take(totalImages));

            var lastImage = sizedImages.Last();

            while (sizedImages.Count < totalImages)
            {
                sizedImages.Add(lastImage.Clone());
            }

            var width  = MaxWidth;
            var height = MaxHeight;

            foreach (var image in sizedImages)
            {
                ResizeUtil.Resize(image, width, height);

                width  /= 2;
                height /= 2;

                lastImage = image;
            }

            var encoder = new VtfEncoder(VtfImageType.Fading);

            return(encoder.EncodeWithMipmapsAsync(sizedImages, outputStream, cancellationToken));
        }
示例#3
0
        /// <summary>
        /// 變更Form的長寬,連動目前使用的功能
        /// </summary>
        public void Resize(Form thisForm, Panel targetPanel)
        {
            //計算目前的長寬的比例
            DynamicConfig.FORM_WIDTH_PERCENT  = (thisForm.Width / DynamicConfig.FORM_WIDTH);
            DynamicConfig.FORM_HEIGHT_PERCENT = (thisForm.Height / DynamicConfig.FORM_HEIGHT);

            //記錄目前Form的size
            SetFormSize(thisForm);

            //變更Panel的大小
            targetPanel.Width  = Convert.ToInt32(targetPanel.Width * DynamicConfig.FORM_WIDTH_PERCENT);
            targetPanel.Height = Convert.ToInt32(targetPanel.Height * DynamicConfig.FORM_HEIGHT_PERCENT);

            //重設長寬
            ResizeUtil.Resize(targetPanel.Controls[0]);
        }
示例#4
0
        protected override void Resize(Image <Rgba32> image)
        {
            var maxWidth  = MaxWidth;
            var maxHeight = MaxHeight;

            if (image.Width > image.Height)
            {
                maxHeight = MaxSmallerDimension;
            }
            else if (maxWidth > maxHeight)
            {
                maxWidth = MaxSmallerDimension;
            }
            else
            {
                maxWidth = maxHeight = MaxSmallerDimension;
            }

            ResizeUtil.Resize(image, maxWidth, maxHeight);
        }
 protected virtual void Resize(Image <Rgba32> image)
 {
     ResizeUtil.Resize(image, MaxWidth, MaxHeight);
 }