本文整理汇总了C#中System.Windows.Media.ImageSource类的典型用法代码示例。如果您正苦于以下问题:C# ImageSource类的具体用法?C# ImageSource怎么用?C# ImageSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ImageSource类属于System.Windows.Media命名空间,在下文中一共展示了ImageSource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetUri
private static Uri GetUri(ImageSource image)
{
var bmp = image as BitmapImage;
if (bmp != null && bmp.UriSource != null)
{
if (bmp.UriSource.IsAbsoluteUri)
return bmp.UriSource;
if (bmp.BaseUri != null)
return new Uri(bmp.BaseUri, bmp.UriSource);
}
var frame = image as BitmapFrame;
if (frame != null)
{
string s = frame.ToString();
if (s != frame.GetType().FullName)
{
Uri fUri;
if (Uri.TryCreate(s, UriKind.RelativeOrAbsolute, out fUri))
{
if (fUri.IsAbsoluteUri)
return fUri;
if (frame.BaseUri != null)
return new Uri(frame.BaseUri, fUri);
}
}
}
return null;
}
示例2: DrawImage
public static void DrawImage (this ConsoleBuffer @this, ImageSource imageSource, int x, int y, int width, int height)
{
var bmp = imageSource as BitmapSource;
if (bmp == null)
throw new ArgumentException("Only rendering of bitmap source is supported.");
@this.OffsetX(ref x).OffsetY(ref y);
int x1 = x, x2 = x + width, y1 = y, y2 = y + height;
if ([email protected](ref x1, ref y1, ref x2, ref y2))
return;
if (width != bmp.PixelWidth || height != bmp.PixelHeight)
bmp = new TransformedBitmap(bmp, new ScaleTransform((double)width / bmp.PixelWidth, (double)height / bmp.PixelHeight));
if (bmp.Format != PixelFormats.Indexed4)
bmp = new FormatConvertedBitmap(bmp, PixelFormats.Indexed4, BitmapPalettes.Halftone8Transparent, 0.5);
const int bitsPerPixel = 4;
int stride = 4 * (bmp.PixelWidth * bitsPerPixel + 31) / 32;
byte[] bytes = new byte[stride * bmp.PixelHeight];
bmp.CopyPixels(bytes, stride, 0);
for (int iy = y1, py = 0; iy < y2; iy++, py++) {
ConsoleChar[] charsLine = @this.GetLine(iy);
for (int ix = x1, px = 0; ix < x2; ix++, px++) {
int byteIndex = stride * py + px / 2;
int bitOffset = px % 2 == 0 ? 4 : 0;
SetColor(ref charsLine[ix], bmp.Palette, (bytes[byteIndex] >> bitOffset) & 0xF);
}
}
}
示例3: FieldInitializerItem
public FieldInitializerItem(string name, string sortText, ImageSource displayGlyph, IEnumerable<CallHierarchyDetail> details)
{
_name = name;
_sortText = sortText;
_displayGlyph = displayGlyph;
_details = details;
}
示例4: Convert
public static ImageSource Convert(ImageSource imageSource, ColorConversion conversion)
{
ImageSource result = null;
BitmapSource bitmapSource = imageSource as BitmapSource;
if (bitmapSource != null)
{
PixelFormat format = PixelFormats.Default;
switch (conversion)
{
case ColorConversion.BlackAndWhite:
format = PixelFormats.BlackWhite;
break;
case ColorConversion.GrayScale:
format = PixelFormats.Gray32Float;
break;
}
if (format != PixelFormats.Default)
{
result = Convert(bitmapSource, format);
}
}
return result;
}
示例5: GalleryItemViewModel
public GalleryItemViewModel(GalleryItem aModel, Action<GalleryItem> aOnClick)
{
_model = aModel;
_onClick = aOnClick;
OnClickCommand = new RelayCommand(wasClicked);
_source = ImageSourceFromFile(_model.MediaPath);
}
示例6: ResetColor
public void ResetColor()
{
if (!AllowRecolor) return;
InnerImage = null;
InnerImageSource = null;
IsRecolored = false;
}
示例7: CompletionData
public CompletionData(string text, ImageSource bmp,string description,TokenType tokenType)
{
this.Text = text;
this.Image = bmp;
this.Description = description;
this.TokenType = tokenType;
}
示例8: MoreInfo
public MoreInfo(string appTitle, string filePath, ImageSource imgSource) {
InitializeComponent();
txtAppTitle.Text = appTitle;
txtAppFileName.Text = System.IO.Path.GetFileName(filePath);
txtAppFilePath.Text = filePath;
imgProgramIcon.Source = imgSource;
}
示例9: TouchTarget
public TouchTarget(double x, double y, double width, double height,
ImageSource image, String characters, int dx, int dy)
{
X = x;
Y = y;
Width = width;
Height = height;
this.image = image;
ROutside = (width / 2.0) * 0.9;
RInside = ROutside * 1.2;
this.callback = null;
this.lastState = State.outside;
this.characters = characters;
this.timeInside = 0.0;
this.selection = ' ';
this.selectionTime = 0.0;
this.dx = dx;
this.dy = dy;
this.CX = this.X + this.Width / 2.0;
this.CY = this.Y + this.Height / 2.0;
}
示例10: Calculator
public Calculator()
{
using (var stream = AssemblyHelper.GetEmbeddedResource(typeof(Calculator).Assembly, "calculate.png"))
{
this._icon = ImageSourceHelper.StreamToImageSource(stream);
}
}
示例11: PracticeModel
static PracticeModel()
{
BmpsError32 = WPFUtils.GetPngImageSource("Grammar", "Status", "Error", 32);
BmpsQuestion32 = WPFUtils.GetPngImageSource("Grammar", "Status", "Question", 32);
BmpsInfo32 = WPFUtils.GetPngImageSource("Grammar", "Status", "Info", 32);
BmpsOK32 = WPFUtils.GetPngImageSource("Grammar", "Status", "OK", 32);
}
示例12: EditorConfigCompletionSource
public EditorConfigCompletionSource(ITextBuffer buffer, IClassifierAggregatorService classifier, ITextStructureNavigatorSelectorService navigator, ImageSource glyph)
{
_buffer = buffer;
_classifier = classifier.GetClassifier(buffer);
_navigator = navigator;
_glyph = glyph;
}
示例13: GetAnimation
public static ObjectAnimationUsingKeyFrames GetAnimation(ImageSource source, RepeatBehavior repeatBehavior)
{
var key = new CacheKey(source, repeatBehavior);
ObjectAnimationUsingKeyFrames animation;
_animationCache.TryGetValue(key, out animation);
return animation;
}
示例14: MediaSource
/// <summary>
/// Constructor with parameters
/// </summary>
public MediaSource(string srcName, string srcPath, string relativeThumbnailUrl)
{
name = srcName;
path = srcPath;
//thumbnail = new BitmapImage(new Uri(@"C:\Users\William\Documents\Software Projects\Carputer\Media\folder-music.png"));
thumbnail = new BitmapImage(new Uri(@"pack://siteoforigin:,,," + relativeThumbnailUrl));
}
示例15: ShadowWindow
static ShadowWindow()
{
ActiveBottomImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/ActiveBottom.png"));
ActiveBottomImage.Freeze();
ActiveBottomLeftImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/ActiveBottomLeft.png"));
ActiveBottomLeftImage.Freeze();
ActiveBottomRightImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/ActiveBottomRight.png"));
ActiveBottomRightImage.Freeze();
ActiveLeftImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/ActiveLeft.png"));
ActiveLeftImage.Freeze();
ActiveRightImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/ActiveRight.png"));
ActiveRightImage.Freeze();
ActiveTopImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/ActiveTop.png"));
ActiveTopImage.Freeze();
ActiveTopLeftImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/ActiveTopLeft.png"));
ActiveTopLeftImage.Freeze();
ActiveTopRightImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/ActiveTopRight.png"));
ActiveTopRightImage.Freeze();
InactiveBottomImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/InactiveBottom.png"));
InactiveBottomImage.Freeze();
InactiveBottomLeftImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/InactiveBottomLeft.png"));
InactiveBottomLeftImage.Freeze();
InactiveBottomRightImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/InactiveBottomRight.png"));
InactiveBottomRightImage.Freeze();
InactiveLeftImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/InactiveLeft.png"));
InactiveLeftImage.Freeze();
InactiveRightImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/InactiveRight.png"));
InactiveRightImage.Freeze();
InactiveTopImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/InactiveTop.png"));
InactiveTopImage.Freeze();
InactiveTopLeftImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/InactiveTopLeft.png"));
InactiveTopLeftImage.Freeze();
InactiveTopRightImage = new BitmapImage(new Uri("pack://application:,,,/Kfstorm.WpfExtensions;component/Images/Shadow/InactiveTopRight.png"));
InactiveTopRightImage.Freeze();
}