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

C# Bitmap类代码示例

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

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



Bitmap类属于命名空间,在下文中一共展示了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: resizeImage

    private static System.Drawing.Image resizeImage(System.Drawing.Image imgToResize, Size size)
    {
        //int sourceWidth = imgToResize.Width;
        //int sourceHeight = imgToResize.Height;

        //float nPercent = 0;
        //float nPercentW = 0;
        //float nPercentH = 0;

        //nPercentW = ((float)size.Width / (float)sourceWidth);
        //nPercentH = ((float)size.Height / (float)sourceHeight);

        //if (nPercentH < nPercentW)
        //    nPercent = nPercentH;
        //else
        //    nPercent = nPercentW;

        //int destWidth = (int)(sourceWidth * nPercent);
        //int destHeight = (int)(sourceHeight * nPercent);
        int destWidth = size.Width;
        int destHeight = size.Height;

        Bitmap b = new Bitmap(destWidth, destHeight);
        Graphics g = Graphics.FromImage((System.Drawing.Image)b);
        g.InterpolationMode = InterpolationMode.HighQualityBicubic;

        g.DrawImage(imgToResize, 0, 0, destWidth, destHeight);
        g.Dispose();

        return (System.Drawing.Image)b;
    }
开发者ID:zachi,项目名称:artyshot,代码行数:31,代码来源:Utils.aspx.cs


示例3: Main

	public static void Main(string[] args)
	{	
		Graphics.DrawImageAbort imageCallback;
		Bitmap outbmp = new Bitmap (300, 300);				
		Bitmap bmp = new Bitmap("../../Test/System.Drawing/bitmaps/almogaver24bits.bmp");
		Graphics dc = Graphics.FromImage (outbmp);        
		
		ImageAttributes imageAttr = new ImageAttributes();
		
		/* Simple image drawing */		
		dc.DrawImage(bmp, 0,0);				
				
		/* Drawing using points */
		PointF ulCorner = new PointF(150.0F, 0.0F);
		PointF urCorner = new PointF(350.0F, 0.0F);
		PointF llCorner = new PointF(200.0F, 150.0F);
		RectangleF srcRect = new Rectangle (0,0,100,100);		
		PointF[] destPara = {ulCorner, urCorner, llCorner};	
		imageCallback =  new Graphics.DrawImageAbort(DrawImageCallback);		
		dc.DrawImage (bmp, destPara, srcRect, GraphicsUnit.Pixel, imageAttr, imageCallback);
	
		/* Using rectangles */	
		RectangleF destRect = new Rectangle (10,200,100,100);
		RectangleF srcRect2 = new Rectangle (50,50,100,100);		
		dc.DrawImage (bmp, destRect, srcRect2, GraphicsUnit.Pixel);		
		
		/* Simple image drawing with with scaling*/		
		dc.DrawImage(bmp, 200,200, 75, 75);				
		
		outbmp.Save("drawimage.bmp", ImageFormat.Bmp);				
		
	}
开发者ID:nlhepler,项目名称:mono,代码行数:32,代码来源:drawimage.cs


示例4: CreateDirectBrush

        private BitmapBrush CreateDirectBrush(
            ImageBrush brush,
            SharpDX.Direct2D1.RenderTarget target,
            Bitmap image, 
            Rect sourceRect, 
            Rect destinationRect)
        {
            var tileMode = brush.TileMode;
            var scale = brush.Stretch.CalculateScaling(destinationRect.Size, sourceRect.Size);
            var translate = CalculateTranslate(brush, sourceRect, destinationRect, scale);
            var transform = Matrix.CreateTranslation(-sourceRect.Position) *
                Matrix.CreateScale(scale) *
                Matrix.CreateTranslation(translate);

            var opts = new BrushProperties
            {
                Transform = transform.ToDirect2D(),
                Opacity = (float)brush.Opacity,
            };

            var bitmapOpts = new BitmapBrushProperties
            {
                ExtendModeX = GetExtendModeX(tileMode),
                ExtendModeY = GetExtendModeY(tileMode),                
            };

            return new BitmapBrush(target, image, bitmapOpts, opts);
        }
