Draw on Pixel-Size Image : Image : Graphics C# Source Code


Custom Search

C# Source Code » Graphics » Image »

 

Draw on Pixel-Size Image








    
 

using System;
using System.Drawing;
using System.Windows.Forms;
   
class DrawOnPixelSizeImage: Form
{
     Image  image = Image.FromFile("Color.jpg");
     string str = "www.navioo.com";
   
     public static void Main()
     {
          Application.Run(new DrawOnPixelSizeImage());
     }
     public DrawOnPixelSizeImage()
     {
          ResizeRedraw = true;
          
          Graphics grfxImage  = Graphics.FromImage(image);
          Graphics grfxScreen = CreateGraphics();
   
          Font font = new Font(Font.FontFamily, grfxScreen.DpiY / grfxImage.DpiY * Font.SizeInPoints);
   
          SizeF sizef = grfxImage.MeasureString(str, font);
   
          grfxImage.DrawString(str, font, Brushes.White, image.Width - sizef.Width, 0);
          grfxImage.Dispose();
          grfxScreen.Dispose();
     }
     protected override void OnPaint(PaintEventArgs pea)
     {
          DoPage(pea.Graphics, ForeColor,ClientSize.Width, ClientSize.Height);
     }   
     protected void DoPage(Graphics grfx, Color clr, int cx, int cy)
     {
          grfx.DrawImage(image, 0, 0, image.Width, image.Height);
          grfx.DrawString(str, Font, new SolidBrush(clr), image.Width, 0);
     }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Graphics
» Image