Esempio n. 1
0
 public static void Resize(Projector[] projectors, ScalingType scaling, float scale, float width)
 {
     foreach (Projector p in projectors)
     {
         Resize(p, scaling, scale, width);
     }
 }
Esempio n. 2
0
        public Chart3d(IStreamReader reader, RecordType id, UInt16 length)
            : base(reader, id, length)
        {
            // assert that the correct record type is instantiated
            Debug.Assert(this.Id == ID);

            // initialize class members from stream
            this.anRot    = reader.ReadInt16();
            this.anElev   = reader.ReadInt16();
            this.pcDist   = reader.ReadInt16();
            this.pcHeight = reader.ReadUInt16();
            this.pcDepth  = reader.ReadInt16();
            this.pcGap    = reader.ReadUInt16();

            UInt16 flags = reader.ReadUInt16();

            this.fPerspective = Utils.BitmaskToBool(flags, 0x0001);
            this.fCluster     = Utils.BitmaskToBool(flags, 0x0002);
            this.f3DScaling   = (ScalingType)Utils.BitmaskToUInt16(flags, 0x0004);
            // 0x0008 is skipped
            this.fNotPieChart = Utils.BitmaskToBool(flags, 0x0010);
            this.fWalls2D     = Utils.BitmaskToBool(flags, 0x0020);

            // assert that the correct number of bytes has been read from the stream
            Debug.Assert(this.Offset + this.Length == this.Reader.BaseStream.Position);
        }
Esempio n. 3
0
        public static RendererCommon.ScalingType ToNative(this ScalingType self)
        {
            switch (self)
            {
            case ScalingType.AspectFit:
                return(RendererCommon.ScalingType.ScaleAspectFit);

            case ScalingType.AspectFill:
                return(RendererCommon.ScalingType.ScaleAspectFill);

            case ScalingType.AspectBalanced:
                return(RendererCommon.ScalingType.ScaleAspectBalanced);

            default:
                throw new ArgumentOutOfRangeException(nameof(self), self, null);
            }
        }
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            // Use this to return your custom view for this Fragment
            // return inflater.Inflate(Resource.Layout.YourFragment, container, false);

            var controlView = inflater.Inflate(Resource.Layout.fragment_call, container, false);

            _contactView = controlView.FindViewById <TextView>(Resource.Id.contact_name_call);

            var disconnectButton = controlView.FindViewById <ImageButton>(Resource.Id.button_call_disconnect);

            _cameraSwitchButton  = controlView.FindViewById <ImageButton>(Resource.Id.button_call_switch_camera);
            _videoScalingButton  = controlView.FindViewById <ImageButton>(Resource.Id.button_call_scaling_mode);
            _toggleMuteButton    = controlView.FindViewById <ImageButton>(Resource.Id.button_call_toggle_mic);
            _captureFormatText   = controlView.FindViewById <TextView>(Resource.Id.capture_format_text_call);
            _captureFormatSlider = controlView.FindViewById <SeekBar>(Resource.Id.capture_format_slider_call);

            disconnectButton.Click    += (sender, args) => _callEvents.OnCallHangUp();
            _cameraSwitchButton.Click += (sender, args) => _callEvents.OnCameraSwitch();
            _videoScalingButton.Click += (sender, args) =>
            {
                if (_scalingType == ScalingType.AspectFill)
                {
                    _videoScalingButton.SetBackgroundResource(Resource.Drawable.ic_action_full_screen);
                    _scalingType = ScalingType.AspectFill;
                }
                else
                {
                    _videoScalingButton.SetBackgroundResource(Resource.Drawable.ic_action_return_from_full_screen);
                    _scalingType = ScalingType.AspectFit;
                }

                _callEvents.OnVideoScalingSwitch(_scalingType);
            };

            _scalingType = ScalingType.AspectFill;

            _toggleMuteButton.Click += (sender, args) =>
            {
                var enabled = _callEvents.OnToggleMic();
                _toggleMuteButton.Alpha = enabled ? 1f : 0.3f;
            };

            return(controlView);
        }
Esempio n. 5
0
 public static void Resize(Projector projector, ScalingType scaling, float scale, float width)
 {
     if (projector != null)
     {
         if (scaling != ScalingType.None)
         {
             if (scaling == ScalingType.LengthOnly)
             {
                 projector.aspectRatio = width / scale;
             }
             else
             {
                 projector.aspectRatio = 1f;
             }
             projector.orthographicSize = scale / 2;
         }
     }
 }
Esempio n. 6
0
        public float GetScalingDamage(Obj_AI_Base target, DamageType Type, ScalingType Stat, float percentScaling)
        {
            float amount = ScalingFunc[Stat.ToString()](percentScaling);

            if (Type == DamageType.Magical)
            {
                return((float)Magic_damage_m * (float)source.CalcDamage(target, Damage.DamageType.Magical, amount));
            }
            else if (Type == DamageType.Physical)
            {
                return((float)Physical_damage_m * (float)source.CalcDamage(target, Damage.DamageType.Physical, amount));
            }
            else if (Type == DamageType.True)
            {
                return(amount);
            }
            return(0f);
        }
Esempio n. 7
0
        public ResizeCommand(ScalingType scalingType, int size)
        {
            _size = size;
            switch (scalingType)
            {
            case ScalingType.CropScaling:
                _scaling = new CropScaling(_size, _size);
                break;

            case ScalingType.FitScaling:
                _scaling = new FitScaling(_size, _size);
                break;

            case ScalingType.PadScaling:
                _scaling = new PadScaling(_size, _size);
                break;
            }
        }
 public void OnVideoScalingSwitch(ScalingType scalingType)
 {
     _fullscreenRenderer.SetScalingType(scalingType.ToNative());
 }
Esempio n. 9
0
        private static float Scale(int maxPixel, float maxSkeleton, float position, ScalingType scalingType)
        {
            int value = 0;

            if (scalingType == ScalingType.paddleBig) { //smaller area for the arm to swing up and down for the paddle to move

                //Make sure the hand position is within the boundaries of the 0.5 - 0.0 scaled set
                if (position > 0.5f)
                    return 0;
                if (position < 0)
                    return maxPixel;

                //Get the percentage of the hand position within the 0.5 to 0.0 scaled set
                float percent = position / maxSkeleton;

                //Get the new position of the bat using the scaled hand position
                value = (int)(maxPixel - (maxPixel * percent));

            } else if (scalingType == ScalingType.paddleSmall) { //bigger area for the arm to swing up and down for the paddle to move

                //Make sure the hand position is within the boundaries of the 0.75 to -0.5 scaled set
                if (position > 0.75f)
                    return 0;
                if (position < -0.5f)
                    return maxPixel;

                //Change the range so that we can work with the negative values of the hand position
                position += 0.5f;

                //Get the percentage of the hand position within the 2 to 0.5 (1 to -0.5) scaled set
                float percent = position / (maxSkeleton + 0.5f);

                //Get the new position of the bat using the scaled hand position
                value = (int)(maxPixel - (maxPixel * percent));
            }

            //Return the new postion of the paddle scaled
            return value;
        }
Esempio n. 10
0
        public static Joint ScaleTo(this Joint joint, int width, int height, float skeletonMaxX, float skeletonMaxY, ScalingType scalingType)
        {
            Microsoft.Kinect.SkeletonPoint pos = new SkeletonPoint()
            {
                X = Scale(width, skeletonMaxX, joint.Position.X, scalingType),
                Y = Scale(height, skeletonMaxY, joint.Position.Y, scalingType), //-joint.Position.Y
                Z = joint.Position.Z
            };

            joint.Position = pos;

            return joint;
        }
