我已经碰过这几次,并认为把它放在那里会很好.什么是你最好的图像调整大小和/或裁剪逻辑.想法是使用目标图像,尺寸和裁剪标记调用某些方法 - 这将返回或保存或任何所需图像.
我的下面.从VB转换为C#所以是的,会有小错误,但逻辑是我们正在看的.
// INIT
// On/off
bool WeAreCropping = true;
// Get some dimensions
int TargetWidth = RequestedWidth;
int TargetHeight = RequestedHeight;
int SourceWidth = SourceImage.Width;
int SourceHeight = SourceImage.Height;
int ResizeWidth = TargetWidth;
int ResizeHeight = TargetHeight;
// GET RESIZE VALUES
// Are we cropping?
if (WeAreCropping) {
// Get source and target aspect ratio
double SourceAspectRatio = SourceWidth / SourceHeight;
double TargetAspectRatio = TargetWidth / TargetHeight;
// Compare aspect ratios to find out if we should …Run Code Online (Sandbox Code Playgroud) 请帮帮我们.我只是想声明一个简单的结果树片段并迭代它.
...
<xsl:variable name="rtf">
<item-list>
<item id="1">one</item>
<item id="2">two</item>
<item id="3">three</item>
<item id="4">four</item>
</item-list>
</xsl:variable>
<xsl:for-each select="msxsl:node-set($rtf)/item-list/item">
<xsl:value-of select="@id"/>
</xsl:for-each>
Run Code Online (Sandbox Code Playgroud)
...
我完全错误地认为这是如何工作的?
编辑: 我正在使用.NET XslCompiledTransform并具有正确的msxsl名称空间声明 - xmlns:msxsl ="urn:schemas-microsoft-com:xslt"
转换执行得很好 - 问题是什么都没有输出
我有一个有趣的XSL场景由你们运行.到目前为止,我的解决方案似乎效率低下(转换时间显着增加),所以我想把它放在那里.
场景 从以下XML我们需要获取每个类别的最新新闻项的ID.
XML 在XML中我有一个新闻项列表,一个新闻类别列表和一个项目类别关系列表.项目列表和项目类别列表也可以是随机顺序(不是按日期排序).
<news>
<itemlist>
<item id="1">
<attribute name="title">Great new products</attribute>
<attribute name="startdate">2009-06-13T00:00:00</attribute>
</item>
<item id="2">
<attribute name="title">FTSE down</attribute>
<attribute name="startdate">2009-10-01T00:00:00</attribute>
</item>
<item id="3">
<attribute name="title">SAAB go under</attribute>
<attribute name="startdate">2008-01-22T00:00:00</attribute>
</item>
<item id="4">
<attribute name="title">M&A on increase</attribute>
<attribute name="startdate">2010-05-11T00:00:00</attribute>
</item>
</itemlist>
<categorylist>
<category id="1">
<name>Finance</name>
</category>
<category id="2">
<name>Environment</name>
</category>
<category id="3">
<name>Health</name>
</category>
</categorylist>
<itemcategorylist>
<itemcategory itemid="1" categoryid="2" />
<itemcategory itemid="2" categoryid="3" />
<itemcategory itemid="3" categoryid="1" />
<itemcategory itemid="4" categoryid="1" />
<itemcategory itemid="4" categoryid="2" />
<itemcategory itemid="2" …Run Code Online (Sandbox Code Playgroud)