本文整理汇总了C#中ScaleMode类的典型用法代码示例。如果您正苦于以下问题:C# ScaleMode类的具体用法?C# ScaleMode怎么用?C# ScaleMode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ScaleMode类属于命名空间,在下文中一共展示了ScaleMode类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: FlexPaginator
public FlexPaginator(C1FlexGrid flex, ScaleMode scaleMode, Size pageSize, Thickness margin, int maxPages)
{
// save parameters
_margin = margin;
_scaleMode = scaleMode;
_pageSize = pageSize;
// adjust page size for margins before building grid images
pageSize.Width -= (margin.Left + margin.Right);
pageSize.Height -= (margin.Top + margin.Bottom);
// get grid images for each page
_pages = flex.GetPageImages(scaleMode, pageSize, maxPages);
}
开发者ID:mdjabirov,项目名称:C1Decompiled,代码行数:14,代码来源:FlexPaginator.cs
示例17: AddScaleString
private static string AddScaleString(ScaleMode value)
{
if(value == ScaleMode.Both)
return "both";
if(value == ScaleMode.DownscaleOnly)
return "down";
if(value == ScaleMode.UpscaleCanvas)
return "canvas";
if(value == ScaleMode.UpscaleOnly)
return "up";
throw new NotImplementedException("Unrecognized ScaleMode value: " + value);
}
开发者ID:valdisiljuconoks,项目名称:ImageResizer.Plugins.EPiServerBlobReader,代码行数:16,代码来源:UrlBuilderExtensions.cs
示例18: CalculateSourceRect
private static Rectangle CalculateSourceRect(string name, Size sourceImage, ScaleMode scaleMode)
{
int previewHeight = limitHeight.ContainsKey(name) ? limitHeight[name] : 0;
int previewWidth = limitWidth.ContainsKey(name) ? limitWidth[name] : 0;
int resultWidth;
int resultHeight;
if (scaleMode == ScaleMode.Cut)
{
double wRatio = (double)sourceImage.Width / (double)previewWidth;
double hRatio = (double)sourceImage.Height / (double)previewHeight;
double coef = (double)previewHeight / (double)previewWidth;
if (wRatio < hRatio)
{
resultWidth = sourceImage.Width;
resultHeight = (int)Math.Truncate(sourceImage.Width * coef);
}
else
{
resultHeight = sourceImage.Height;
resultWidth = (int)Math.Truncate(sourceImage.Height / coef);
}
return new Rectangle(0, 0, resultWidth, resultHeight);
}
else
{
if (sourceImage.Width > sourceImage.Height)
{
int shift = (int)Math.Truncate((sourceImage.Width - sourceImage.Height) / (double)2);
return new Rectangle(0, -shift, sourceImage.Width, sourceImage.Height + shift * 2);
}
else
{
int shift = (int)Math.Truncate((sourceImage.Height - sourceImage.Width) / (double)2);
return new Rectangle(-shift, 0, sourceImage.Width + shift * 2, sourceImage.Height);
}
}
}
开发者ID:fathurxzz,项目名称:aleqx,代码行数:43,代码来源:GraphicsHelper.cs
示例19: ImageView
public ImageView(ImageView imageView)
{
LeftMargin = imageView.LeftMargin;
TopMargin = imageView.TopMargin;
RightMargin = imageView.RightMargin;
BottomMargin = imageView.BottomMargin;
Width = imageView.Width;
Height = imageView.Height;
Position = imageView.Position;
Scale = imageView.Scale;
Offset = imageView.Offset;
ImageTexture = imageView.ImageTexture;
ImageRect = imageView.ImageRect;
ImageScaleMode = imageView.ImageScaleMode;
IsDirty = imageView.IsDirty;
Rect = imageView.Rect;
}
开发者ID:phicuong08,项目名称:memorymatch,代码行数:20,代码来源:ImageView.cs
示例20: SetRectangle
/// <summary>
/// Sets the rectangle for this item
/// <summary>
/// <param name="x">The x coordinate.</param>
/// <param name="y">The y coordinate.</param>
/// <param name="w">The width.</param>
/// <param name="h">The height.</param>
public virtual void SetRectangle(float x, float y, float w, float h, bool isWorld, ScaleMode scale)
{
Scale = scale;
WorldCoords = Vector2.zero;
IsWorld = isWorld;
if (w <= 1 && h <= 1 )
{
w = Screen.width * w;
h = Screen.height * h;
}
if (isWorld)
{
WorldCoords = new Vector2(x, y);
}
else
{
if (x <= 1 && y <= 1)
{
x = Screen.width * x;
y = Screen.height * y;
}
}
if (Scale == ScaleMode.ScaleToFit)
{
if (Content.image != null)
{
float r =
Math.Min(w / Content.image.width,
h / Content.image.height);
w = Content.image.width * r;
h = Content.image.height * r;
}
}
Rectangle = new Rect(x, y, w, h);
}
开发者ID:kasmeltz,项目名称:PizzaEmpire,代码行数:47,代码来源:GUIItem.cs
注:本文中的ScaleMode类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论