Esempio n. 11
0
        /// <summary>
        ///     Storleksändrar bild med en maxstorlek som påverkar både höjd och bredd beroende på val av ScalingType
        /// </summary>
        /// <param name="image">Bild</param>
        /// <param name="width">Max Storlek Bredd</param>
        /// <param name="height">Max Storlek höjd</param>
        /// <param name="scalingType">Välj vilken scalingType för storleksändring som ska gälla.</param>
        /// <returns>Returnerar bildobjekt</returns>
        private static Image ResizeImage(Image image, float width, float height, ScalingType scalingType)
        {
            // Undersök om bilden redan är mindre än önskat
            if (scalingType == ScalingType.Max &&
                (Math.Abs(width) < float.Epsilon || image.Width <= width) &&
                (Math.Abs(height) < float.Epsilon || image.Height <= height))
            {
                return(image);
            }

            // Tag reda på storleksförhållande för bilden
            var aspectRatioBild = (float)image.Width / image.Height;

            // Tag reda på önskat storleksförhållande för önskad bild
            var aspectRatioUt = aspectRatioBild;

            // Anpassa storleksförhållandet om man uteslutit något av höjd/bredd
            if (Math.Abs(width) > float.Epsilon && Math.Abs(height) > float.Epsilon)
            {
                aspectRatioUt = width / height;
            }

            // Storleksförändra beroende på vald scalingType.
            if (scalingType == ScalingType.Max)
            {
                if (Math.Abs(height) < float.Epsilon)
                {
                    height = width / aspectRatioUt;
                }

                if (Math.Abs(width) < float.Epsilon)
                {
                    width = height * aspectRatioUt;
                }

                if (image.Width > width)
                {
                    if (width / aspectRatioBild < height)
                    {
                        height = width / aspectRatioBild;
                    }
                }

                if (image.Height > height)
                {
                    if (height * aspectRatioBild < width)
                    {
                        width = height * aspectRatioBild;
                    }
                }

                var bitmap = new Bitmap((int)width, (int)height);
                bitmap.SetResolution(image.HorizontalResolution, image.VerticalResolution);
                using (var graphics = Graphics.FromImage(bitmap))
                {
                    graphics.CompositingQuality = CompositingQuality.HighQuality;
                    graphics.InterpolationMode  = InterpolationMode.HighQualityBilinear;
                    graphics.SmoothingMode      = SmoothingMode.HighQuality;
                    graphics.DrawImage(image, 0, 0, bitmap.Width, bitmap.Height);
                }

                return(bitmap);
            }

            #region Force

            if (scalingType == ScalingType.Force)
            {
                if (Math.Abs(height) < float.Epsilon)
                {
                    height = width / aspectRatioBild;
                }

                if (Math.Abs(width) < float.Epsilon)
                {
                    width = height * aspectRatioBild;
                }

                var bitmap = new Bitmap((int)width, (int)height);
                using (var graphics = Graphics.FromImage(bitmap))
                {
                    graphics.SmoothingMode     = SmoothingMode.AntiAlias;
                    graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
                    graphics.DrawImage(image, new Rectangle(-1, -1, (int)width + 2, (int)height + 2), 0, 0,
                                       image.Width, image.Height, GraphicsUnit.Pixel);
                }

                return(bitmap);
            }

            #endregion

            if (scalingType == ScalingType.Center)
            {
                // Make sure it works even if no width/height is specified
                if (Math.Abs(height) < float.Epsilon)
                {
                    height = width / aspectRatioUt;
                }

                if (Math.Abs(width) < float.Epsilon)
                {
                    width = height * aspectRatioUt;
                }

                // Create the target image
                var thumbnail = new Bitmap((int)width, (int)height);

                // Make target paint area heigh based on aspect ratio
                if (width / aspectRatioBild < height)
                {
                    height = width / aspectRatioBild;
                }

                // Make target paint area width based on aspect ratio
                if (height * aspectRatioBild < width)
                {
                    width = height * aspectRatioBild;
                }

                using (var graphics = Graphics.FromImage(thumbnail))
                {
                    // Set quality for new image
                    graphics.CompositingQuality = CompositingQuality.HighQuality;
                    graphics.InterpolationMode  = InterpolationMode.HighQualityBicubic;
                    graphics.SmoothingMode      = SmoothingMode.HighQuality;

                    // Fill the destination image with white
                    graphics.Clear(Color.White);

                    var startX = 0;
                    var startY = 0;

                    // Set start patinging for Y
                    if (thumbnail.Width > height * aspectRatioUt)
                    {
                        startY = (int)((thumbnail.Width - height * aspectRatioUt) / 2f);
                    }

                    // Set start patinging for X
                    if (thumbnail.Height > width / aspectRatioUt)
                    {
                        startX = (int)((thumbnail.Height - width / aspectRatioUt) / 2f);
                    }

                    // Create painting rectangle
                    var destRect = new Rectangle(startX, startY, (int)width, (int)height);

                    graphics.DrawImage(image, destRect, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel);
                }

                return(thumbnail);
            }

            {
                var bitmap = new Bitmap((int)width, (int)height);
                using (var graphics = Graphics.FromImage(bitmap))
                {
                    graphics.SmoothingMode     = SmoothingMode.AntiAlias;
                    graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;

                    if ((float)image.Width / image.Height >= width / height)
                    {
                        // Önskad bildutsnitt kräver att vi kapar till höger och vänster
                        // "Liggande"
                        var newWidth  = (int)(image.Height * (width / height));
                        var widthDiff = image.Width - newWidth;

                        graphics.DrawImage(image, new Rectangle(-1, -1, (int)width + 2, (int)height + 2),
                                           widthDiff / 2, 0, newWidth, image.Height, GraphicsUnit.Pixel);
                    }
                    else if (scalingType == ScalingType.Top)
                    {
                        // Önskad bildutsnitt kräver att vi kapar i botten (vi vill ha toppen)
                        // Porträtt-bild, stående
                        var newHeight = (int)(image.Width * (height / width));

                        graphics.DrawImage(image, new Rectangle(-1, -1, (int)width + 2, (int)height + 2), 0, 0,
                                           image.Width, newHeight, GraphicsUnit.Pixel);
                    }
                    else
                    {
                        // Önskad bildutsnitt kräver att vi kapar i toppen och botten
                        // Stående
                        // Porträtt-bild, stående
                        var newHeight  = (int)(image.Width * (height / width));
                        var heightDiff = image.Height - newHeight;

                        graphics.DrawImage(image, new Rectangle(-1, -1, (int)width + 2, (int)height + 2), 0,
                                           heightDiff / 2, image.Width, newHeight, GraphicsUnit.Pixel);
                    }
                }

                return(bitmap);
            }
        }
