ImageResizer  3.4.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events
Static Public Member Functions | Public Attributes | List of all members
ImageResizer.Util.Utils Class Reference

Static Public Member Functions

static Color parseColor (string value, Color defaultValue)
 
static string writeColor (Color value)
 
static double[] parseList (string text, double defaultValue)
 Parses lists in the form "3,4,5,2,5" and "(3,4,40,50)". If a number cannot be parsed (i.e, number 2 in "5,,2,3") defaultValue is used. More...
 
static int getInt (NameValueCollection q, string name, int defaultValue)
 
static float getFloat (NameValueCollection q, string name, float defaultValue)
 
static double getDouble (NameValueCollection q, string name, double defaultValue)
 
static bool getBool (NameValueCollection q, string name, bool defaultValue)
 
static T parseEnum< T > (string value, T defaultValue)
 
static void copyStream (Stream source, Stream dest)
 Copies all remaining data from 'source' to 'dest' More...
 
static RotateFlipType parseFlip (string sFlip)
 Returns RotateNoneFlipNone if not a recognized value. More...
 
static double parseRotate (string s)
 Returns 0 if not a recognized value. Rounds the value to 0, 90, 180, or 270 More...
 
static double normalizeTo90Intervals (double d)
 
static RotateFlipType combineFlipAndRotate (RotateFlipType flip, double angle)
 
static string writeFlip (RotateFlipType flip)
 Throws an exception if the specified value is unsupported. Rotation values are not supported, and should be specified with the Rotate or srcRotate command. More...
 
static StretchMode parseStretch (string value)
 
static string writeStretch (StretchMode value)
 
static KeyValuePair< CropUnits,
double > 
parseCropUnits (string value)
 
static string writeCropUnits (KeyValuePair< CropUnits, double > value)
 
static ScaleMode parseScale (string value)
 
static string writeScale (ScaleMode value)
 
static KeyValuePair< CropMode,
double[]> 
parseCrop (string value)
 
static string writeCrop (CropMode mode, double[] coords)
 
static BoxPadding parsePadding (string value)
 Parses padding, allowing syntax (all) and (left, top, right, bottom). Parens are optional. More...
 
static PointF parsePointF (string value, PointF defaultValue)
 
static string writePadding (BoxPadding p)
 
static void DrawOuterGradient (Graphics g, PointF[] poly, Color inner, Color outer, float width)
 Draws a gradient around the specified polygon. Fades from 'inner' to 'outer' over a distance of 'width' pixels. More...
 

Public Attributes

const NumberStyles floatingPointStyle
 

Detailed Description

Definition at line 16 of file Utils.cs.

Member Function Documentation

static void ImageResizer.Util.Utils.copyStream ( Stream  source,
Stream  dest 
)
inlinestatic

Copies all remaining data from 'source' to 'dest'

Parameters
source
dest

Definition at line 102 of file Utils.cs.

102  {
103  StreamExtensions.CopyToStream(source, dest, false, 0x1000);
104  }
static void ImageResizer.Util.Utils.DrawOuterGradient ( Graphics  g,
PointF[]  poly,
Color  inner,
Color  outer,
float  width 
)
inlinestatic

Draws a gradient around the specified polygon. Fades from 'inner' to 'outer' over a distance of 'width' pixels.

Parameters
g
poly
inner
outer
width

Definition at line 253 of file Utils.cs.

253  {
254  ImageResizer.Plugins.Basic.DropShadow.DrawOuterGradient(g, poly, inner, outer, width);
255  }
static RotateFlipType ImageResizer.Util.Utils.parseFlip ( string  sFlip)
inlinestatic

Returns RotateNoneFlipNone if not a recognized value.

Parameters
sFlip
Returns

Definition at line 114 of file Utils.cs.

114  {
115  return (RotateFlipType)ParseUtils.ParsePrimitive<FlipMode>(sFlip, FlipMode.None);
116  }
FlipMode
Horizontal and vertical flipping. Convertible to System.Drawing.RotateFlipType by casting...
static double [] ImageResizer.Util.Utils.parseList ( string  text,
double  defaultValue 
)
inlinestatic

Parses lists in the form "3,4,5,2,5" and "(3,4,40,50)". If a number cannot be parsed (i.e, number 2 in "5,,2,3") defaultValue is used.

Parameters
text
defaultValue
Returns

Definition at line 32 of file Utils.cs.

32  {
33  text = text.Trim(' ', '(', ')');
34  string[] parts = text.Split(new char[] { ',' }, StringSplitOptions.None);
35  double[] vals = new double[parts.Length];
36  for (int i = 0; i < parts.Length; i++) {
37  if (!double.TryParse(parts[i], floatingPointStyle, NumberFormatInfo.InvariantInfo, out vals[i]))
38  vals[i] = defaultValue;
39  }
40  return vals;
41  }
static BoxPadding ImageResizer.Util.Utils.parsePadding ( string  value)
inlinestatic

Parses padding, allowing syntax (all) and (left, top, right, bottom). Parens are optional.

Parameters
value
Returns

Definition at line 218 of file Utils.cs.

218  {
219  //Default to none if null
220  if (string.IsNullOrEmpty(value)) return BoxPadding.Empty;
221 
222  double[] coords = parseList(value, 0);
223  if (coords.Length == 1) return new BoxPadding(coords[0]);
224  if (coords.Length == 4) return new BoxPadding(coords[0], coords[1], coords[2], coords[3]);
225 
226  return BoxPadding.Empty; //Unrecognized value;
227  }
Represents the widths of edges of a box.
Definition: BoxPadding.cs:12
static double[] parseList(string text, double defaultValue)
Parses lists in the form &quot;3,4,5,2,5&quot; and &quot;(3,4,40,50)&quot;. If a number cannot be parsed (i...
Definition: Utils.cs:32
static double ImageResizer.Util.Utils.parseRotate ( string  s)
inlinestatic

Returns 0 if not a recognized value. Rounds the value to 0, 90, 180, or 270

Returns

Definition at line 122 of file Utils.cs.

122  {
123 
124  if (!string.IsNullOrEmpty(s)) {
125  double temp;
126  if (!double.TryParse(s,floatingPointStyle, NumberFormatInfo.InvariantInfo, out temp)) return 0;
127 
128  return normalizeTo90Intervals(temp);
129  }
130  return 0;
131  }
static string ImageResizer.Util.Utils.writeFlip ( RotateFlipType  flip)
inlinestatic

Throws an exception if the specified value is unsupported. Rotation values are not supported, and should be specified with the Rotate or srcRotate command.

Returns

Definition at line 146 of file Utils.cs.

146  {
147  if (flip == RotateFlipType.RotateNoneFlipNone) return "none";
148  if (flip == RotateFlipType.RotateNoneFlipX) return "x";
149  if (flip == RotateFlipType.RotateNoneFlipY) return "y";
150  if (flip == RotateFlipType.RotateNoneFlipXY) return "xy";
151 
152  throw new ArgumentException("Valid flip values are RotateNoneFlipNone, RotateNoneFlipX, RotateNoneFlipY, and RotateNoneFlipXY. Rotation must be specified with Rotate or srcRotate instead. Received: " + flip.ToString());
153  }

Member Data Documentation

const NumberStyles ImageResizer.Util.Utils.floatingPointStyle
Initial value:
= NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite |
NumberStyles.AllowLeadingSign | NumberStyles.AllowDecimalPoint | NumberStyles.AllowThousands | NumberStyles.AllowExponent

Definition at line 42 of file Utils.cs.


The documentation for this class was generated from the following file: