当前位置: 首页>>代码示例>>C#>>正文


C# Media.ImageSource类代码示例

本文整理汇总了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;
 }
开发者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: 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));
 }
开发者ID:WillVandergrift,项目名称:Carputer,代码行数:10,代码来源:MediaSource.cs

示例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();
 }
开发者ID:alexguo88,项目名称:WpfExtensions,代码行数:35,代码来源:ShadowWindow.Partial.cs


注:本文中的System.Windows.Media.ImageSource类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。