Esempio n. 12
0
        /// <summary>
        ///     Storleksändrar bild med en maxstorlek som påverkar både höjd och bredd beroende på val av ScalingType
        /// </summary>
        /// <param name="originalImage">The original image.</param>
        /// <param name="maxWidth">Width of the max.</param>
        /// <param name="maxHeight">Height of the max.</param>
        /// <param name="scalingType">Välj vilken scalingType för storleksändring som ska gälla.</param>
        /// <returns>
        ///     Returnerar bildobjekt
        /// </returns>
        private static Image ResizeIndexedImage(Image originalImage, float maxWidth, float maxHeight, ScalingType scalingType)
        {
            Bitmap     sourceBitmap;
            Bitmap     targetBitmap;
            BitmapData sourceData, targetData;

            // Convert the image to an 8bpp image
            using (var stream = new MemoryStream())
            {
                originalImage.Save(stream, ImageFormat.Gif);
                stream.Position = 0;
                sourceBitmap    = new Bitmap(stream);
            }

            // Undersök om bilden redan är mindre än önskat
            if (scalingType == ScalingType.Max &&
                (Math.Abs(maxWidth) < float.Epsilon || originalImage.Width <= maxWidth) &&
                (Math.Abs(maxHeight) < float.Epsilon || originalImage.Height <= maxHeight))
            {
                return(originalImage);
            }

            // Tag reda på storleksförhållande för bilden
            var aspectRatioBild = (float)originalImage.Width / originalImage.Height;

            // Tag reda på önskat storleksförhållande för önskad bild
            var aspectRatioUt = aspectRatioBild;

            // Anpassa storleksförhållandet om man uteslutit något av höjd/bredd
            if (Math.Abs(maxWidth) > float.Epsilon && Math.Abs(maxHeight) > float.Epsilon)
            {
                aspectRatioUt = maxWidth / maxHeight;
            }

            // Storleksförändra beroande på vald scalingType.
            if (scalingType == ScalingType.Max || scalingType == ScalingType.Force)
            {
                if (scalingType == ScalingType.Max)
                {
                    if (Math.Abs(maxHeight) < float.Epsilon)
                    {
                        maxHeight = maxWidth / aspectRatioUt;
                    }

                    if (Math.Abs(maxWidth) < float.Epsilon)
                    {
                        maxWidth = maxHeight * aspectRatioUt;
                    }

                    if (originalImage.Width > maxWidth)
                    {
                        if (maxWidth / aspectRatioBild < maxHeight)
                        {
                            maxHeight = maxWidth / aspectRatioBild;
                        }
                    }

                    if (originalImage.Height > maxHeight)
                    {
                        if (maxHeight * aspectRatioBild < maxWidth)
                        {
                            maxWidth = maxHeight * aspectRatioBild;
                        }
                    }
                }
                else // scalingType == ScalingType.Force
                {
                    if (Math.Abs(maxHeight) < float.Epsilon)
                    {
                        maxHeight = maxWidth / aspectRatioBild;
                    }

                    if (Math.Abs(maxWidth) < float.Epsilon)
                    {
                        maxWidth = maxHeight * aspectRatioBild;
                    }
                }

                targetBitmap =
                    new Bitmap((int)maxWidth, (int)maxHeight, sourceBitmap.PixelFormat)
                {
                    Palette = sourceBitmap.Palette
                };

                sourceData = sourceBitmap.LockBits(new Rectangle(0, 0, sourceBitmap.Width, sourceBitmap.Height),
                                                   ImageLockMode.ReadOnly, sourceBitmap.PixelFormat);
                targetData = targetBitmap.LockBits(new Rectangle(0, 0, (int)maxWidth, (int)maxHeight),
                                                   ImageLockMode.WriteOnly, targetBitmap.PixelFormat);

                var xFactor = (double)sourceBitmap.Width / targetBitmap.Width;
                var yFactor = (double)sourceBitmap.Height / targetBitmap.Height;

                for (var y = 0; y < targetBitmap.Height; ++y)
                {
                    for (var x = 0; x < targetBitmap.Width; ++x)
                    {
                        var yPosition = (int)Math.Floor(y * yFactor);
                        var xPosition = (int)Math.Floor(x * xFactor);
                        var origByte  = Marshal.ReadByte(sourceData.Scan0, sourceData.Stride * yPosition + xPosition);
                        Marshal.WriteByte(targetData.Scan0, targetData.Stride * y + x, origByte);
                    }
                }

                targetBitmap.UnlockBits(targetData);
                sourceBitmap.UnlockBits(sourceData);
            }
            else //( scalingType == ScalingType.CutOut )  // Eller Top
            {
                int sourceX, sourceY;
                int sourceWidth, sourceHeight;

                if ((float)originalImage.Width / originalImage.Height >= maxWidth / maxHeight)
                {
                    // Önskad bildutsnitt kräver att vi kapar till höger och vänster
                    // "Liggande"
                    var newWidth  = (int)(originalImage.Height * (maxWidth / maxHeight));
                    var widthDiff = originalImage.Width - newWidth;

                    sourceX      = widthDiff / 2;
                    sourceY      = 0;
                    sourceWidth  = newWidth;
                    sourceHeight = originalImage.Height;
                }
                else
                {
                    // Önskad bildutsnitt kräver att vi kapar i toppen och botten
                    // "Stående"
                    // Porträtt-bild, stående
                    var newHeight  = (int)(originalImage.Width * (maxHeight / maxWidth));
                    var heightDiff = originalImage.Height - newHeight;

                    sourceX = 0;
                    sourceY = heightDiff / 2;

                    // Om vi vill ha top, ta toppen på bilden, istället för "centrerad" yta
                    if (scalingType == ScalingType.Top)
                    {
                        sourceY = 0;
                    }
                    //else
                    //{
                    //    // Ta centrerad yta
                    //    sourceY = (int)(heightDiff / 2);

                    //    // ...men om den dynamiska egenskapen "ImageHandlerUseTopWhenCroping" är satt, använd toppen ändå.
                    //    PageBase CurrentPage = HttpContext.Current.Handler as PageBase;
                    //    if (CurrentPage != null)
                    //    {
                    //        if (CurrentPage.IsValue("ImageHandlerUseTopWhenCroping"))
                    //            sourceY = 0;
                    //    }
                    //}

                    sourceWidth  = originalImage.Width;
                    sourceHeight = newHeight;
                }

                targetBitmap =
                    new Bitmap((int)maxWidth, (int)maxHeight, sourceBitmap.PixelFormat)
                {
                    Palette = sourceBitmap.Palette
                };

                sourceData = sourceBitmap.LockBits(new Rectangle(0, 0, sourceBitmap.Width, sourceBitmap.Height),
                                                   ImageLockMode.ReadOnly, sourceBitmap.PixelFormat);
                targetData = targetBitmap.LockBits(new Rectangle(0, 0, targetBitmap.Width, targetBitmap.Height),
                                                   ImageLockMode.WriteOnly, targetBitmap.PixelFormat);

                var xFactor = (double)sourceWidth / targetBitmap.Width;
                var yFactor = (double)sourceHeight / targetBitmap.Height;

                for (var y = 0; y < maxHeight; ++y)
                {
                    for (var x = 0; x < maxWidth; ++x)
                    {
                        var yPosition = (int)Math.Floor(y * yFactor) + sourceY;
                        var xPosition = (int)Math.Floor(x * xFactor) + sourceX;
                        var origByte  = Marshal.ReadByte(sourceData.Scan0, sourceData.Stride * yPosition + xPosition);
                        Marshal.WriteByte(targetData.Scan0, targetData.Stride * y + x, origByte);
                    }
                }

                targetBitmap.UnlockBits(targetData);
                sourceBitmap.UnlockBits(sourceData);
            }

            return(targetBitmap);
        }
