本文整理汇总了C#中Transformation类的典型用法代码示例。如果您正苦于以下问题:C# Transformation类的具体用法?C# Transformation怎么用?C# Transformation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Transformation类属于命名空间,在下文中一共展示了Transformation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BrightnessBarChanged
private void BrightnessBarChanged()
{
Transformation transform = new Transformation();
transform.type = TransformationType.BRIGHTNESS_CHANGE;
transform.argument = getNormalizedBrightnessLevel();
TransformImage(transform);
}
示例2: CalculateImageAndTransformationMatrix
private void CalculateImageAndTransformationMatrix(string fileName)
{
var zipFile = new Ionic.Zip.ZipFile(fileName);
var mapSize = new Size();
Transformation = new Transformation();
// get entry for kml file and image file
KmlDocument kmlDocument = null;
foreach (var entry in zipFile)
{
if (entry.FileName == entry.LocalFileName && Path.GetExtension(entry.FileName) == ".kml")
{
using (var kmlStream = new MemoryStream())
{
entry.Extract(kmlStream);
kmlStream.Position = 0;
kmlDocument = new KmlDocument(kmlStream);
}
break;
}
}
if (kmlDocument != null)
{
// we have got a kml document, get map image file stream from it
foreach (var entry in zipFile)
{
if (entry.FileName == kmlDocument.ImageFileName)
{
ImageStream = new MemoryStream();
entry.Extract(ImageStream);
ImageStream.Position = 0;
// check if image is QR jpeg
var ed = QuickRouteJpegExtensionData.FromStream(ImageStream);
if(ed != null)
{
// get transformation matrix from QR jpeg metadata
Transformation = ed.Sessions.CalculateAverageTransformation();
ImageStream.Position = 0;
return;
}
else
{
// it is not, use normal image bounds
ImageStream.Position = 0;
mapSize = Image.FromStream(ImageStream).Size; // need to get image object to get image size
}
ImageStream.Position = 0;
break;
}
}
}
if (kmlDocument != null && ImageStream != null)
{
// finally, calculate the transformation
Transformation = new Transformation(kmlDocument.LongLatBox, mapSize);
}
}
示例3: CloudinaryImage_WithAutoAngle_AddsPosition
public void CloudinaryImage_WithAutoAngle_AddsPosition()
{
var transformation = new Transformation(240, 240) {Angle = Angle.Auto};
string url = Url.CloudinaryImage("angled", transformation).ToString();
Assert.AreEqual("http://res.cloudinary.com/test/image/upload/w_240,h_240,a_auto/angled.jpg", url);
}
示例4: MeshNode
public MeshNode(string label, NsNode parent, double[,] initTransform)
: this(label, parent)
{
for (int i = 0; i < 3; i++)
initTransform[i, 3] *= 1000;
m_T = new Transformation(initTransform);
}
示例5: CloudinaryImage_WithEffect_AddsEffect
public void CloudinaryImage_WithEffect_AddsEffect()
{
var transformation = new Transformation(30, 90);
transformation.Effect = "sepia";
string url = Url.CloudinaryImage("effected", transformation).ToString();
Assert.AreEqual("http://res.cloudinary.com/test/image/upload/w_30,h_90,e_sepia/effected.jpg", url);
}
示例6: CloudinaryImage_WithFixedCroppingPositionSet_AddPosition
public void CloudinaryImage_WithFixedCroppingPositionSet_AddPosition()
{
var transformation = new Transformation(240, 240) { Crop = CropMode.Crop };
transformation.SetFixedCroppingPosition(350, 510);
string url = Url.CloudinaryImage("cropme", transformation).ToString();
Assert.AreEqual("http://res.cloudinary.com/test/image/upload/w_240,h_240,x_350,y_510,c_crop/cropme.jpg", url);
}
示例7: TestBaseTransformationChain
public void TestBaseTransformationChain()
{
// should support base transformation
Transformation transformation = new Transformation().X(100).Y(100).Crop("fill").Chain().Crop("crop").Width(100);
string uri = api.UrlImgUp.Transform(transformation).BuildUrl("test");
Assert.AreEqual("100", transformation.HtmlWidth);
Assert.AreEqual("http://res.cloudinary.com/testcloud/image/upload/c_fill,x_100,y_100/c_crop,w_100/test", uri);
}
示例8: TestBackground
public void TestBackground()
{
// should support background
Transformation transformation = new Transformation().Background("red");
String result = m_api.UrlImgUp.Transform(transformation).BuildUrl("test");
Assert.AreEqual(m_defaultImgUpPath + "b_red/test", result);
transformation = new Transformation().Background("#112233");
result = m_api.UrlImgUp.Transform(transformation).BuildUrl("test");
Assert.AreEqual(m_defaultImgUpPath + "b_rgb:112233/test", result);
}
示例9: TestBackground
public void TestBackground()
{
// should support background
Transformation transformation = new Transformation().Background("red");
String result = api.UrlImgUp.Transform(transformation).BuildUrl("test");
Assert.AreEqual("http://res.cloudinary.com/testcloud/image/upload/b_red/test", result);
transformation = new Transformation().Background("#112233");
result = api.UrlImgUp.Transform(transformation).BuildUrl("test");
Assert.AreEqual("http://res.cloudinary.com/testcloud/image/upload/b_rgb:112233/test", result);
}
示例10: EndIf
public void EndIf()
{
Transformation transformation = new Transformation().IfCondition("w_lt_200").Crop("fill").Height(120).Width(80).Effect("sharpen")
.Chain().Effect("brightness", 50)
.Chain().Effect("shadow").Color("red")
.EndIf();
string sTransform = transformation.ToString();
Assert.IsTrue(sTransform.EndsWith("if_end"), "should include the if_end as the last parameter in its component");
Assert.AreEqual("if_w_lt_200/c_fill,e_sharpen,h_120,w_80/e_brightness:50/co_red,e_shadow/if_end", sTransform, "should be proper transformation string");
}
示例11: TestAngle
public void TestAngle()
{
// should support angle
Transformation transformation = new Transformation().Angle(12);
String result = m_api.UrlImgUp.Transform(transformation).BuildUrl("test");
Assert.AreEqual(m_defaultImgUpPath + "a_12/test", result);
transformation = new Transformation().Angle("exif", "12");
result = m_api.UrlImgUp.Transform(transformation).BuildUrl("test");
Assert.AreEqual(m_defaultImgUpPath + "a_exif.12/test", result);
}
示例12: CanInsertCollectionOfItemsToScene
public void CanInsertCollectionOfItemsToScene()
{
var map = new Map();
var transformation = new Transformation(500, 500);
var transformation2 = new Transformation(100, 100);
map.Insert("grass", new List<Transformation> { transformation, transformation2 });
Assert.AreEqual(map.Scene["grass"].Count, 2);
}
示例13: CanInsertItemToScene
public void CanInsertItemToScene()
{
var map = new Map();
var transformation = new Transformation(500, 500);
map.Insert("grass", transformation);
Assert.AreEqual(map.Scene["grass"].First().Translation, transformation.Translation);
}
示例14: TestAngle
public void TestAngle()
{
// should support angle
Transformation transformation = new Transformation().Angle(12);
String result = api.UrlImgUp.Transform(transformation).BuildUrl("test");
Assert.AreEqual("http://res.cloudinary.com/testcloud/image/upload/a_12/test", result);
transformation = new Transformation().Angle("exif", "12");
result = api.UrlImgUp.Transform(transformation).BuildUrl("test");
Assert.AreEqual("http://res.cloudinary.com/testcloud/image/upload/a_exif.12/test", result);
}
示例15: EndIf2
public void EndIf2()
{
Transformation transformation = new Transformation().IfCondition().Width("gt", 100).And().Width("lt", 200).Then().Width(50).Crop("scale").EndIf();
Assert.AreEqual("if_w_gt_100_and_w_lt_200/c_scale,w_50/if_end", transformation.ToString(), "should serialize to 'if_end'");
transformation = new Transformation().IfCondition().Width("gt", 100).And().Width("lt", 200).Then().Width(50).Crop("scale").EndIf();
Assert.AreEqual("if_w_gt_100_and_w_lt_200/c_scale,w_50/if_end", transformation.ToString(), "force the if clause to be chained");
transformation = new Transformation().IfCondition().Width("gt", 100).And().Width("lt", 200).Then().Width(50).Crop("scale").IfElse().Width(100).Crop("crop").EndIf();
Assert.AreEqual("if_w_gt_100_and_w_lt_200/c_scale,w_50/if_else/c_crop,w_100/if_end", transformation.ToString(), "force the if_else clause to be chained");
}