473,699 Members | 2,413 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Stream blob data to a tiff format

Hi I have an issue when trying to stream blob image data from a SQL table to
a .aspx page. the code I have works for GIF and JPEG but the images can be
multiple pages and we would like them to open in a TIFF format.

What comes back to the screen is garble.... Can anyone help? Thanks

The code I am using is:

SqlConnection myConn = new
SqlConnection(C onfigurationSet tings.AppSettin gs["strConnect ion"]);
SqlCommand myComm = new SqlCommand("Sel ect SX_Image_Data from
SX_ACCSXDB_Imag es where chrBarCode = '" + Request.QuerySt ring["invoice"] +
"'",myConn) ;

myConn.Open();
try
{
byte [] img = (byte[]) myComm.ExecuteS calar();
MemoryStream ms = new MemoryStream();
ms.Write(img, 0, img.Length);
Bitmap bmp = new Bitmap(ms);

bmp.Save(Respon se.OutputStream , ImageFormat.Tif f);

}
catch(Exception )
{
Response.Write( "<center><h4>Th e Invoice you are requesting does not
exist in the system</h4></center>");
}
Nov 16 '05 #1
6 2967
Phil <Ph**@discussio ns.microsoft.co m> wrote:
Hi I have an issue when trying to stream blob image data from a SQL table to
a .aspx page. the code I have works for GIF and JPEG but the images can be
multiple pages and we would like them to open in a TIFF format.

What comes back to the screen is garble.... Can anyone help? Thanks


I can't see anything there setting the content type - have you tried
that?

What happens if you save the output to disk and load it from explorer?

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #2
Phil,

Are you setting the mime type correctly for the image? If the image is
in TIFF format (something that might not be able to be "sniffed" as easily),
then the browser might very well show it as garbage (especially if the
returned mime type says it is something else).

Also, your logic should be changed to show that the invoice does not
exist if the return value is null, not if an exception is thrown. An
exception might be thrown for any number of other reasons in your code,
while the invoice might actually exist. It is misleading, and the idea of
basing business logic on exception handling is generally a bad one (hard to
maintain, etc, etc).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Phil" <Ph**@discussio ns.microsoft.co m> wrote in message
news:14******** *************** ***********@mic rosoft.com...
Hi I have an issue when trying to stream blob image data from a SQL table
to
a .aspx page. the code I have works for GIF and JPEG but the images can be
multiple pages and we would like them to open in a TIFF format.

What comes back to the screen is garble.... Can anyone help? Thanks

The code I am using is:

SqlConnection myConn = new
SqlConnection(C onfigurationSet tings.AppSettin gs["strConnect ion"]);
SqlCommand myComm = new SqlCommand("Sel ect SX_Image_Data from
SX_ACCSXDB_Imag es where chrBarCode = '" + Request.QuerySt ring["invoice"] +
"'",myConn) ;

myConn.Open();
try
{
byte [] img = (byte[]) myComm.ExecuteS calar();
MemoryStream ms = new MemoryStream();
ms.Write(img, 0, img.Length);
Bitmap bmp = new Bitmap(ms);

bmp.Save(Respon se.OutputStream , ImageFormat.Tif f);

}
catch(Exception )
{
Response.Write( "<center><h4>Th e Invoice you are requesting does not
exist in the system</h4></center>");
}

Nov 16 '05 #3
Native TIFF support is not present in either Microsoft Internet Explorer
nor Mozilla FireFox.

--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"Jon Skeet [C# MVP]" <sk***@pobox.co m> wrote in message
news:MP******** *************** *@msnews.micros oft.com...
Phil <Ph**@discussio ns.microsoft.co m> wrote:
Hi I have an issue when trying to stream blob image data from a SQL table
to
a .aspx page. the code I have works for GIF and JPEG but the images can
be
multiple pages and we would like them to open in a TIFF format.

What comes back to the screen is garble.... Can anyone help? Thanks


I can't see anything there setting the content type - have you tried
that?

What happens if you save the output to disk and load it from explorer?

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 16 '05 #4
I have tried Response.Conten tType = "image/tiff"; and this prompts me to open
the document then a dialog box appears saying:

"The file referenced by the shortcut file blablabla\blabl abla\Temp Internet
Files\Content.I E5\blablabla\re questInvoice[1].aspx cannot be opened"

I will also work on the logic once I get the file to open properly.. thanks
for the tip there.

"Nicholas Paldino [.NET/C# MVP]" wrote:
Phil,

Are you setting the mime type correctly for the image? If the image is
in TIFF format (something that might not be able to be "sniffed" as easily),
then the browser might very well show it as garbage (especially if the
returned mime type says it is something else).

Also, your logic should be changed to show that the invoice does not
exist if the return value is null, not if an exception is thrown. An
exception might be thrown for any number of other reasons in your code,
while the invoice might actually exist. It is misleading, and the idea of
basing business logic on exception handling is generally a bad one (hard to
maintain, etc, etc).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Phil" <Ph**@discussio ns.microsoft.co m> wrote in message
news:14******** *************** ***********@mic rosoft.com...
Hi I have an issue when trying to stream blob image data from a SQL table
to
a .aspx page. the code I have works for GIF and JPEG but the images can be
multiple pages and we would like them to open in a TIFF format.

What comes back to the screen is garble.... Can anyone help? Thanks

The code I am using is:

SqlConnection myConn = new
SqlConnection(C onfigurationSet tings.AppSettin gs["strConnect ion"]);
SqlCommand myComm = new SqlCommand("Sel ect SX_Image_Data from
SX_ACCSXDB_Imag es where chrBarCode = '" + Request.QuerySt ring["invoice"] +
"'",myConn) ;

myConn.Open();
try
{
byte [] img = (byte[]) myComm.ExecuteS calar();
MemoryStream ms = new MemoryStream();
ms.Write(img, 0, img.Length);
Bitmap bmp = new Bitmap(ms);

bmp.Save(Respon se.OutputStream , ImageFormat.Tif f);

}
catch(Exception )
{
Response.Write( "<center><h4>Th e Invoice you are requesting does not
exist in the system</h4></center>");
}


Nov 16 '05 #5
Maybe I should give more detail on what I want to do...

When I simply change the code I posted to ImageFormat.Gif .. it streams fine
to IE and opens.. life is good.

But since there are invoices with multiple pages, we would like to open as a
TIFF format in Windows Picture and Fax Viewer. (or default for TIFF on
client). Basically I need to stream this file to the client and then open in
this program (or default for TIFF). I initially thought that by streaming and
opening.. it is essentially placing a copy in the clients temp internet files
and then opening from there.

Thanks for all your help, keep the ideas rolling...

Nov 16 '05 #6
There is a free plugin that will allow you to view TIFF files in the
browser.
It can be downloaded from here:
http://www.alternatiff.com/

However, this will be needed to be installed at the client.
--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"Dennis Myrén" <de****@oslokb. no> wrote in message
news:xQ******** ********@news4. e.nsc.no...
Native TIFF support is not present in either Microsoft Internet Explorer
nor Mozilla FireFox.

--
Regards,
Dennis JD Myrén
Oslo Kodebureau
"Jon Skeet [C# MVP]" <sk***@pobox.co m> wrote in message
news:MP******** *************** *@msnews.micros oft.com...
Phil <Ph**@discussio ns.microsoft.co m> wrote:
Hi I have an issue when trying to stream blob image data from a SQL
table to
a .aspx page. the code I have works for GIF and JPEG but the images can
be
multiple pages and we would like them to open in a TIFF format.

What comes back to the screen is garble.... Can anyone help? Thanks


I can't see anything there setting the content type - have you tried
that?

What happens if you save the output to disk and load it from explorer?

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


Nov 16 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
12301
by: Maurice Mertens | last post by:
Hello, I'm having troubles with saving a tiff-file with a certain compression and colordepth. This is the code I use: ---------------------------------------------------------------------- private sub MakeTiff dim imgSource as new bitmap(strTifSourceFile)
3
4722
by: hamvil79 | last post by:
I'm implementig a java web application using MySQL as database. The main function of the application is basically to redistribuite documents. Those documents (PDF, DOC with an average size around 2Mb) are stored in BLOB column. The amount of documents for the first year should not exceed 5/6 Giga, but I cannot make prevision for the next years. Those documents are mainly just accessed (update and delete are not so
7
5130
by: johnm | last post by:
We have a new CRM application that uses a DB2 7.2 database. Our users noted that the CRM application would not allow them to attach and store any documents over 2 meg in size. When asked, the vendor claims that this behavior is a limit of the DB2 system. We asked the vendor how we might get around this issue since most of our user's documents are over the 2 meg limit. The vendor said that by removing logging from the blob fields the 2...
11
23019
by: Chris Fink | last post by:
I have setup an Oracle table which contains a blob field. How do I insert data into this field using C# and ADO.net?
5
5988
by: Shane Story | last post by:
I can seem to get the dimensions of a frame in a multiframe tiff. After selecting activeframe, the Width/Height is still really much larger than the page's actual dimensions. When I split a TIFF to several PNG files this causes a problem, becuase the resulting image is (the page to the far left and a lot of black space surrounding it and a filesize that is larger than needed. Any ideas?
9
7986
by: matt | last post by:
hello, im doing my first ASP.NET app that inserts & retrieves files from Oracle (no need for a discussion on *that*!). i learned first-hand of the somewhat awkward technique for inserting binary data into an Oracle BLOB column via ADO.NET. since my files are larger than 33k, it seemed had to use this technique: http://support.microsoft.com/default.aspx?scid=kb;en-us;322796
0
1642
by: bananularstyle | last post by:
Hi everyone, This is an issue I have been picking away at for the past two weeks and am running short of ideas. :-\ I am writing an ASP page that allows a user to open/save a tif image stored on SQL Server. The user triggers the download by clicking a hyperlink which loads getAttachment.asp (code listed below). GetAttachment.asp connects to SQL Server through an ODBC and attempts to download the specified tiff using BinaryWrite(). It...
8
18280
by: =?Utf-8?B?Q2hyaXMgRmluaw==?= | last post by:
I am trying to make a minor modification to the code below and need some assistance. Currently this code is using the java.util, java.util.zip, and java.io assemblies from the vjslib.dll assembly. This code works fine by taking file(s) from disk and creating a zip file to disk. I need to modify this code to read a file from a byte array and then output the zip file to a byte array (all done in memory instead of disk). The reason for...
1
1226
by: David C | last post by:
Is there a way in ASP.Net 2.0 to stream individual TIFF image files into one TIFF file? If so, can you point me to any details? Thank you. David
0
8687
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8615
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9174
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9034
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8914
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7750
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4629
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3057
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2347
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.