开发者ID:rdterner,项目名称:Perspex,代码行数:28,代码来源:ImageBrushImpl.cs


示例5: ImageMenu

    public ImageMenu()
    {
        this.Text = "메뉴 선택 표시와 이미지 넣기";

        // 이미지 개체 준비
        Bitmap bmp1 = new Bitmap(GetType(), "ImageMenu.image_1.bmp");
        Bitmap bmp2 = new Bitmap(GetType(), "ImageMenu.image_2.bmp");

        MenuStrip menu = new MenuStrip();
        menu.Parent = this;

        // File 항목
        ToolStripMenuItem file_item = new ToolStripMenuItem();
        file_item.Text = "&File";
        file_item.Image = bmp1;         // 메뉴에 출력할 이미지 지정
        menu.Items.Add(file_item);

        select_item = new ToolStripMenuItem();
        select_item.Text = "&Select";
        select_item.Click += EventProc;
        file_item.DropDownItems.Add(select_item);

        // 메뉴 구분선 넣기
        ToolStripSeparator file_item_sep = new ToolStripSeparator();
        file_item.DropDownItems.Add(file_item_sep);

        ToolStripMenuItem close_item = new ToolStripMenuItem();
        close_item.Text = "&Close";
        close_item.Image = bmp2;
        close_item.ShortcutKeys = Keys.Alt | Keys.F4;
        close_item.Click += EventProc;
        file_item.DropDownItems.Add(close_item);
    }
开发者ID:gawallsibya,项目名称:BIT_MFC-CShap-DotNet,代码行数:33,代码来源:Program.cs


示例6: CreateImage

    /// <summary>
    /// ����ͼƬ
    /// </summary>
    /// <param name="checkCode">�����</param>
    private void CreateImage(string checkCode)
    {
        int iwidth = (int)(checkCode.Length * 11.5);//����������趨ͼƬ���
        Bitmap image = new Bitmap(iwidth, 20);//����һ������
        Graphics g = Graphics.FromImage(image);//�ڻ����϶����ͼ��ʵ��
        Font f = new Font("Arial",10,FontStyle.Bold);//���壬��С����ʽ
        Brush b = new SolidBrush(Color.Black);//������ɫ
        //g.FillRectangle(new System.Drawing.SolidBrush(Color.Blue),0,0,image.Width, image.Height);
        g.Clear(Color.White);//������ɫ
        g.DrawString(checkCode, f, b, 3, 3);

        Pen blackPen = new Pen(Color.Black, 0);
        Random rand = new Random();
        /*�����
        for (int i = 0; i < 5; i++)
        {
            int y = rand.Next(image.Height);
            g.DrawLine(blackPen, 0, y, image.Width, y);
        }
        */
        System.IO.MemoryStream ms = new System.IO.MemoryStream();
        image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
        Response.ClearContent();
        Response.ContentType = "image/Jpeg";
        Response.BinaryWrite(ms.ToArray());
        g.Dispose();
        image.Dispose();
    }
开发者ID:vtmer,项目名称:NewStudent,代码行数:32,代码来源:checkCode.aspx.cs


示例7: ReSizeImage

    public string ReSizeImage(string imagePath, string outputPath, int newWidth)
    {
        System.Drawing.Image bm = System.Drawing.Image.FromFile(imagePath);
            string ext = Path.GetExtension(imagePath);
            string fileN = Path.GetFileName(imagePath);
            var imgFor = GetFormat(ext);
            int NewHeight = (bm.Height*newWidth)/bm.Width;

            Bitmap resized = new Bitmap(newWidth, NewHeight);

            Graphics g = Graphics.FromImage(resized);

            g.DrawImage(bm, new Rectangle(0, 0, resized.Width, resized.Height), 0, 0, bm.Width, bm.Height,
                GraphicsUnit.Pixel);

            g.Dispose();
            bm.Dispose();

            if (imgFor != null)
            {
                resized.Save(outputPath + fileN, imgFor);
                return outputPath + fileN;
            }
            else
            {
                return null;
            }
    }
开发者ID:HenrikObsen,项目名称:MVC_Blog,代码行数:28,代码来源:Uploader.cs


