internal _ImageSourceTransforms UseTransforms() { if (_Transforms != null) { return(_Transforms); } _Transforms = new _ImageSourceTransforms(this, _SourceWidth, _SourceHeight); return(_Transforms); }
/// <summary> /// Sets the source bitmap size. /// </summary> /// <param name="width">The image width, in pixels.</param> /// <param name="height">The image height, in pixels.</param> /// <returns>Self.</returns> public ImageSource WithSourceSize(int width, int height) { if (width == _SourceWidth && height == _SourceHeight) { return(this); } _SourceWidth = width; _SourceHeight = height; _Transforms = null; return(this); }
/// <summary> /// Sets the source bitmap size. /// </summary> /// <param name="source">The new image source.</param> /// <param name="width">The image width, in pixels.</param> /// <param name="height">The image height, in pixels.</param> /// <returns>Self.</returns> public ImageSource WithSource(Object source, int width, int height) { if (source == _Source && width == _SourceWidth && height == _SourceHeight) { return(this); } _Source = source; _SourceWidth = width; _SourceHeight = height; _Transforms = null; return(this); }
/// <summary> /// expands the Texture coordinates and compensates the scale so the actual screen size remains unchanged. /// </summary> /// <param name="expand">The size to expand, in pixels</param> /// <returns>itself.</returns> /// <remarks> /// This method is useful for tightly packed tiled bitmaps, where we want to contract the texture half a pixel (expand = -0.5f) /// </remarks> public ImageSource WithExpandedSource(float expand) { var v2exp = new XY(expand); var s1 = _SourceUVMax - _SourceUVMin; _SourceUVMin -= v2exp; _SourceUVMax += v2exp; var s2 = _SourceUVMax - _SourceUVMin; _OutputScale = _OutputScale * s1 / s2; _Pivot = _Pivot * s2 / s1; _Transforms = null; return(this); }
/// <summary> /// Sets the mirror flags. /// </summary> /// <param name="mirrorX">The horizontal mirror.</param> /// <param name="mirrorY">The vertical mirror.</param> /// <returns>Self.</returns> public ImageSource WithMirror(bool mirrorX, bool mirrorY) { var o = _ImageFlags.None; if (mirrorX) { o |= _ImageFlags.FlipHorizontal; } if (mirrorY) { o |= _ImageFlags.FlipVertical; } if (_OrientationMask == o) { return(this); } _OrientationMask = o; _Transforms = null; return(this); }
/// <summary> /// Sets the new output scale. /// </summary> /// <param name="scale">The scale.</param> /// <returns>Self.</returns> public ImageSource WithScale(float scale) { _OutputScale = new XY(scale); _Transforms = null; return(this); }
/// <summary> /// Sets a new pivot/mirror precedence /// </summary> /// <param name="precedence">the mirror/pivot precedence.</param> /// <returns>Self.</returns> public ImageSource WithPivotPrecedence(bool precedence) { _PivotPrecedence = precedence; _Transforms = null; return(this); }
/// <summary> /// Sets a new pivot. /// </summary> /// <param name="pivot">The new pivot.</param> /// <returns>Self.</returns> public ImageSource WithPivot(Point2 pivot) { _Pivot = pivot.XY; _Transforms = null; return(this); }