• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Drawing.Bitmap类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



System.Drawing.Bitmap类属于命名空间,在下文中一共展示了System.Drawing.Bitmap类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Terrain

 public Terrain(Device device, String texture, int pitch, Renderer renderer)
 {
     HeightMap = new System.Drawing.Bitmap(@"Data/Textures/"+texture);
     WaterShader = new WaterShader(device);
     TerrainShader = new TerrainShader(device);
     _width = HeightMap.Width-1;
     _height = HeightMap.Height-1;
     _pitch = pitch;
     _terrainTextures = new ShaderResourceView[4];
     _terrainTextures[0] = new Texture(device, "Sand.png").TextureResource;
     _terrainTextures[1] = new Texture(device, "Grass.png").TextureResource;
     _terrainTextures[2] = new Texture(device, "Ground.png").TextureResource;
     _terrainTextures[3] = new Texture(device, "Rock.png").TextureResource;
     _reflectionClippingPlane = new Vector4(0.0f, 1.0f, 0.0f, 0.0f);
     _refractionClippingPlane = new Vector4(0.0f, -1.0f, 0.0f, 0.0f);
     _noClippingPlane = new Vector4(0.0f, 1.0f, 0.0f, 10000);
     _reflectionTexture = new RenderTexture(device, renderer.ScreenSize);
     _refractionTexture = new RenderTexture(device, renderer.ScreenSize);
     _renderer = renderer;
     _bitmap = new Bitmap(device,_refractionTexture.ShaderResourceView,renderer.ScreenSize, new Vector2I(100, 100), 0);
     _bitmap.Position = new Vector2I(renderer.ScreenSize.X - 100, 0);
     _bitmap2 = new Bitmap(device, _reflectionTexture.ShaderResourceView, renderer.ScreenSize, new Vector2I(100, 100), 0);
     _bitmap2.Position = new Vector2I(renderer.ScreenSize.X - 100, 120);
     _bumpMap = _renderer.TextureManager.Create("OceanWater.png");
     _skydome = new ObjModel(device, "skydome.obj", renderer.TextureManager.Create("Sky.png"));
     BuildBuffers(device);
     WaveTranslation = new Vector2(0,0);
 }
开发者ID:ndech,项目名称:PlaneSimulator,代码行数:28,代码来源:Terrain.cs


示例2: Wolf

 public Wolf()
 {
     name = "Wolf";
     family = "Carnivore";
     food = "Rabbits";
     image = new System.Drawing.Bitmap("wolf.jpg");
 }
开发者ID:sleemjm1,项目名称:IN710-sleemjm1,代码行数:7,代码来源:Wolf.cs


示例3: Run

        public static void Run()
        {
            // ExStart:ExtractAllImagesFromPage
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Shapes();

            // Call a Diagram class constructor to load a VSD diagram
            Diagram diagram = new Diagram(dataDir + "ExtractAllImagesFromPage.vsd");

            // Enter page index i.e. 0 for first one
            foreach (Shape shape in diagram.Pages[0].Shapes)
            {
                // Filter shapes by type Foreign
                if (shape.Type == Aspose.Diagram.TypeValue.Foreign)
                {
                    using (System.IO.MemoryStream stream = new System.IO.MemoryStream(shape.ForeignData.Value))
                    {
                        // Load memory stream into bitmap object
                        System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(stream);

                        // Save bmp here
                        bitmap.Save(dataDir + "ExtractAllImages" + shape.ID + "_out.bmp");
                    }
                }
            }
            // ExEnd:ExtractAllImagesFromPage
        }
开发者ID:aspose-diagram,项目名称:Aspose.Diagram-for-.NET,代码行数:27,代码来源:ExtractAllImagesFromPage.cs


示例4: Intitial

        /// <summary>
        /// 初始化
        /// </summary>
        public void Intitial( FontMgr.FontLoadInfo fontLoadInfo )
        {
            try
            {
                privateFontCollection = new PrivateFontCollection();

                foreach (FontMgr.FontInfo info in fontLoadInfo.UnitCodeFontInfos)
                {
                    privateFontCollection.AddFontFile( info.path );
                }

                fontFamilys = privateFontCollection.Families;

                if (fontFamilys.Length != fontLoadInfo.UnitCodeFontInfos.Count)
                    throw new Exception( "导入的各个字体必须属于不同类别" );

                for (int i = 0; i < fontFamilys.Length; i++)
                {
                    fonts.Add( fontLoadInfo.UnitCodeFontInfos[i].name, new System.Drawing.Font( fontFamilys[i], fontLoadInfo.DefualtEmSize ) );
                }

                System.Drawing.Bitmap tempBitMap = new System.Drawing.Bitmap( 1, 1 );
                mesureGraphics = System.Drawing.Graphics.FromImage( tempBitMap );
            }
            catch (Exception)
            {
                throw new Exception( "读取字体文件出错" );
            }

        }
