Help with Tiff Image

Okay so I am wrighting some text over a picture It works fine for JPG but I need it to work for Tiff can some one show me what I am doing wrong please


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using System.Drawing.Text;
using System.Web.SessionState;

namespace WebApplication3
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {   // this one works good
            Bitmap bitMapImage = new Bitmap(Server.MapPath("dallen.jpg"));
             /// but when I try to use a tif  she blows up image that is suposed to go below
          //  Bitmap bitMapImage = new Bitmap(Server.MapPath("Davis.tif"));


           // Bitmap bitMapImage = new System.Drawing.Bitmap(Server.MapPath("dallen.jpg"));
            Graphics graphicImage = Graphics.FromImage(bitMapImage);

            //Smooth graphics is nice.
            graphicImage.SmoothingMode = SmoothingMode.AntiAlias;

            //I am drawing a oval around my text.
           // graphicImage.DrawArc(new Pen(Color.Red, 3), 90, 235, 150, 50, 0, 360);

            //Write your text.
            graphicImage.DrawString("That's my boy!", new Font("Arial", 12, FontStyle.Bold), SystemBrushes.WindowText, new Point(100, 250));

            //Set the content type
            Response.ContentType = "image/jpg";
            // Need to change to tiff but noting working
           // Response.ContentType = "image/tif";


            //Save the new image to the response output stream.
            bitMapImage.Save(Response.OutputStream, ImageFormat.Jpeg);

            //Clean house.
            graphicImage.Dispose();
            bitMapImage.Dispose();



        }
    }
}

Open in new window

HawaiiDragonAsked:
Who is Participating?
 
Easwaran ParamasivamCommented:
//The content type should be as tiff
 
  Response.ContentType = "image/tiff";    

 //The save option to TIFF

  bitMapImage.Save(Response.OutputStream, ImageFormat.Tiff);

 //Finally end your response. If you miss, this may cause to blow up.

   Response.OutputStream.Flush();
   Response.End();
0
 
HawaiiDragonAuthor Commented:
I now get this error

A generic error occurred in GDI+.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using System.Drawing.Text;
using System.Web.SessionState;

namespace WebApplication3
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {   // this one works good
           Bitmap bitMapImage = new Bitmap(Server.MapPath("Scott.tiff"));
             /// but when I try to use a tif  she blows up image that is suposed to go below
         // Bitmap bitMapImage = new Bitmap(Server.MapPath("Davis.tiff"));


           // Bitmap bitMapImage = new System.Drawing.Bitmap(Server.MapPath("dallen.jpg"));
            Graphics graphicImage = Graphics.FromImage(bitMapImage);

            //Smooth graphics is nice.
            graphicImage.SmoothingMode = SmoothingMode.AntiAlias;

            //I am drawing a oval around my text.
           // graphicImage.DrawArc(new Pen(Color.Red, 3), 90, 235, 150, 50, 0, 360);

            //Write your text.
            graphicImage.DrawString("Fucking Work", new Font("Arial", 12, FontStyle.Bold), SystemBrushes.WindowText, new Point(0, 0));

            //Set the content type
           //Response.ContentType = "image/jpg";
            // Need to change to tiff but noting working
          Response.ContentType = "image/tiff";


            //Save the new image to the response output stream.
            bitMapImage.Save(Response.OutputStream, ImageFormat.Tiff);

            //Clean house.
            Response.OutputStream.Flush();
            Response.End();
            graphicImage.Dispose();
            bitMapImage.Dispose();



        }
    }
}

Open in new window

0
 
HawaiiDragonAuthor Commented:
As I have moved on to other things I am closing this question
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.