private int DefaultMajorInterval(ScaleModes iScaleMode) { int iInterval = 10; // Set scaling switch (iScaleMode) { // Determines the *relative* proportions of each scale case ScaleModes.smPoints: iInterval = 72; break; case ScaleModes.smPixels: iInterval = 100; break; case ScaleModes.smCentimetres: iInterval = 1; break; case ScaleModes.smInches: iInterval = 1; break; case ScaleModes.smMillimetres: iInterval = 1; break; } return(iInterval); }
/// <summary> /// Creates a new instance of FeatureSymbolizer /// </summary> protected FeatureSymbolizer() { _scaleMode = ScaleModes.Simple; _smoothing = true; _isVisible = true; _unit = GraphicsUnit.Pixel; }
/// <summary> /// 缩放图片 /// </summary> /// <param name="img">The img.</param> /// <param name="savePath">The save path.</param> /// <param name="scaleLength">Length of the scale.</param> /// <param name="sMode">The s mode.</param> /// <param name="encoder">The encoder.</param> /// <summary> /// 缩放图片 /// </summary> /// <param name="img">The img.</param> /// <param name="savePath">The save path.</param> /// <param name="scaleLength">Length of the scale.</param> /// <param name="sMode">The s mode.</param> public static void Scale(this Image img, string savePath, int scaleLength, ScaleModes sMode) { Image newMap = img.Scale(scaleLength, sMode); //throw new Exception(img.RawFormat.ToString()); newMap.Save(savePath, img.RawFormat); newMap.Dispose(); }
void UpdateBarPositions() { float hCoef = _webCamTexture.width * 1f / horizontalDivision; float vCoef = _webCamTexture.height * 1f / verticalDivision; float yMax = boundingBox2.y * 0.5f; float yMin = boundingBox1.y - yMax; float yCoef = yMax - yMin; float yCoefInv = 1.0f / yCoef; var colors = _webCamTexture.GetPixels(); int h = 0; int v = 0; for (int i = 0; i < _allBar.Length; i++) { var bar = _allBar[i]; var color = colors[(int)(v * vCoef) * _webCamTexture.width + _webCamTexture.width - 1 - (int)(h * hCoef)]; float scale = 0f; if (_useNegaScale) { scale = Mathf.Lerp( (bar.localPosition.y - yMin) * yCoefInv, 1 - ScaleModes.GetScale(color, _scaleMode), lerpFactor ); } else { scale = Mathf.Lerp( (bar.localPosition.y - yMin) * yCoefInv, ScaleModes.GetScale(color, _scaleMode), lerpFactor ); } bar.localPosition = new Vector3( bar.localPosition.x, yMin + scale * yCoef, bar.localPosition.z ); _allMaterial[i].color = Color.Lerp( _allMaterial[i].color, ScaleModes.GetColor(color, _scaleMode), lerpFactor ); v++; if (!(v - verticalDivision < 0)) { v = 0; h++; } } }
public static Image Resize(this Image img, int scaleLength, ScaleModes sMode) { int xwidth = img.Width; int xheight = img.Height; if (xwidth <= scaleLength && xheight <= scaleLength) { return(img); } //图片缩小后的尺寸,画布尺寸 int lWidht = 0, lHeight = 0; switch (sMode) { case ScaleModes.Both: if (xwidth > xheight) { lWidht = scaleLength; lHeight = (xheight * scaleLength) / xwidth; } else { lWidht = (xwidth * scaleLength) / xheight; lHeight = scaleLength; } break; case ScaleModes.Height: lWidht = (xwidth * scaleLength) / xheight; lHeight = scaleLength; break; case ScaleModes.Width: lWidht = scaleLength; lHeight = (xheight * scaleLength) / xwidth; break; case ScaleModes.Squre: lWidht = scaleLength; lHeight = scaleLength; break; } return(img.Resize(lWidht, lHeight)); }
private int DefaultScale(ScaleModes iScaleMode) { int iScale = 100; // Set scaling switch (iScaleMode) { // Determines the *relative* proportions of each scale case ScaleModes.smPoints: iScale = 660; // 132; break; case ScaleModes.smPixels: iScale = 100; break; case ScaleModes.smCentimetres: iScale = 262; // 53; break; case ScaleModes.smInches: iScale = 660; // 132; break; case ScaleModes.smMillimetres: iScale = 27; break; } if (iScaleMode == ScaleModes.smPixels) { return(Convert.ToInt32(iScale * _ZoomFactor)); } return(Convert.ToInt32(iScale * _ZoomFactor * (_bActualSize ? (double)_DpiX / 480 : 0.2))); }
/// <summary> /// 上传一个用户头像 /// </summary> /// <param name="fileInput">The file input.</param> /// <param name="savingPath">The saving path.</param> /// <param name="scaleLength">Length of the scale.</param> /// <param name="sMode">The s mode.</param> public static void UploadUserIcon(this HtmlInputFile fileInput, string savingPath, int scaleLength, ScaleModes sMode) { System.Drawing.Image img = fileInput.ToImage(); img.Scale(savingPath, scaleLength, sMode); }
/// <summary> /// 缩放图片 /// </summary> /// <param name="img"></param> /// <param name="scaleLength"></param> /// <param name="sMode"></param> /// <returns></returns> public static Image Scale(this Image img, int scaleLength, ScaleModes sMode) { int xwidth = img.Width; int xheight = img.Height; if (xwidth <= scaleLength && xheight <= scaleLength) { return(img); } //图片缩小后的尺寸,画布尺寸 int lWidht = 0, lHeight = 0; switch (sMode) { case ScaleModes.Both: if (xwidth > xheight) { lWidht = scaleLength; lHeight = (xheight * scaleLength) / xwidth; } else { lWidht = (xwidth * scaleLength) / xheight; lHeight = scaleLength; } break; case ScaleModes.Height: lWidht = (xwidth * scaleLength) / xheight; lHeight = scaleLength; break; case ScaleModes.Width: lWidht = scaleLength; lHeight = (xheight * scaleLength) / xwidth; break; case ScaleModes.Squre: lWidht = scaleLength; lHeight = scaleLength; break; } PixelFormat Format = img.PixelFormat; if (Format.ToString().Contains("Indexed")) { Format = PixelFormat.Format24bppRgb; } using (Bitmap newMap = new Bitmap(lWidht, lHeight, Format)) { using (Graphics g = Graphics.FromImage(newMap)) { g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; g.InterpolationMode = InterpolationMode.HighQualityBicubic; g.PixelOffsetMode = PixelOffsetMode.HighQuality; if (sMode == ScaleModes.Squre) { if (xwidth > xheight) { //g.DrawImage(img, new Rectangle(0, 0, 75, 75), g.DrawImage(img, new RectangleF(0f, 0f, (float)lWidht, (float)lHeight), new RectangleF((float)((xwidth - xheight) / 2), 0f, (float)xheight, (float)xheight), GraphicsUnit.Pixel); } else { g.DrawImage(img, new RectangleF(0f, 0f, (float)lWidht, (float)lHeight), new RectangleF(0f, (float)((xheight - xwidth) / 2), (float)xwidth, (float)xwidth), GraphicsUnit.Pixel); } } else { g.DrawImage(img, new RectangleF(0f, 0f, (float)lWidht, (float)lHeight), new RectangleF(0f, 0f, (float)xwidth, (float)xheight), GraphicsUnit.Pixel); } return(newMap); } } }
/// <summary> /// Creates a new instance of TextSymbolizer /// </summary> public LabelSymbolizer() { _angle = 0; _borderEnabled = false; _borderColor = Color.Black; _backColor = Color.AntiqueWhite; _backColorEnabled = false; _dropShadowColor = Color.FromArgb(20, 0, 0, 0); _dropShadowEnabled = false; _dropShadowGeographicOffset = new Coordinate(0, 0); _dropShadowPixelOffset = new PointF(2F, 2F); _fontSize = 10F; _fontFamily = "Arial Unicode MS"; _fontStyle = FontStyle.Regular; _fontColor = Color.Black; _haloColor = Color.White; _haloEnabled = false; _scaleMode = ScaleModes.Symbolic; _labelMethod = LabelMethod.Centroid; _labelParts = LabelParts.LabelLargestPart; _preventCollisions = true; _priorityField = "FID"; }
/// <summary> /// Prints an image. /// </summary> /// <param name="image">Image to be printed</param> /// <param name="jobName">Name of the printing job</param> /// <param name="onFinishCallback"> /// Action to perform after printing is finished. /// Is performed even if the printing was cancelled. /// </param> /// <param name="colorMode">Color mode of printing</param> /// <param name="orientation">Sheet orientation of printing</param> /// <param name="scaleMode">Scale mode of printing</param> /// <exception cref="ArgumentNullException"></exception> public static void PrintImage([NotNull] Texture2D image, [NotNull] string jobName, Action onFinishCallback = null, ColorModes colorMode = ColorModes.Color, Orientations orientation = Orientations.Portrait, ScaleModes scaleMode = ScaleModes.Fit) { if (AGUtils.IsNotAndroid()) { return; } if (image == null) { throw new ArgumentNullException("image"); } if (jobName == null) { throw new ArgumentNullException("jobName"); } _printHelper = new AndroidJavaObject(C.AndroidPrintHelper, AGUtils.Activity); _printHelper.Call("setColorMode", (int)colorMode); _printHelper.Call("setOrientation", (int)orientation); _printHelper.Call("setScaleMode", (int)scaleMode); _onPrintSuccess = onFinishCallback; var helperClass = new AndroidJavaClass(C.PrintHelperUtilsClass); helperClass.CallStatic("printBitmap", jobName, AGUtils.Texture2DToAndroidBitmap(image), _printHelper); }
public ScaleModeChangedEventArgs(ScaleModes Mode) : base() { this.Mode = Mode; }