开发者ID:ingex0,项目名称:smarttank,代码行数:33,代码来源:ChineseWriter.cs


示例5: ScaleByFixedHeight

        private static void ScaleByFixedHeight(String fileName, int newHeight, String outputFile)
        {
            System.Drawing.Bitmap resizedImage = null;

            try
            {
                using (System.Drawing.Image originalImage = System.Drawing.Image.FromFile(fileName))
                {
                    double resizeRatio = (double)newHeight / originalImage.Size.Height;
                    int newWidth = (int)(originalImage.Size.Width * resizeRatio);

                    System.Drawing.Size newSize = new System.Drawing.Size(newWidth, newHeight);

                    resizedImage = new System.Drawing.Bitmap(originalImage, newSize);
                }

                // Save resized picture.
                CheckAndCreatePath(outputFile);
                resizedImage.Save(outputFile, System.Drawing.Imaging.ImageFormat.Jpeg);
            }
            finally
            {
                if (resizedImage != null)
                {
                    resizedImage.Dispose();
                }
            }
        }
开发者ID:Creou,项目名称:WebGalleryProcessor,代码行数:28,代码来源:GalleryImageProcessor.cs


示例6: BatchClassificationDialog

        public BatchClassificationDialog(ref Klu klu, ref TrainingDataSet dataSet, ProcessOptions processOptions)
        {
            InitializeComponent();

            _BackgroundWorker = new BackgroundWorker();
            _BackgroundWorker.WorkerReportsProgress = true;
            _BackgroundWorker.WorkerSupportsCancellation = true;
            _BackgroundWorker.DoWork += new DoWorkEventHandler(DoWork);
            _BackgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(RunWorkerCompleted);
            _BackgroundWorker.ProgressChanged += new ProgressChangedEventHandler(ProgressChanged);        

            BrowseButton.IsEnabled = true;
            CancelButton.IsEnabled = false;
            ClassifyButton.IsEnabled = false;

            _DataSet = dataSet;
            _SelectedFiles = new ArrayList();
            _ProcessOptions = processOptions;
            // We want the images to be as less distorded as possible, so we disable all the overlays.

            _ProcessOptions.DrawAnthropometricPoints = 0;
            _ProcessOptions.DrawDetectionTime = 0;
            _ProcessOptions.DrawFaceRectangle = 0;
            _ProcessOptions.DrawSearchRectangles = 0;
            _ProcessOptions.DrawFeaturePoints = 0;
            
            _KLU = klu;
            _FFP = new FaceFeaturePoints();
            _TempBitmap = new System.Drawing.Bitmap(10, 10);

            ExpressionsComboBox.ItemsSource = _DataSet.Expression;
            ClassifyButton.Content = "Classify";
        }
开发者ID:shardulchauhan007,项目名称:klucv2,代码行数:33,代码来源:BatchClassificationDialog.xaml.cs


示例7: reveal

 public static string reveal(string path)
 {
     string result = "";
     System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(path);
     // FIXME
     return result;
 }
开发者ID:Ardawo,项目名称:TPC-,代码行数:7,代码来源:Stegano.cs


示例8: MakeImagesNegative

        static void MakeImagesNegative(string sourceDirectoryPath, string targetDirectoryPath)
        {
            string[] filenames = System.IO.Directory.GetFiles(sourceDirectoryPath);

            foreach (var filename in filenames)
            {
                System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(filename);
                Parallel.For(0, bitmap.Height, (bitmapRowIndex) =>
                {
                    lock (bitmap)
                    {
                        for (int bitmapColIndex = 0; bitmapColIndex < bitmap.Width; bitmapColIndex++)
                        {

                            var pixel = bitmap.GetPixel(bitmapColIndex, bitmapRowIndex);
                            var negativePixel = System.Drawing.Color.FromArgb(
                                byte.MaxValue - pixel.A,
                                byte.MaxValue - pixel.R,
                                byte.MaxValue - pixel.G,
                                byte.MaxValue - pixel.B);

                            bitmap.SetPixel(bitmapColIndex, bitmapRowIndex, negativePixel);
                        }
                    }
                });

                bitmap.Save(filename.Replace(sourceDirectoryPath, targetDirectoryPath));
            }
        }
