本文整理汇总了C#中System.Windows.Controls.Image.Measure方法的典型用法代码示例。如果您正苦于以下问题:C# Image.Measure方法的具体用法?C# Image.Measure怎么用?C# Image.Measure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.Image
的用法示例。
在下文中一共展示了Image.Measure方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckImage
void CheckImage(BitmapImage img)
{
if(img.IsDownloading)
{
Dispatcher.InvokeAsync(() => CheckImage(img), DispatcherPriority.Background);
}
else
{
var el = new System.Windows.Controls.Image()
{
Source = img,
SnapsToDevicePixels = true,
UseLayoutRounding = true,
MinWidth = LedBadgeLib.BadgeCaps.Width,
MinHeight = LedBadgeLib.BadgeCaps.Height,
Width = img.Width * ((BitmapSource)img).DpiX / 96,
Stretch = Stretch.UniformToFill,
};
RenderOptions.SetBitmapScalingMode(img, BitmapScalingMode.NearestNeighbor);
el.Measure(new Size(LedBadgeLib.BadgeCaps.Width, LedBadgeLib.BadgeCaps.Height));
el.Arrange(new Rect(0, 0, LedBadgeLib.BadgeCaps.Width, LedBadgeLib.BadgeCaps.Height));
m_messageQueue.Enqueue(new LedBadgeLib.MessageQueueItem(new LedBadgeLib.WpfVisual(el, dither : Dither)));
};
}
示例2: PrintPage
private static UIElement PrintPage(BitmapSource bitmap)
{
var bitmapSize = new System.Windows.Size(bitmap.PixelWidth, bitmap.PixelHeight);
var image = new System.Windows.Controls.Image { Source = bitmap };
image.Measure(bitmapSize);
image.Arrange(new System.Windows.Rect(new System.Windows.Point(0, 0), bitmapSize));
return image;
}
示例3: ApplyCinemagraphButton_Click
private void ApplyCinemagraphButton_Click(object sender, RoutedEventArgs e)
{
if (CinemagraphInkCanvas.Strokes.Count == 0)
{
ShowWarning(ResMessage("Editor.Cinemagraph.WarningNoDrawing"), MessageIcon.Info);
return;
}
ActionStack.Did(ListFrames);
var dpi = ListFrames[0].ImageLocation.DpiOf();
var scaledSize = ListFrames[0].ImageLocation.ScaledSize();
#region Get the Strokes and Clip the Image
var image = ListFrames[0].ImageLocation.SourceFrom();
var rectangle = new RectangleGeometry(new Rect(new System.Windows.Point(0, 0), new System.Windows.Size(image.PixelWidth, image.PixelHeight)));
Geometry geometry = Geometry.Empty;
foreach (Stroke stroke in CinemagraphInkCanvas.Strokes)
{
geometry = Geometry.Combine(geometry, stroke.GetGeometry(), GeometryCombineMode.Union, null);
}
geometry = Geometry.Combine(geometry, rectangle, GeometryCombineMode.Xor, null);
var clippedImage = new System.Windows.Controls.Image
{
Height = image.PixelHeight,
Width = image.PixelWidth,
Source = image,
Clip = geometry
};
clippedImage.Measure(scaledSize);
clippedImage.Arrange(new Rect(scaledSize));
var imageRender = clippedImage.GetRender(dpi, scaledSize);
#endregion
Cursor = Cursors.AppStarting;
_overlayFramesDel = Overlay;
_overlayFramesDel.BeginInvoke(imageRender, dpi, true, OverlayCallback, null);
ClosePanel();
}
示例4: CheckTweetData
void CheckTweetData(string text, List<BitmapImage> images)
{
bool ready = true;
foreach(var img in images)
{
if(img.IsDownloading)
{
ready = false;
break;
}
}
if(ready)
{
Func<ImageSource, Image> makeImg = source =>
{
var el = new System.Windows.Controls.Image()
{
Source = source,
SnapsToDevicePixels = true,
UseLayoutRounding = true,
MinWidth = LedBadgeLib.BadgeCaps.Width,
MinHeight = LedBadgeLib.BadgeCaps.Height,
Width = source.Width * ((BitmapSource)source).DpiX / 96,
Stretch = Stretch.UniformToFill,
};
RenderOptions.SetBitmapScalingMode(source, BitmapScalingMode.NearestNeighbor);
el.Measure(new Size(LedBadgeLib.BadgeCaps.Width, LedBadgeLib.BadgeCaps.Height));
el.Arrange(new Rect(0, 0, LedBadgeLib.BadgeCaps.Width, LedBadgeLib.BadgeCaps.Height));
return el;
};
if(images.Count > 0)
{
m_messageQueue.Enqueue(new LedBadgeLib.MessageQueueItem(new LedBadgeLib.WpfVisual(makeImg(images[0]), dither: Dither)));
}
m_messageQueue.Enqueue(LedBadgeLib.WPF.MakeQueuedItem(LedBadgeLib.WPF.MakeSingleLineItem(text)));
for(int i = 1; i < images.Count; ++i)
{
m_messageQueue.Enqueue(new LedBadgeLib.MessageQueueItem(new LedBadgeLib.WpfVisual(makeImg(images[i]), dither : Dither)));
}
}
else
{
Dispatcher.InvokeAsync(() => CheckTweetData(text, images), DispatcherPriority.Background);
}
}