当前位置: 首页>>代码示例>>C#>>正文


C# ScaleMode类代码示例

本文整理汇总了C#中ScaleMode的典型用法代码示例。如果您正苦于以下问题:C# ScaleMode类的具体用法?C# ScaleMode怎么用?C# ScaleMode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ScaleMode类属于命名空间,在下文中一共展示了ScaleMode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetScaledImage

        // from http://blogs.wankuma.com/ch3cooh/archive/2008/07/07/147667.aspx
        public static Image GetScaledImage(Image srcImg, int maxW, int maxH, ScaleMode mode)
        {
            int srcW = srcImg.Width;
            int srcH = srcImg.Height;
            Rectangle srcRect = new Rectangle(0, 0, srcW, srcH);

            int dstW, dstH;

            // FIXME 正方形の画像の場合は?
            // fitのときに横方向がはみ出す(縦に合わせられる)場合がある
            if ((srcW > srcH && mode == ScaleMode.Fit) || (srcH > srcW && mode == ScaleMode.Full))
            {
                dstW = maxW;
                dstH = (int)(((float)dstW / (float)srcW) * srcH);
            }
            else
            {
                dstH = maxH;
                dstW = (int)(((float)dstH / (float)srcH) * srcW);
            }

            Image dstImg = new Bitmap(dstW, dstH, PixelFormat.Format16bppRgb565);

            Rectangle dstRect = new Rectangle(0, 0, dstW, dstH);

            Graphics g = Graphics.FromImage(dstImg);
            g.DrawImage(srcImg, dstRect, srcRect, GraphicsUnit.Pixel);
            g.Dispose();

            return dstImg;
        }
开发者ID:n13i,项目名称:tumblott,代码行数:32,代码来源:Utils.cs

示例2: init

 public void init(Vector2 butSize, Vector2 screenSize, ScaleMode scaleMode)
 {
     refButtonSize = butSize;
     refScreenSize = screenSize;
     smode = scaleMode;
     setButtonSize();
 }
开发者ID:copperlizard,项目名称:Adventure-Marble,代码行数:7,代码来源:ButtonBrancher.cs

示例3: Initialize

 public void Initialize(Vector2 referenceButtonSize, Vector2 referenceScreenSize, int scaleMode)
 {
     this.referenceButtonSize = referenceButtonSize;
     this.referenceScreenSize = referenceScreenSize;
     this.scaleMode = (ScaleMode)scaleMode;
     SetNewButtonSize();
 }
开发者ID:ameyagadkari,项目名称:portfolio,代码行数:7,代码来源:ButtonBrancher.cs

示例4: ScaleFromTo

        public static Vector2 ScaleFromTo(Vector2 from, Vector2 to, ScaleMode scaleMode = ScaleMode.StretchToFill)
        {
            Vector2 scale = Vector2.one;
            scale.x = to.x / from.x;
            scale.y = to.y / from.y;

            switch (scaleMode) {
            case ScaleMode.ScaleAndCrop:
                scale.x = scale.y = Mathf.Max(scale.x, scale.y);
                break;

            case ScaleMode.ScaleToFit:
                scale.x = scale.y = Mathf.Min(scale.x, scale.y);
                break;

            case ScaleMode.StretchToFill:
                //Do nothing
                break;

            default:
                Debug.LogException(new System.NotImplementedException("The Received ScaleMode." + scaleMode.ToString() + " is not implemented."));
                break;
            }

            return scale;
        }
开发者ID:JaySoyer,项目名称:Unity-Utils,代码行数:26,代码来源:Vectors.cs

示例5: FeatureSymbolizer

 /// <summary>
 /// Creates a new instance of FeatureSymbolizer
 /// </summary>
 protected FeatureSymbolizer()
 {
     _scaleMode = ScaleMode.Simple;
     _smoothing = true;
     _isVisible = true;
     _unit = GraphicsUnit.Pixel;
 }
开发者ID:DIVEROVIEDO,项目名称:DotSpatial,代码行数:10,代码来源:FeatureSymbolizer.cs

