本文整理汇总了C#中System.Windows.Media.ImageSource类的典型用法代码示例。如果您正苦于以下问题:C# ImageSource类的具体用法?C# ImageSource怎么用?C# ImageSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ImageSource类属于System.Windows.Media命名空间,在下文中一共展示了ImageSource类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:danieldeb,项目名称:WpfAnimatedGif,代码行数:28,代码来源:AnimationCache.cs
示例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);
}
}
}
开发者ID:jhorv,项目名称:CsConsoleFormat,代码行数:30,代码来源:ConsoleBufferImageExts.cs
示例3: FieldInitializerItem
public FieldInitializerItem(string name, string sortText, ImageSource displayGlyph, IEnumerable<CallHierarchyDetail> details)
{
_name = name;
_sortText = sortText;
_displayGlyph = displayGlyph;
_details = details;
}
开发者ID:Rickinio,项目名称:roslyn,代码行数:7,代码来源:FieldInitializerItem.cs
示例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;
}
开发者ID:CadeLaRen,项目名称:digiCamControl,代码行数:25,代码来源:ColorUtility.cs
示例5: GalleryItemViewModel
public GalleryItemViewModel(GalleryItem aModel, Action<GalleryItem> aOnClick)
{
_model = aModel;
_onClick = aOnClick;
OnClickCommand = new RelayCommand(wasClicked);
_source = ImageSourceFromFile(_model.MediaPath);
}
开发者ID:Dig-Doug,项目名称:BU_KinectShowcase,代码行数:7,代码来源:GalleryItemViewModel.cs
示例6: ResetColor
public void ResetColor()
{
if (!AllowRecolor) return;
InnerImage = null;
InnerImageSource = null;
IsRecolored = false;
}
开发者ID:OronDF343,项目名称:Sky-Jukebox,代码行数:7,代码来源:IconBase.cs
示例7: CompletionData
public CompletionData(string text, ImageSource bmp,string description,TokenType tokenType)
{
this.Text = text;
this.Image = bmp;
this.Description = description;
this.TokenType = tokenType;
}
开发者ID:ZixiangBoy,项目名称:CIIP,代码行数:7,代码来源:CompletionData.cs
示例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;
}
开发者ID:pankajbhandari08,项目名称:windows-tweaker,代码行数:7,代码来源:MoreInfo.xaml.cs
示例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;
}
开发者ID:SimonWallner,项目名称:uit2012-lab4,代码行数:27,代码来源:TouchTarget.cs
示例10: Calculator
public Calculator()
{
using (var stream = AssemblyHelper.GetEmbeddedResource(typeof(Calculator).Assembly, "calculate.png"))
{
this._icon = ImageSourceHelper.StreamToImageSource(stream);
}
}
开发者ID:jefim,项目名称:wooster,代码行数:7,代码来源:Calculator.cs
示例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);
}
开发者ID:andrey-kozyrev,项目名称:LinguaSpace,代码行数:7,代码来源:PracticeModel.cs
示例12: EditorConfigCompletionSource
public EditorConfigCompletionSource(ITextBuffer buffer, IClassifierAggregatorService classifier, ITextStructureNavigatorSelectorService navigator, ImageSource glyph)
{
_buffer = buffer;
_classifier = classifier.GetClassifier(buffer);
_navigator = navigator;
_glyph = glyph;
}
开发者ID:modulexcite,项目名称:EditorConfig,代码行数:7,代码来源:EditorConfigCompletionSource.cs
示例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;
}
开发者ID:eric-seekas,项目名称:ErrorControlSystem,代码行数:7,代码来源:AnimationCache.cs
示例14: EmojiCompletion
private static Completion EmojiCompletion(string emoji, ImageSource emojiImage)
{
// Map a completion object for each Emoji to the appropriate image
var formattedEmoji = $":{emoji}:";
// Build a completion for each Emoji
return new Completion(formattedEmoji, formattedEmoji, formattedEmoji, emojiImage, formattedEmoji);
}
开发者ID:justinmcunn,项目名称:Glyphfriend,代码行数:7,代码来源:EmojiCompletionSource.cs
示例15: AbstractMenuItem
public AbstractMenuItem(string header, int priority, ImageSource icon = null, ICommand command = null,
KeyGesture gesture = null, bool isCheckable = false)
{
Priority = priority;
IsSeparator = false;
Header = header;
Key = header;
Command = command;
IsCheckable = isCheckable;
Icon = icon;
if (gesture != null && command != null)
{
Application.Current.MainWindow.InputBindings.Add(new KeyBinding(command, gesture));
InputGestureText = gesture.DisplayString;
}
if (isCheckable)
{
IsChecked = false;
}
if (Header == "SEP")
{
Key = "SEP" + sepCount.ToString();
Header = "";
sepCount++;
IsSeparator = true;
}
}
开发者ID:vinodj,项目名称:Wide,代码行数:27,代码来源:AbstractMenuItem.cs
示例16: MoveUpObject
static MoveUpObject()
{
//use this code for *.ico files loading
//IconBitmapDecoder ibd = new IconBitmapDecoder(new Uri(@"pack://application:,,/Icons/up.ico", UriKind.RelativeOrAbsolute), BitmapCreateOptions.None, BitmapCacheOption.Default);
//icon = ibd.Frames[0];
//icon = new BitmapImage(new Uri(@"pack://application:,,/Icons/up.png", UriKind.RelativeOrAbsolute));
icon = Utility.LoadImageSource("UpIcon");
}
开发者ID:kkalinowski,项目名称:nex,代码行数:8,代码来源:MoveUpObject.cs
示例17: ImageBrushTool
public ImageBrushTool(ImageSource i, TileMode m, Rect v, BrushMappingMode u, double o = 1) : this()
{
Image = i;
Mode = m;
Viewport = v;
ViewportUnits = u;
Opacity = o;
}
开发者ID:usagirei,项目名称:3DS-Theme-Editor,代码行数:8,代码来源:ImageBrushTool.cs
示例18: VideoScreenViewModel
public VideoScreenViewModel()
{
var bmp = new BitmapImage();
bmp.BeginInit();
bmp.UriSource = new Uri(@"/PlaybackPlugin;component/Images/iconwattermarkone.png", UriKind.RelativeOrAbsolute);
bmp.EndInit();
ImageSource = bmp;
}
开发者ID:huyettoc,项目名称:duycm-workstation,代码行数:8,代码来源:VideoScreenViewModel.cs
示例19: AttachedImageViewModel
public AttachedImageViewModel(AttachedImage attachedAlbumModel, ImageSource image)
{
_attachedAlbumModel = attachedAlbumModel;
_linkUrl = attachedAlbumModel.LinkUrl;
_image = image;
_width = image.Width;
_height = image.Height;
}
开发者ID:namoshika,项目名称:Metrooz,代码行数:8,代码来源:AttachedImageViewModel.cs
示例20: ChangeNodeIcon
private void ChangeNodeIcon(TreeViewIconsItem node, ImageSource newIcon)
{
if (node == null || newIcon == null)
{
return;
}
node.Icon = newIcon;
}
开发者ID:puma007,项目名称:PersonalInfoForWPF,代码行数:8,代码来源:MainWindowHelper.cs
注:本文中的System.Windows.Media.ImageSource类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论