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


C# Image.Fill方法代码示例

本文整理汇总了C#中System.Image.Fill方法的典型用法代码示例。如果您正苦于以下问题:C# Image.Fill方法的具体用法?C# Image.Fill怎么用?C# Image.Fill使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Image的用法示例。


在下文中一共展示了Image.Fill方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Render

        protected void Render(Image image, bool useMarker, int markerLoc = -1)
        {
            image.Fill(BackColor.Value);

            string text = Text.Value;
            if(text == null) text = "null";
            int length = text.Length;
            if(length == 0)
            {
                return;
            }
            if(!LockFont)
            {
                Point2D idealSize = new Point2D(image.Width / (Math.Max(length, lengthOverride) - Margin.Value.X * 2), image.Height - Margin.Value.Y * 2);
                if(CurrentFont == null || CurrentFont.Size != idealSize)
                {
                    CurrentFont = Font.GetFont(idealSize, Style);
                }
            }
            int x = 0;
            int y = 0;
            switch(HorizontalJustify)
            {
                case Justify.MIN: x = Margin.Value.X; break;
                case Justify.MIDDLE: x = (image.Width / 2) - (CurrentFont.Width * length / 2); break;
                case Justify.MAX: x = image.Width - (CurrentFont.Width * length) - Margin.Value.X; break;
            }
            switch(VerticalJustify)
            {
                case Justify.MIN: y = Margin.Value.Y; break;
                case Justify.MIDDLE: y = (image.Height / 2) - (CurrentFont.Height / 2); break;
                case Justify.MAX: y = image.Height - CurrentFont.Height - Margin.Value.Y; break;
            }
            CurrentFont.Draw(image, x, y, text, TextColor.Value);
            if(useMarker)
            {
                CurrentFont.Draw(image, x + (int)((markerLoc - .5) * CurrentFont.Width), y, '|', TextColor.Value);
            }
        }
开发者ID:jonhartnett,项目名称:IROM-UI,代码行数:39,代码来源:Label.cs

示例2: Render

 protected override void Render(Image image)
 {
     image.Fill(Color.Value);
 }
开发者ID:jonhartnett,项目名称:IROM-UI,代码行数:4,代码来源:Panel.cs

示例3: Build

        /// <summary>
        /// 
        /// </summary>
        /// <param name="buildContext"></param>
        public override void Build( BuildContext buildContext )
        {
            var fileNames	=	buildContext.ExpandAndResolveSearchPatterns( Dependencies );
            var images		=	fileNames
                                .Select( fn => Image.LoadTga( fn ) )
                                .OrderByDescending( img0 => img0.Width * img0.Height )
                                .ThenByDescending( img1 => img1.Width )
                                .ThenByDescending( img2 => img2.Height )
                                .ToList();

            if (!images.Any()) {
                throw new InvalidOperationException("At least one subimage must be added to teh texture atlas");
            }

            //
            //	Pack atlas :
            //
            AtlasNode root = new AtlasNode(0,0, Width, Height, Padding );

            foreach ( var img in images ) {
                var n = root.Insert( img );
                if (n==null) {
                    throw new InvalidOperationException("No enough room to place image");
                }
            }

            //
            //	Create image and fill it with atlas elements :
            //
            var targetImage	=	new Image( Width, Height );
            targetImage.Fill( FillColor );

            root.WriteImages( targetImage );

            //
            //	Save and compress :
            //
            var tgaOutput	=	buildContext.GetTempFileName( AssetPath, ".tga", true );
            var ddsOutput	=	buildContext.GetTempFileName( AssetPath, ".dds", true );
            Image.SaveTga( targetImage, tgaOutput );

            var compression =	UseDXT ? ImageFileTextureAsset.TextureCompression.BC3 : ImageFileTextureAsset.TextureCompression.RGB;
            ImageFileTextureAsset.RunNVCompress( buildContext, tgaOutput, ddsOutput, NoMips, false, false, true, true, false, compression );

            //
            //	Write binary blob (text + dds texture):
            //
            using ( var fs = buildContext.TargetStream( this ) ) {
                var bw = new BinaryWriter( fs );

                bw.Write(new[]{'A','T','L','S'});
                bw.Write( images.Count );

                root.WriteLayout( bw );

                bw.Write( (int)(new FileInfo(ddsOutput).Length) );

                using ( var dds = File.OpenRead( ddsOutput ) ) {
                    dds.CopyTo( fs );
                }
            }
        }
开发者ID:temik911,项目名称:audio,代码行数:66,代码来源:AssembledTextureAtlasAsset.cs


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