示例8: convertirGris

    //Función que convierte una imagen a escala de grises
    public void convertirGris(string imagefrom, string imageto)
    {
        //create a blank bitmap the same size as original
        Bitmap original = new Bitmap(imagefrom);
        Bitmap newBitmap = new Bitmap(original.Width, original.Height);

        //get a graphics object from the new image
        Graphics g = Graphics.FromImage(newBitmap);

        //create the grayscale ColorMatrix
        ColorMatrix colorMatrix = new ColorMatrix(new float[][]
         {
             new float[] {.30f, .30f, .30f, 0, 0},
             new float[] {.59f, .59f, .59f, 0, 0},
             new float[] {.11f, .11f, .11f, 0, 0},
             new float[] {0, 0, 0, 1, 0},
             new float[] {0, 0, 0, 0, 1}
         });

        //create some image attributes
        ImageAttributes attributes = new ImageAttributes();

        //set the color matrix attribute
        attributes.SetColorMatrix(colorMatrix);

        //draw the original image on the new image
        //using the grayscale color matrix
        g.DrawImage(original, new Rectangle(0, 0, original.Width, original.Height),
           0, 0, original.Width, original.Height, GraphicsUnit.Pixel, attributes);

        //dispose the Graphics object
        g.Dispose();
        newBitmap.Save(imageto);
    }
开发者ID:ClickApp,项目名称:crackcompany,代码行数:35,代码来源:ProcesarImagenes.cs


示例9: Filter

        public static UIImage Filter(UIImage img, int puzzleSize)
        {
            int tileSize = 2;
            int paletteColorsNumber = BasePaletteColorsNumber + (8 * puzzleSize / 64);

            // 1/ Get the main colors
            // So we have a color palette
            Logger.I ("Filter: getting palette...");
            var colorPalette = getColorPalette (img, paletteColorsNumber);

            // 1/ Resize & Load image as readable
            UIImage resizedImg = UIImageEx.ResizeRatio (img, puzzleSize);
            Bitmap bitmap = new Bitmap (resizedImg);

            // 2/ Apply mosaic
            Logger.I ("Filter: applying mosaic...");
            var flippedImage = applyMosaic (tileSize, colorPalette, resizedImg, bitmap);

            // -- Flip because bitmap has inverted coordinates
            Logger.I ("Filter: resizing...");
            UIImage finalImg = new UIImage (flippedImage, 0f, UIImageOrientation.DownMirrored);
            //			UIImage finalImg = new UIImage (flippedImage);

            // -- Resize the final
            //			return ResizeRatio (finalImg, FinalSize);

            Logger.I ("Filter: image ready!");
            return finalImg;
        }
开发者ID:valryon,项目名称:pixpuzzle,代码行数:29,代码来源:ImageFilters.cs


示例10: SetFontBitmap

 /// <summary> Sets the bitmap that contains the bitmapped font characters as an atlas. </summary>
 public void SetFontBitmap( Bitmap bmp )
 {
     FontBitmap = bmp;
     boxSize = FontBitmap.Width / 16;
     fontPixels = new FastBitmap( FontBitmap, true, true );
     CalculateTextWidths();
 }
开发者ID:Chameleonherman,项目名称:ClassicalSharp,代码行数:8,代码来源:IDrawer2D.TextMC.cs


示例11: OnPaint

 protected override void OnPaint(PaintEventArgs e)
 {
     Graphics g = e.Graphics;
     Bitmap bmp = new Bitmap("back.jpg");
     Rectangle r = new Rectangle(0, 0, bmp.Width, bmp.Height);
     g.DrawImage(bmp, r, r, GraphicsUnit.Pixel);
 }
开发者ID:dbremner,项目名称:hycs,代码行数:7,代码来源:helloImage.cs


示例12: generateTicket

    public  Bitmap generateTicket(string ticketType, string start, string destination, string price)
    {
        
       //Orte der verschiedenen Textboxen auf dem Ticket:
        Point StartLine1 = new Point(0,100);
        Point EndLine1 = new Point(960, 100);
        Point StartLine2 = new Point(0, 700);
        Point EndLine2 = new Point(960, 700);
        PointF logoLocation = new PointF(150,20);
        PointF fromLocation = new PointF(40,300);
        PointF toLocation = new PointF(40,500);
        PointF totalLocation = new PointF(40,750);
        PointF ticketTypeLocation = new PointF(40, 150);
        PointF startLocation = new PointF(40, 400);
        PointF destinationLocation = new PointF(40, 600);
        PointF priceLocation = new PointF(500, 750);

        //string imageFilePath = "C:\\Users\\kuehnle\\Documents\\TestWebsite\\NewTestTicket.bmp";

        
        Bitmap tempBmp = new Bitmap(960,900);

        //auf das neu erstellte Bitmap draufzeichnen:
        using (Graphics g = Graphics.FromImage(tempBmp))
        {

            g.Clear(Color.White);
            g.DrawLine(new Pen(Brushes.Black,10), StartLine1, EndLine1);
            g.DrawLine(new Pen(Brushes.Black,10), StartLine2, EndLine2);
            
            using (Font arialFont = new Font("Arial", 40,FontStyle.Bold))
            {

                g.DrawString("Jakarta Commuter Train", arialFont, Brushes.Black, logoLocation);
               
                g.DrawString(ticketType, arialFont, Brushes.Black, ticketTypeLocation);
                

            }
            using (Font arialFont = new Font("Arial", 40, FontStyle.Underline))
            {
                g.DrawString("From:", arialFont, Brushes.Black, fromLocation);
                g.DrawString("To:", arialFont, Brushes.Black, toLocation);
            }
            using (Font arialFont = new Font("Arial", 40, FontStyle.Regular))
            {
                g.DrawString("Total:", arialFont, Brushes.Black, totalLocation);
                g.DrawString(start, arialFont, Brushes.Black, startLocation);
                g.DrawString(destination, arialFont, Brushes.Black, destinationLocation);
                g.DrawString(price, arialFont, Brushes.Black, priceLocation);
            }
        }
        //Farbtiefe auf 1 reduzieren:
        Bitmap ticket = tempBmp.Clone(new Rectangle(0, 0, tempBmp.Width, tempBmp.Height),PixelFormat.Format1bppIndexed);
        
        //ticket.Save(imageFilePath,System.Drawing.Imaging.ImageFormat.Bmp);
        //ticket.Dispose();
        return ticket;

    }
开发者ID:cstrobbe,项目名称:C4A-TVM,代码行数:60,代码来源:Printer.cs


示例13: ProcessRequest

    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "image/jpeg";
        string url = context.Request.RawUrl;
        string path = context.Request.MapPath(url);

        using (Image priImg = Image.FromFile(path))
        {
            int width = 660;
            int height = 350;
            if (priImg.Width > priImg.Height)
            {
                height = width * priImg.Height / priImg.Width;
            }
            else
            {
                width = height * priImg.Width / priImg.Height;
            }
            path = context.Request.MapPath("logo.png");
            using (Image logo = Image.FromFile(path))
            {
                using (Bitmap bm = new Bitmap(width, height))
                {
                    using (Graphics g = Graphics.FromImage(bm))
                    {
                        g.DrawImage(priImg, 0, 0, bm.Width, bm.Height);
                        g.DrawImage(logo, bm.Width - logo.Width, bm.Height - logo.Height, logo.Width, logo.Height);
                        bm.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
                    }
                }
            }
        }
    }
开发者ID:hdkn235,项目名称:MyPhotosNew,代码行数:33,代码来源:WaterMaker.cs


示例14: eval_a

 public decimal eval_a(Bitmap A_0, decimal A_1)
 {
     while (true)
     {
         decimal num = eval_be.eval_a(A_0, eval_i.eval_a);
         int num2 = 4;
         while (true)
         {
             switch (num2)
             {
             case 0:
                 if (true)
                 {
                 }
                 num2 = 7;
                 continue;
             case 1:
                 return A_1;
             case 2:
                 if (num < 0m)
                 {
                     num2 = 1;
                     continue;
                 }
                 return num;
             case 3:
                 num = eval_be.eval_a(A_0, eval_i.eval_b);
                 num2 = 5;
                 continue;
             case 4:
                 if (num < 0m)
                 {
                     num2 = 0;
                     continue;
                 }
                 return num;
             case 5:
                 if (num < A_1)
                 {
                     num2 = 6;
                     continue;
                 }
                 goto IL_5F;
             case 6:
                 return A_1;
             case 7:
                 if (eval_i.eval_b != null)
                 {
                     num2 = 3;
                     continue;
                 }
                 goto IL_5F;
             }
             break;
             IL_5F:
             num2 = 2;
         }
     }
     return A_1;
 }
开发者ID:JABirchall,项目名称:FullAutoHoldem,代码行数:60,代码来源:eval_i.cs


示例15: getImageValidate

 //生成图像
 private void getImageValidate(string strValue)
 {
     //string str = "OO00"; //前两个为字母O,后两个为数字0
     int width = Convert.ToInt32(strValue.Length * 12);    //计算图像宽度
     Bitmap img = new Bitmap(width, 23);
     Graphics gfc = Graphics.FromImage(img);           //产生Graphics对象,进行画图
     gfc.Clear(Color.White);
     drawLine(gfc, img);
     //写验证码,需要定义Font
     Font font = new Font("arial", 12, FontStyle.Bold);
     System.Drawing.Drawing2D.LinearGradientBrush brush =
         new System.Drawing.Drawing2D.LinearGradientBrush(new Rectangle(0, 0, img.Width, img.Height), Color.DarkOrchid, Color.Blue, 1.5f, true);
     gfc.DrawString(strValue, font, brush, 3, 2);
     drawPoint(img);
     gfc.DrawRectangle(new Pen(Color.DarkBlue), 0, 0, img.Width - 1, img.Height - 1);
     //将图像添加到页面
     MemoryStream ms = new MemoryStream();
     img.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);
     //更改Http头
     Response.ClearContent();
     Response.ContentType = "image/gif";
     Response.BinaryWrite(ms.ToArray());
     //Dispose
     gfc.Dispose();
     img.Dispose();
     Response.End();
 }
开发者ID:kooyou,项目名称:TrafficFinesSystem,代码行数:28,代码来源:CreateImg.aspx.cs


示例16: Invert

        public static bool Invert(Bitmap b)
        {
            // GDI+ still lies to us - the return format is BGR, NOT RGB.
            BitmapData bmData = b.LockBits(new Rectangle(0, 0, b.Width, b.Height),
                ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
            int stride = bmData.Stride;
            System.IntPtr Scan0 = bmData.Scan0;
            unsafe
            {
                byte* p = (byte*)(void*)Scan0;
                int nOffset = stride - b.Width * 3;
                int nWidth = b.Width * 3;
                for (int y = 0; y < b.Height; ++y)
                {
                    for (int x = 0; x < nWidth; ++x)
                    {
                        p[0] = (byte)(255 - p[0]);
                        ++p;
                    }
                    p += nOffset;
                }
            }

            b.UnlockBits(bmData);

            return true;
        }
开发者ID:TechBridgeWorld,项目名称:TactileGraphics,代码行数:27,代码来源:Program.cs


示例17: GenerateBarcodeImage

    public Bitmap GenerateBarcodeImage(string text, FontFamily fontFamily, int fontSizeInPoints)
    {
        StringBuilder sb = new StringBuilder();
        sb.Append("*");
        sb.Append(text);
        sb.Append("*");

        Bitmap bmp = new Bitmap(1, 1, PixelFormat.Format32bppArgb);

        Font font = new Font(fontFamily, fontSizeInPoints, FontStyle.Regular, GraphicsUnit.Point);

        Graphics graphics = Graphics.FromImage(bmp);

        SizeF textSize = graphics.MeasureString(sb.ToString(), font);

        bmp = new Bitmap(bmp, textSize.ToSize());

        graphics = Graphics.FromImage(bmp);
        graphics.Clear(Color.White);
        graphics.TextRenderingHint = TextRenderingHint.SingleBitPerPixel;
        graphics.DrawString(sb.ToString(), font, new SolidBrush(Color.Black), 0, 0);
        graphics.Flush();

        font.Dispose();
        graphics.Dispose();

        return bmp;
    }
开发者ID:rid50,项目名称:PSCBioOffice,代码行数:28,代码来源:Helper.cs


示例18: BitMapToByte

    /// <summary>
    /// BitMap转换成二进制
    /// </summary>
    /// <param name="bitmap"></param>
    /// <returns></returns>
    public static byte[] BitMapToByte(Bitmap bitmap)
    {
        //List<byte[]> list = new List<byte[]>();
        MemoryStream ms = null;
        byte[] imgData = null;

        ///重新绘图并指定大小
        int destWidth = 794;
        int destHight = 1122;

        Bitmap newBitmap = new Bitmap(destWidth, destHight);
        using(Graphics g=Graphics.FromImage((Image)newBitmap))
        {
            g.InterpolationMode = InterpolationMode.HighQualityBicubic;
            g.SmoothingMode = SmoothingMode.AntiAlias;
            g.CompositingQuality = CompositingQuality.HighQuality;
            g.DrawImage((Image)bitmap, 0, 0, destWidth, destHight);
            g.Dispose();
        }

        ///

        using (ms = new MemoryStream())
        {
            newBitmap.Save(ms, ImageFormat.Jpeg);
            ms.Position = 0;
            imgData = new byte[ms.Length];
            ms.Read(imgData, 0, Convert.ToInt32(ms.Length));
            ms.Flush();
        }
        //list.Add(imgData);
        return imgData;
    }
开发者ID:hkis,项目名称:octopus,代码行数:38,代码来源:ImageTools.cs


示例19: CreateImage

    private void CreateImage()
    {
        Session["captcha.guid"] = Guid.NewGuid().ToString ("N");
        string code = GetRandomText();

        Bitmap bitmap = new Bitmap(WIDTH,HEIGHT,System.Drawing.Imaging.PixelFormat.Format32bppArgb);

        Graphics g = Graphics.FromImage(bitmap);
        Pen pen = new Pen(Color.DarkSlateGray);
        Rectangle rect = new Rectangle(0,0,WIDTH,HEIGHT);

        SolidBrush background = new SolidBrush(Color.AntiqueWhite);
        SolidBrush textcolor = new SolidBrush(Color.DarkSlateGray);

        int counter = 0;

        g.DrawRectangle(pen, rect);
        g.FillRectangle(background, rect);

        for (int i = 0; i < code.Length; i++)
        {
            g.DrawString(code[i].ToString(),
                         new Font("Verdana", 10 + rand.Next(6, 14)),
                         textcolor,
                         new PointF(10 + counter, 10));
            counter += 25;
        }

        DrawRandomLines(g);

        bitmap.Save(Response.OutputStream,ImageFormat.Gif);

        g.Dispose();
        bitmap.Dispose();
    }
开发者ID:nageshverma2003,项目名称:TrackProtectSource,代码行数:35,代码来源:CaptchaControl.aspx.cs


示例20: CaptureNow

    /// <summary>
    /// Capture the AutoCAD window now, returning the path of the file saved
    /// </summary>
    /// <returns></returns>
    public String CaptureNow()
    {
        if (InitGeometryReflectionInfo())
                update_display.Invoke(null, new object[]{});

            IntPtr main_window = System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle;
            RECT rect;
            GetWindowRect(main_window, out rect);

            int width = (int)(rect.Right - rect.Left);
            int height = (int)(rect.Bottom - rect.Top);

            string filename = BuildFileName();
            using (Bitmap image = new Bitmap(width, height))
            {

                Graphics g = Graphics.FromImage(image);
                g.CopyFromScreen((int)(rect.Left), (int)(rect.Top), 0, 0, new System.Drawing.Size(width, height));

                image.Save(filename);
            }

            counter++;

            return filename;
    }
开发者ID:samuto,项目名称:designscript,代码行数:30,代码来源:ScreenRecorder.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Bits类代码示例发布时间:2022-05-24
下一篇:
C# BitcoinStream类代码示例发布时间: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