示例6: CalculateSourceRect

        private static Rectangle CalculateSourceRect(Size sourceImage, Size thumbImage, ScaleMode scaleMode)
        {
            int previewHeight = thumbImage.Height;
            int previewWidth = thumbImage.Width;

            switch (scaleMode)
            {
                case ScaleMode.Crop:
                    double wRatio = (double)sourceImage.Width / previewWidth;
                    double hRatio = (double)sourceImage.Height / previewHeight;
                    double coef = (double)previewHeight / previewWidth;
                    int resultWidth;
                    int resultHeight;
                    if (wRatio < hRatio)
                    {
                        resultWidth = sourceImage.Width;
                        resultHeight = (int)Math.Truncate(sourceImage.Width * coef);
                        return new Rectangle(0, (sourceImage.Height - resultHeight) / 2, resultWidth, resultHeight);
                    }
                    else
                    {
                        resultHeight = sourceImage.Height;
                        resultWidth = (int)Math.Truncate(sourceImage.Height / coef);
                        return new Rectangle((sourceImage.Width - resultWidth) / 2, 0, resultWidth, resultHeight);
                    }

                case ScaleMode.Insert:
                    return new Rectangle(0, 0, sourceImage.Width, sourceImage.Height);

                default:
                    return new Rectangle(0, 0, sourceImage.Width, sourceImage.Height);
            }
        }
开发者ID:fathurxzz,项目名称:aleqx,代码行数:33,代码来源:GraphicsHelper.cs

示例7: GalleryModelBuilder

        public GalleryModelBuilder(String baseHttpUrl, String siteName, String galleryHttpRootPath, String contentFilePath, String galleryRootFilePath, ScaleMode scaledImageScaleMode, double scaledImageWidth, double scaledImagedHeight, ScaleMode thumbScaleMode, double thumbImageWidth, double thumbImagedHeight)
        {
            _contentFilePath = contentFilePath;
            _baseHttpUrl = baseHttpUrl;
            _galleryContentRootFilePath = galleryRootFilePath;
            _galleryContentRootHttpPath = galleryHttpRootPath;

            _galleryHttpPathFormat = Settings.Default.Http_GalleryHttpPathFormat;
            _galleryHttpEnhancedPathFormat = Settings.Default.Http_GalleryHttpEnhancedPathFormat;
            _galleriesIndexHttpPathFormat = Settings.Default.Http_GalleriesIndexHttpPathFormat;
            _galleryCoverFileName = Settings.Default.File_GalleryCoverFileName;

            _imageFileTypeFilter = Settings.Default.Image_FileTypeFilter;

            _galleryFolderOriginalImages = Settings.Default.Folders_OringinalImages;
            _galleryFolderScaledImages = Settings.Default.Folders_ScaledImages;
            _galleryFolderThumbs = Settings.Default.Folders_Thumbs;

            _zipFileLQFormat = Settings.Default.Zip_FileNameFormat_LowQuality;
            _zipFileHQFormat = Settings.Default.Zip_FileNameFormat_HighQuality;

            _galleriesIndexHttpPath = String.Format(_galleriesIndexHttpPathFormat, _baseHttpUrl);

            _imageProcessor = new GalleryImageProcessor(scaledImageScaleMode, scaledImageWidth, scaledImagedHeight, thumbScaleMode, thumbImageWidth, thumbImagedHeight);
            _dataProcessor = new GalleryDataProcessor();
            _feedBuilder = new GalleryFeedBuilder(siteName, _galleriesIndexHttpPath);
            _coverRenderer = new GalleryCoverRenderer(_contentFilePath);
        }
开发者ID:Creou,项目名称:WebGalleryProcessor,代码行数:28,代码来源:GalleryModelBuilder.cs

示例8: Scale

        public static UrlBuilder Scale(this UrlBuilder target, ScaleMode mode)
        {
            if(target == null)
                throw new ArgumentNullException(nameof(target));

            target.QueryCollection.Add("scale", AddScaleString(mode));
            return target;
        }
开发者ID:valdisiljuconoks,项目名称:ImageResizer.Plugins.EPiServerBlobReader,代码行数:8,代码来源:UrlBuilderExtensions.cs

示例9: endDrag

 public void endDrag()
 {
     if (scaleMode == ScaleMode.none)
         return;
     scaleMode = ScaleMode.none;
     editableObject.draged = false;
     this.enabled = false;
     editableObject.rigidbody.detectCollisions = true;
 }