开发者ID:TelerikAcademy,项目名称:TelerikAcademyPlus,代码行数:29,代码来源:Program.cs


示例9: CreateAvatar

        public static byte[] CreateAvatar(int sideLength, System.IO.Stream fromStream)
        {
            System.IO.MemoryStream ms = new System.IO.MemoryStream();

            using (var image = System.Drawing.Image.FromStream(fromStream))
            using (var thumbBitmap = new System.Drawing.Bitmap(sideLength, sideLength))
            {

                var a = Math.Min(image.Width, image.Height);

                var x = (image.Width - a) / 2;

                var y = (image.Height - a) / 2;

                using (var thumbGraph = System.Drawing.Graphics.FromImage(thumbBitmap))
                {

                    thumbGraph.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;

                    thumbGraph.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

                    thumbGraph.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;

                    var imgRectangle = new System.Drawing.Rectangle(0, 0, sideLength, sideLength);

                    thumbGraph.DrawImage(image, imgRectangle, x, y, a, a, System.Drawing.GraphicsUnit.Pixel);

                    thumbBitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);

                }

            }
            return (ms.ToArray());
        }
开发者ID:kyallbarrows,项目名称:LifeguardServer,代码行数:34,代码来源:Utilities.cs


示例10: ThumbnailEventArgs

 // Constructor
 public ThumbnailEventArgs(System.Drawing.Bitmap bmp, string filename,int count, int totalcount)
 {
     this.bmp = bmp;
     this.filename = filename;
     this.count = count;
     this.totalCount = totalcount;
 }
开发者ID:cszielke,项目名称:pentaxks2wifiremote,代码行数:8,代码来源:ThumbnailEvent.cs


示例11: create_hue_bitmap

        public static System.Drawing.Bitmap create_hue_bitmap(int width, int height)
        {
            var bitmap = new System.Drawing.Bitmap(width, height);

            using (var gfx = System.Drawing.Graphics.FromImage(bitmap))
            {
                var colorblend = new System.Drawing.Drawing2D.ColorBlend();
                const int num_steps = 34;
                var range_steps = EnumerableUtil.RangeSteps(0.0, 1.0, num_steps);

                colorblend.Colors = new System.Drawing.Color[num_steps];
                colorblend.Positions = new float[num_steps];

                double _sat = 1.0;
                double _val = 1.0;

                var colors = range_steps.Select(x => VisioAutomation.UI.ColorUtil.HSVToSystemDrawingColor(x, _sat, _val));
                var positions = range_steps.Select(x => (float) x);

                EnumerableUtil.FillArray( colorblend.Colors, colors );
                EnumerableUtil.FillArray(colorblend.Positions, positions);

                using (var brush_rainbow = new System.Drawing.Drawing2D.LinearGradientBrush(
                    new System.Drawing.Point(0, 0),
                    new System.Drawing.Point(bitmap.Width, 0),
                    System.Drawing.Color.Black,
                    System.Drawing.Color.White))
                {
                    brush_rainbow.InterpolationColors = colorblend;
                    gfx.FillRectangle(brush_rainbow, 0, 0, bitmap.Width, bitmap.Height);
                }
            }
            return bitmap;
        }
开发者ID:firestream99,项目名称:VisioAutomation,代码行数:34,代码来源:WinFormUtil.cs


示例12: Koala

 public Koala()
 {
     name = "Koala";
     family = "Herbavore";
     food = "Leaves";
     image = new System.Drawing.Bitmap("koala.jpg");
 }
开发者ID:sleemjm1,项目名称:IN710-sleemjm1,代码行数:7,代码来源:Koala.cs


