[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Help with Tiff Image

Posted on 2011-10-13
3
Medium Priority
?
212 Views
Last Modified: 2012-08-13
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

0
Comment
Question by:HawaiiDragon
  • 2
3 Comments
 
LVL 16

Accepted Solution

by:
Easwaran Paramasivam earned 2000 total points
ID: 36966533
//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
 

Author Comment

by:HawaiiDragon
ID: 36969188
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
 

Author Closing Comment

by:HawaiiDragon
ID: 37084085
As I have moved on to other things I am closing this question
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question