473,498 Members | 1,721 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using response.write to display system.drawing.image

Hi all.

Hope you can help me. This should be easy but I can't make this work.
In brief I am building a page of thumbnails using images held in a
SQLServer 2000 database. I do this by creating imagebuttons which
point to a dummy page that takes the image and displays it via
response. All works fine if I use explicit paths to a file
(response.writefile(<filename>) or directly pass through the database
image (response.binarywrite(<dbimage>), but I convert the db image to
system.drawing.image so as to resize etc, and once I do that I can't
display it.

I have used the following code to take the database image, convert it
into a system.drawing.image and show the results (this is obviously a
cut down version of the original).

Dim clsTableImage As New TableImage
If clsTableImage.GetRecord(CType(1, Short)) = 0 Then
' Make an image object of the image using a stream
Dim FullSizeImage As System.Drawing.Image
Dim fs As New System.IO.MemoryStream
Dim w As New System.IO.BinaryWriter(fs)
w.Write(clsTableImage.Image)
FullSizeImage = System.Drawing.Image.FromStream(fs)

'Response.ContentType = "image/jpeg"
Response.Write(FullSizeImage)
End If

clsTableImage is a class that returns the image as a byte array. What
I get out of this is the text "system.drawing.bitmap". So, how do I
send a system.drawing.image to the form in ASP 1.1?

Thanks in advance.

Dave

Nov 26 '06 #1
3 6406
You would typically Response.Write the byte array itself.
No need to create an image from it.

--
Robbe Morris - 2004-2006 Microsoft MVP C#
I've mapped the database to .NET class properties and methods to
implement an multi-layered object oriented environment for your
data access layer. Thus, you should rarely ever have to type the words
SqlCommand, SqlDataAdapter, or SqlConnection again.
http://www.eggheadcafe.com/articles/..._generator.asp

"Dave Keen" <da********@hotmail.comwrote in message
news:11**********************@l39g2000cwd.googlegr oups.com...
Hi all.

Hope you can help me. This should be easy but I can't make this work.
In brief I am building a page of thumbnails using images held in a
SQLServer 2000 database. I do this by creating imagebuttons which
point to a dummy page that takes the image and displays it via
response. All works fine if I use explicit paths to a file
(response.writefile(<filename>) or directly pass through the database
image (response.binarywrite(<dbimage>), but I convert the db image to
system.drawing.image so as to resize etc, and once I do that I can't
display it.

I have used the following code to take the database image, convert it
into a system.drawing.image and show the results (this is obviously a
cut down version of the original).

Dim clsTableImage As New TableImage
If clsTableImage.GetRecord(CType(1, Short)) = 0 Then
' Make an image object of the image using a stream
Dim FullSizeImage As System.Drawing.Image
Dim fs As New System.IO.MemoryStream
Dim w As New System.IO.BinaryWriter(fs)
w.Write(clsTableImage.Image)
FullSizeImage = System.Drawing.Image.FromStream(fs)

'Response.ContentType = "image/jpeg"
Response.Write(FullSizeImage)
End If

clsTableImage is a class that returns the image as a byte array. What
I get out of this is the text "system.drawing.bitmap". So, how do I
send a system.drawing.image to the form in ASP 1.1?

Thanks in advance.

Dave
Nov 27 '06 #2
Hi Robbe

Thanks for your thoughts. Unfortunately I have to convert to an image
object as I want to resize and manipulate the image before showing it.
Remember I said the code I gave was a simplified version. After I take
the byte array and convert to an image which I have changed in various
ways I need to pass that image object to the form. How?

Cheers

Dave
Robbe Morris [C# MVP] wrote:
You would typically Response.Write the byte array itself.
No need to create an image from it.

--
Robbe Morris - 2004-2006 Microsoft MVP C#
I've mapped the database to .NET class properties and methods to
implement an multi-layered object oriented environment for your
data access layer. Thus, you should rarely ever have to type the words
SqlCommand, SqlDataAdapter, or SqlConnection again.
http://www.eggheadcafe.com/articles/..._generator.asp

"Dave Keen" <da********@hotmail.comwrote in message
news:11**********************@l39g2000cwd.googlegr oups.com...
Hi all.

Hope you can help me. This should be easy but I can't make this work.
In brief I am building a page of thumbnails using images held in a
SQLServer 2000 database. I do this by creating imagebuttons which
point to a dummy page that takes the image and displays it via
response. All works fine if I use explicit paths to a file
(response.writefile(<filename>) or directly pass through the database
image (response.binarywrite(<dbimage>), but I convert the db image to
system.drawing.image so as to resize etc, and once I do that I can't
display it.

I have used the following code to take the database image, convert it
into a system.drawing.image and show the results (this is obviously a
cut down version of the original).

Dim clsTableImage As New TableImage
If clsTableImage.GetRecord(CType(1, Short)) = 0 Then
' Make an image object of the image using a stream
Dim FullSizeImage As System.Drawing.Image
Dim fs As New System.IO.MemoryStream
Dim w As New System.IO.BinaryWriter(fs)
w.Write(clsTableImage.Image)
FullSizeImage = System.Drawing.Image.FromStream(fs)

'Response.ContentType = "image/jpeg"
Response.Write(FullSizeImage)
End If

clsTableImage is a class that returns the image as a byte array. What
I get out of this is the text "system.drawing.bitmap". So, how do I
send a system.drawing.image to the form in ASP 1.1?

Thanks in advance.

Dave
Nov 27 '06 #3
Hi Robbe

Thanks for your thoughts. Unfortunately I have to convert to an image
object as I want to resize and manipulate the image before showing it.
Remember I said the code I gave was a simplified version. After I take
the byte array and convert to an image which I have changed in various
ways I need to pass that image object to the form. How?

Cheers

Dave
Robbe Morris [C# MVP] wrote:
You would typically Response.Write the byte array itself.
No need to create an image from it.

--
Robbe Morris - 2004-2006 Microsoft MVP C#
I've mapped the database to .NET class properties and methods to
implement an multi-layered object oriented environment for your
data access layer. Thus, you should rarely ever have to type the words
SqlCommand, SqlDataAdapter, or SqlConnection again.
http://www.eggheadcafe.com/articles/..._generator.asp

"Dave Keen" <da********@hotmail.comwrote in message
news:11**********************@l39g2000cwd.googlegr oups.com...
Hi all.

Hope you can help me. This should be easy but I can't make this work.
In brief I am building a page of thumbnails using images held in a
SQLServer 2000 database. I do this by creating imagebuttons which
point to a dummy page that takes the image and displays it via
response. All works fine if I use explicit paths to a file
(response.writefile(<filename>) or directly pass through the database
image (response.binarywrite(<dbimage>), but I convert the db image to
system.drawing.image so as to resize etc, and once I do that I can't
display it.

I have used the following code to take the database image, convert it
into a system.drawing.image and show the results (this is obviously a
cut down version of the original).

Dim clsTableImage As New TableImage
If clsTableImage.GetRecord(CType(1, Short)) = 0 Then
' Make an image object of the image using a stream
Dim FullSizeImage As System.Drawing.Image
Dim fs As New System.IO.MemoryStream
Dim w As New System.IO.BinaryWriter(fs)
w.Write(clsTableImage.Image)
FullSizeImage = System.Drawing.Image.FromStream(fs)

'Response.ContentType = "image/jpeg"
Response.Write(FullSizeImage)
End If

clsTableImage is a class that returns the image as a byte array. What
I get out of this is the text "system.drawing.bitmap". So, how do I
send a system.drawing.image to the form in ASP 1.1?

Thanks in advance.

Dave
Nov 27 '06 #4

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

Similar topics

0
17835
by: Nicolas Guilhot | last post by:
Hi all ! I have a multi-page Tiff image file that I want to convert to PDF. To do so I am using iText library. The conversion is working, but the code execution is very different according to...
0
6413
by: Michelle Keys | last post by:
I am trying to call a print function to print a string from a database using javascript. Which is RC_DATA of Varchar2(2500). This is a javascript is not being used. I have a thing that needs to...
3
2081
by: Josema | last post by:
Hi to all, I have stored in a database some binary files (pdfs, and gif images), i would like to know how could i show it, in internet explorer when a person enters for instance in a textbox the...
0
1826
by: John via .NET 247 | last post by:
Hi, I'm using the System.Drawing.Bitmap namespace to load an image,and the RotateNoneFlipY method to flip that image before saving.However I have noticed that the saved image appears cropped...
3
3054
by: Hitesh | last post by:
Hi, I am getting the response from another Website by using the HttpHandler in my current site. I am getting the page but all the images on that page are not appearing only placeholder are...
1
2338
by: rushikesh.joshi | last post by:
Hi All, I want some charting functionality in my ASP.NET application. I want to show a multiple bar on my web page. It's based on down time of different servers. like server1: down betn 4 AM...
4
3801
by: Greg | last post by:
I've searched everywhere for a solution Microsoft .NET Framework V 2.0.50727 AutoEventWireup="false" image2.aspx resize an image on the fly but Page_Load is triggered twice: Any suggestion?...
1
4402
by: WeCi2i | last post by:
Okay, I have a problem that has been stumping me for weeks. I have tried many different solutions and this is pretty much my last resort. I have seen a lot of good answers give here so I figured I...
0
1353
by: krishnasamy | last post by:
Hello, I am writing a DLL for Capturing the Image from Camera Device using Camera SDK DLL. All the calls made to functions in Camera SDK DLL are working properly as I am able to get a return...
0
7002
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...
0
7165
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,...
0
7205
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...
0
7379
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5462
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,...
0
4590
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3093
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1419
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 ...

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.