开发者ID:orange030,项目名称:modelPainter,代码行数:9,代码来源:Editable2DObjectScale.cs

示例10: Image

 /// <summary>
 /// 
 /// </summary>
 /// <param name="position"></param>
 /// <param name="size"></param>
 /// <param name="tex"></param>
 /// <param name="texCoords"></param>
 /// <param name="scaleMode"></param>
 /// <param name="drawAlpha"></param>
 /// <param name="drawTransparent"></param>
 /// <param name="mat"></param>
 public Image( Vector2 position, Vector2 size, Texture tex = null, Rect? texCoords = null, ScaleMode scaleMode = ScaleMode.ScaleToFit, bool drawAlpha = false, bool drawTransparent = true, Material mat = null ) : base( position, size )
 {
     DrawTexture         = tex;
     Scale               = scaleMode;
     DrawAlpha           = drawAlpha;
     DrawTransparent     = drawTransparent;
     DrawMaterial        = mat;
     TexCoords           = texCoords;
 }
开发者ID:ChelseaLing,项目名称:UForms,代码行数:20,代码来源:Image.cs

示例11: BasicButtonGUI

 public BasicButtonGUI(Rect r, Texture down, Texture up, Texture disableDown, Texture disableUp, bool bKeepSt = true)
 {
     TexDown = down;
     TexUp = up;
     TexDownDisable = disableDown;
     TexUpDisable = disableUp;
     rec = r;
     mKeepState = bKeepSt;
     scaleMode = ScaleMode.ScaleToFit;
     disableOnMouseMove = true;
 }
开发者ID:tonylavenders,项目名称:test-video-record,代码行数:11,代码来源:BasicButtonGUI.cs

示例12: Reset

		public override void Reset()
		{
			texture = null;
			left = 0;
			top = 0;
			width = 1;
			height = 1;
			scaleMode = ScaleMode.StretchToFill;
			alphaBlend = true;
			imageAspect = 0;
			normalized = true;
		}
开发者ID:AlexanderUrbano,项目名称:shapewars,代码行数:12,代码来源:DrawTexture.cs

示例13: TileGUItexture

 //-----------------------------------------------------
 // Affiche une texture tilée. A appeler d'un OnGUI
 // (la texture sera devant toutes les GUITextures).
 public static void TileGUItexture(Texture texture, Rect tile, Rect areaToFill, ScaleMode scaleMode)
 {
     // Tiles an <areaToFill> with a <texture> which is scaled to the size
     // of a <tile> using a given <scaleMode>. Author: Isaac Manning Dart
     for (float y = areaToFill.y; y < areaToFill.y + areaToFill.height; y = y + tile.height)
     {
         for (float x = areaToFill.x; x < areaToFill.x + areaToFill.width; x = x + tile.width)
         {
             tile.x = x; tile.y = y;
             GUI.DrawTexture(tile, texture, scaleMode);
         }
     }
 }
开发者ID:gviaud,项目名称:OS-unity-5,代码行数:16,代码来源:Utils.cs

示例14: Reset

 public override void Reset()
 {
     this.texture = null;
     this.screenRect = null;
     this.left = 0f;
     this.top = 0f;
     this.width = 1f;
     this.height = 1f;
     this.scaleMode = ScaleMode.StretchToFill;
     this.alphaBlend = true;
     this.imageAspect = 0f;
     this.normalized = true;
 }
开发者ID:GameDiffs,项目名称:TheForest,代码行数:13,代码来源:DrawTexture.cs

示例15: GalleryImageProcessor

 public GalleryImageProcessor(ScaleMode scaledImageScaleMode,
                              double scaledImageWidth,
                              double scaledImagedHeight,
                              ScaleMode thumbScaleMode,
                              double thumbImageWidth,
                              double thumbImagedHeight)
 {
     _scaledImageScaleMode = scaledImageScaleMode;
     _scaledImageWidth = scaledImageWidth;
     _scaledImagedHeight = scaledImagedHeight;
     _thumbScaleMode = thumbScaleMode;
     _thumbImageWidth = thumbImageWidth;
     _thumbImageHeight = thumbImagedHeight;
 }
开发者ID:Creou,项目名称:WebGalleryProcessor,代码行数:14,代码来源:GalleryImageProcessor.cs


注:本文中的ScaleMode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。