示例13: ThumbnailCreator

        /// <summary>
        /// Initializes a new instance of the <see cref="ThumbnailCreator"/> class.
        /// </summary>
        /// <param name="tnSettings">The <see cref="ThumbnailSettings"/> to use.</param>
        /// <param name="worker">The <see cref="System.ComponentModel.BackgroundWorker"/>worker to use.
        /// </param>
        public ThumbnailCreator(ThumbnailSettings tnSettings, System.ComponentModel.BackgroundWorker worker)
        {
            this._tnSettings = tnSettings;
            this._worker = worker;

            #if false
            _imageCodec = GetEncoder (System.Drawing.Imaging.ImageFormat.Png);
            _qualityParameter = new System.Drawing.Imaging.EncoderParameter (
                    System.Drawing.Imaging.Encoder.Quality, 75L);
            _qualityParameters = new System.Drawing.Imaging.EncoderParameters (1);
            _qualityParameters.Param[0] = _qualityParameter;
            #else
            _imageCodec = GetEncoder (System.Drawing.Imaging.ImageFormat.Jpeg);
            _qualityParameter = new System.Drawing.Imaging.EncoderParameter (
                    System.Drawing.Imaging.Encoder.Quality, 75L);
            _qualityParameters = new System.Drawing.Imaging.EncoderParameters (1);
            _qualityParameters.Param[0] = _qualityParameter;
            #endif

            #if false
            using (System.Drawing.Bitmap bitmap1 = new System.Drawing.Bitmap (1, 1))
                {
                System.Drawing.Imaging.EncoderParameters paramList =
                        bitmap1.GetEncoderParameterList (_imageCodec.Clsid);
                System.Drawing.Imaging.EncoderParameter[] encParams = paramList.Param;
                foreach (System.Drawing.Imaging.EncoderParameter p in encParams)
                    {
                    THelper.Information ("Type {0}, GUID {1}", p.ValueType, p.Encoder.Guid);
                    }

                paramList.Dispose ();
                }
            #endif
        }
开发者ID:rm2,项目名称:CLAutoThumbnailer,代码行数:40,代码来源:ThumbnailCreator.cs