Esempio n. 13
0
 public ScalingStatAttribute(ScalingType type)
 {
     scaling = type.ToString();
 }
Esempio n. 14
0
 public void SetDisplay(ScalingType scaling)
 {
     Display.Scaling = scaling;
 }
Esempio n. 15
0
 public void OnVideoScalingSwitch(ScalingType _scalingType) => FullScreenRenderer.SetScalingType(_scalingType.ToNative());
Esempio n. 16
0
 public RegistedDamage(DamageType DamageType, float baseDamage, float perLevel, DamageType ScalingType, ScalingType ScalingStat, float percentScaling, Func <Obj_AI_Base, bool> condition, Func <Obj_AI_Base, float> extra)
 {
     this.DamageType = DamageType;
     this.baseDamage = baseDamage;
     this.ScalingType.Add(ScalingType);
     this.ScalingStat.Add(ScalingStat);
     this.percentScaling.Add(percentScaling);
     this.condition = condition;
     this.extra     = extra;
 }
Esempio n. 17
0
 public void RegistDamage(string spellId, DamageType damageType, float baseDamage, float perLevel, DamageType scalingType, ScalingType scalingStat, float percentScaling, Func <Obj_AI_Base, bool> condition, Func <Obj_AI_Base, float> extra)
 {
     sources.Add(spellId, new RegistedDamage(damageType, baseDamage, perLevel, scalingType, scalingStat, percentScaling, condition, extra));
 }
 public void OnVideoScalingSwitch(ScalingType _scalingType) => FullScreenRenderer.SetScalingType(RendererCommon.ScalingType.ScaleAspectFill);
Esempio n. 19
0
 public ScalingStatAttribute(ScalingType type)
 {
     scaling = type.ToString();
 }
Esempio n. 20
0
 public KWP2000ScalingTableRecordEntry(ScalingType scalingType, byte numScalingBytes)
 {
     RecordScalingType = scalingType;
     NumScalingBytes   = numScalingBytes;
 }
 /// <summary>
 ///     Techniques the specified technique.
 /// </summary>
 /// <param name="technique">The technique.</param>
 /// <returns>FluentImageProviderImage.</returns>
 public FluentImageProviderImage Technique(ScalingType technique)
 {
     _technique = technique;
     return(this);
 }