本文整理汇总了C#中MonoMac.AppKit.NSImage.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# NSImage.Dispose方法的具体用法?C# NSImage.Dispose怎么用?C# NSImage.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MonoMac.AppKit.NSImage
的用法示例。
在下文中一共展示了NSImage.Dispose方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateTextSprite
//.........这里部分代码省略.........
nsAttributes.ParagraphStyle = nsparagraphStyle;
var stringWithAttributes = new NSAttributedString(text, nsAttributes);
var realDimensions = stringWithAttributes.Size;
// Mac crashes if the width or height is 0
if (realDimensions == SizeF.Empty)
{
CCLog.Log("Native string:", "Dimensions of native NSAttributedString can not be 0,0");
return new CCTexture2D();
}
var dimensions = new SizeF(textDef.Dimensions.Width, textDef.Dimensions.Height);
var layoutAvailable = true;
//
// * Note * This seems to only effect Mac because iOS works fine without this work around.
// Right Alignment BoundingRectWithSize does not seem to be working correctly when the following conditions are set:
// 1) Alignment Right
// 2) No dimensions
// 3) There are new line characters embedded in the string.
//
// So we set alignment to Left, calculate our bounds and then restore alignement afterwards before drawing.
//
if (dimensions.Width <= 0)
{
dimensions.Width = 8388608;
layoutAvailable = false;
// Set our alignment variables to left - see notes above.
nsparagraphStyle.Alignment = NSTextAlignment.Left;
stringWithAttributes.Dispose();
stringWithAttributes = null;
stringWithAttributes = new NSAttributedString(text, nsAttributes);
}
if (dimensions.Height <= 0)
{
dimensions.Height = 8388608;
layoutAvailable = false;
}
// Calculate our bounding rectangle
var boundingRect = stringWithAttributes.BoundingRectWithSize(new SizeF((int)dimensions.Width, (int)dimensions.Height),
NSStringDrawingOptions.UsesLineFragmentOrigin);
if (!layoutAvailable)
{
if (dimensions.Width == 8388608)
{
dimensions.Width = boundingRect.Width;
// Restore our alignment before drawing - see notes above.
nsparagraphStyle.Alignment = textAlign;
stringWithAttributes.Dispose();
stringWithAttributes = null;
stringWithAttributes = new NSAttributedString(text, nsAttributes);
}
if (dimensions.Height == 8388608)
{
dimensions.Height = boundingRect.Height;
}
}