示例14: ActionDefinition

 public ActionDefinition(ActionLibrary parent, string name, int id)
 {
     Library = parent;
     GameMakerVersion = 520;
     Name = name;
     ActionID = id;
     System.IO.MemoryStream ms = new System.IO.MemoryStream();
     Properties.Resources.DefaultAction.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
     OriginalImage = ms.ToArray();
     ms.Close();
     Image = new System.Drawing.Bitmap(24, 24, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
     System.Drawing.Graphics.FromImage(Image).DrawImage(Properties.Resources.DefaultAction, new System.Drawing.Rectangle(0, 0, 24, 24), new System.Drawing.Rectangle(0, 0, 24, 24), System.Drawing.GraphicsUnit.Pixel);
     (Image as System.Drawing.Bitmap).MakeTransparent(Properties.Resources.DefaultAction.GetPixel(0, Properties.Resources.DefaultAction.Height - 1));
     Hidden = false;
     Advanced = false;
     RegisteredOnly = false;
     Description = string.Empty;
     ListText = string.Empty;
     HintText = string.Empty;
     Kind = ActionKind.Normal;
     InterfaceKind = ActionInferfaceKind.Normal;
     IsQuestion = false;
     ShowApplyTo = true;
     ShowRelative = true;
     ArgumentCount = 0;
     Arguments = new ActionArgument[8];
     for (int i = 0; i < 8; i++) Arguments[i] = new ActionArgument();
     ExecutionType = ActionExecutionType.None;
     FunctionName = string.Empty;
     Code = string.Empty;
 }
开发者ID:joshwyant,项目名称:game-creator,代码行数:31,代码来源:ActionDefinition.cs


示例15: TextureData

        public TextureData(string src)
        {
            try
            {
                System.Drawing.Bitmap texture = new System.Drawing.Bitmap(src);

                width = texture.Width;
                height = texture.Height;

                Clear();

                for (int x = 0; x < width; x++)
                    for (int y = 0; y < height; y++)
                    {
                        Color xnaColor = new Color();
                        System.Drawing.Color formsColor = texture.GetPixel(x, y);

                        xnaColor.R = formsColor.R;
                        xnaColor.G = formsColor.G;
                        xnaColor.B = formsColor.B;
                        xnaColor.A = formsColor.A;

                        data[y * width + x] = xnaColor.PackedValue;
                    }
            }
            catch(Exception e)
            {
                Console.WriteLine("Failed to load file: " + e.Message);
                Clear();
            }
        }
开发者ID:teamprova,项目名称:Dungeontest,代码行数:31,代码来源:TextureData.cs


示例16: IsBig

        public string IsBig(string originalImagePath, int intWidth)
        {
            bool isExist = WXSSK.Common.DirectoryAndFile.FileExists(originalImagePath);
            System.Drawing.Image imgOriginal = System.Drawing.Image.FromFile(Server.MapPath(originalImagePath));

            //获取原图片的的宽度与高度
            int originalWidth = imgOriginal.Width;
            int originalHeight = imgOriginal.Height;

            //如果原图片宽度大于原图片的高度
            if (originalWidth > intWidth)
            {
                originalWidth = intWidth;  //宽度等于缩略图片尺寸
                originalHeight = originalHeight * (intWidth / originalWidth);  //高度做相应比例缩小
            }

            System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(originalWidth, originalHeight);
            System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(bitmap);

            //设置缩略图片质量
            graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
            graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
            graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

            graphics.DrawImage(imgOriginal, 0, 0, originalWidth, originalHeight);

            //System.Drawing.Graphics temp = graphics;
            // 保存缩略图片
            imgOriginal.Dispose();
            WXSSK.Common.DirectoryAndFile.DeleteFile(originalImagePath);
            bitmap.Save(Server.MapPath(originalImagePath), System.Drawing.Imaging.ImageFormat.Jpeg);
            return originalImagePath;
        }
开发者ID:leroy358,项目名称:CircusIOC,代码行数:33,代码来源:PictureController.cs


示例17: RoyalAlbatross

 public RoyalAlbatross()
 {
     name = "Royal Albatross";
     family = "Carnivore";
     food = "Squid";
     image = new System.Drawing.Bitmap("royal_albatross.jpg");
 }
开发者ID:sleemjm1,项目名称:IN710-sleemjm1,代码行数:7,代码来源:RoyalAlbatross.cs


示例18: ToBitmapSource

 /// <summary>
 /// Converts a <see cref="System.Drawing.Image"/> into a WPF <see cref="BitmapSource"/>.
 /// </summary>
 /// <param name="image">The image image.</param>
 /// <returns>A BitmapSource</returns>
 public static BitmapSource ToBitmapSource(this System.Drawing.Image image)
 {
     using (var bitmap = new System.Drawing.Bitmap(image))
     {
         return bitmap.ToBitmapSource();
     }
 }
开发者ID:mastersign,项目名称:minimods,代码行数:12,代码来源:Mastersign.Minimods.BitmapToBitmapSource.cs


示例19: GetResourceBitmap

		internal static System.Drawing.Bitmap GetResourceBitmap(string filename)
		{
			System.IO.StreamReader reader = Common.GetResourceReader(filename);
			System.Drawing.Bitmap toReturn = new System.Drawing.Bitmap(reader.BaseStream);
			reader.Close();
			return toReturn;
		}
开发者ID:WinShooter,项目名称:WinShooter-Legacy,代码行数:7,代码来源:Common.cs


示例20: CropImage

            public string CropImage(int x, int y, int w, int h, string imagePath)
            {
                var pathImage = Server.MapPath(imagePath);
                Image img = Image.FromFile(pathImage);
                Bitmap newBitmap = null;
                using (System.Drawing.Bitmap _bitmap = new System.Drawing.Bitmap(w, h))
                {
                    _bitmap.SetResolution(img.HorizontalResolution, img.VerticalResolution);
                    using (Graphics _graphic = Graphics.FromImage(_bitmap))
                    {
                        _graphic.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
                        _graphic.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                        _graphic.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
                        _graphic.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;

                        _graphic.DrawImage(img, 0, 0, w, h);
                        _graphic.DrawImage(img, new Rectangle(0, 0, w, h), x, y, w, h, GraphicsUnit.Pixel);
                    }
                    var objImg = _bitmap.Clone();
                    newBitmap = (Bitmap)objImg;

                }
                var fileName = Path.GetFileNameWithoutExtension(imagePath) + "_Cropped" + Path.GetExtension(imagePath);
                newBitmap.Save(Server.MapPath("/Uploads/Temp/") + fileName, System.Drawing.Imaging.ImageFormat.Jpeg);
                return fileName;
            }
开发者ID:ramonrepositorio,项目名称:CareFit,代码行数:26,代码来源:ImagesController.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Drawing.Color类代码示例发布时间:2022-05-24
下一篇:
C# Diagnostics.Stopwatch类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap