This is my code. When i use an image that is a jpeg format it works. But when i use a tif format it gives me a warning like "A graphics object cannot be created from an image that has an indexed pixel format" when i run it with a tif format image
Can somebody help me to solve this problem??

 private void drawOnPic()        
{            
      // Attach grapich to picturebox            
      Graphics g = Graphics.FromImage(pictureBox1.Image);             

      // Create a new pen that we shall use for drawing the line            
      Pen PenStyle = new Pen(Color.Red, 1);             

      // Draw a 50x50 pixels rectangle (x, y, width, hight)           
      g.DrawRectangle(PenStyle, 20, 20, 50, 50);        
}         

 private void Form1_Load(object sender, EventArgs e)        
{            
         drawOnPic();    
}

You'll have to load the tiff image as a BMP thn get the graphic object from that.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.