473,394 Members | 1,841 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Response.OutputStream

Hi all,

I'm using a second page to write dynamical generated images
into the outputstream. This avoids using tmp-files on disc.

My code-behind in the start aspx file is:

'Use second file to write into outputstream
Application("grafix-obj") = ob
button.ImageUrl = "Grafix.aspx"
Panel.Controls.Add(button)

ob is the bitmap with the image! The file Grafix.aspx
contains only code behind:

Public Class grafix
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

......

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles MyBase.Load

Dim ob As Bitmap = New Bitmap(830, 30)
ob = CType(Application("grafix-obj"), Bitmap)
ob.Save(Response.OutputStream, Imaging.ImageFormat.Jpeg)
End Sub

End Class

I normally expect this to be working! But there is only the
'no image' sign on the imagebutton if I try.
I used the following code before, which worked well:

'Store as tmp file on disk
Dim tempfilepath As String = System.IO.Path.GetTempPath
ob.Save(tempfilepath &"temp.jpg",Imaging.ImageFormat.Jpeg
button.ImageUrl = tempfilepath & "temp.jpg"

What is going wrong?

Thanks for each help
Jenny
Nov 17 '05 #1
3 5056
IN the Image.Save method, save it to a MemoryStream and after write the
memorystream to the response.outputstream of the page.

Dim memstr as new memorystream()
Image.Save(memstr,imageformat.jpeg)
memstr.writeto(response.outputstream)
"Jenny" <j.********@SPAMx-mail.ent> escribió en el mensaje
news:04****************************@phx.gbl...
Hi all,

I'm using a second page to write dynamical generated images
into the outputstream. This avoids using tmp-files on disc.

My code-behind in the start aspx file is:

'Use second file to write into outputstream
Application("grafix-obj") = ob
button.ImageUrl = "Grafix.aspx"
Panel.Controls.Add(button)

ob is the bitmap with the image! The file Grafix.aspx
contains only code behind:

Public Class grafix
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

.....

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles MyBase.Load

Dim ob As Bitmap = New Bitmap(830, 30)
ob = CType(Application("grafix-obj"), Bitmap)
ob.Save(Response.OutputStream, Imaging.ImageFormat.Jpeg)
End Sub

End Class

I normally expect this to be working! But there is only the
'no image' sign on the imagebutton if I try.
I used the following code before, which worked well:

'Store as tmp file on disk
Dim tempfilepath As String = System.IO.Path.GetTempPath
ob.Save(tempfilepath &"temp.jpg",Imaging.ImageFormat.Jpeg
button.ImageUrl = tempfilepath & "temp.jpg"

What is going wrong?

Thanks for each help
Jenny

Nov 17 '05 #2
| Private Sub Page_Load(ByVal sender As System.Object, ByVal
| e As System.EventArgs) Handles MyBase.Load
|
| Dim ob As Bitmap = New Bitmap(830, 30)
| ob = CType(Application("grafix-obj"), Bitmap)
| ob.Save(Response.OutputStream, Imaging.ImageFormat.Jpeg)
| End Sub
|
| End Class
|
| I normally expect this to be working! But there is only the
| 'no image' sign on the imagebutton if I try.

Similar code works well for me, just specify content-type:
Response.ContentType = "image/jpeg".

The following is code I use at http://webcam.rider.cz:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim BMP As Bitmap, GPH As Graphics
Dim RQ As System.Net.HttpWebRequest
Dim RP As System.Net.HttpWebResponse

Response.ContentType = "image/jpeg"
Try
RQ = System.Net.WebRequest.Create("http://epona:8000/" &
Request.UserHostAddress)
RQ.UserAgent = Request.UserAgent
RP = RQ.GetResponse()
BMP = New Bitmap(RP.GetResponseStream())
GPH = System.Drawing.Graphics.FromImage(BMP)
Catch EX As Exception
BMP = BMP.FromFile(Server.MapPath("/_gfx/wc-error.bmp"))
GPH = System.Drawing.Graphics.FromImage(BMP)
GPH.DrawString("The following exception occured:" & vbCrLf &
EX.Message, New Font("Courier New", 10, FontStyle.Bold, GraphicsUnit.Point),
New SolidBrush(Color.White), 5, 400)
End Try
GPH.DrawImage(New Bitmap(Server.MapPath("/_gfx/wc-footer.bmp")), New
RectangleF(0, 460, 640, 20), New RectangleF(0, 0, 640, 20),
GraphicsUnit.Pixel)
GPH.DrawString("www.rider.cz | Prague CZ-EU | " &
Now.ToUniversalTime.ToString("yyyy-MM-dd HH:mm:ss") & " GMT", New
Font("Courier New", 10, FontStyle.Bold, GraphicsUnit.Point), New
SolidBrush(Color.White), 5, 462)
BMP.Save(Response.OutputStream,
System.Drawing.Imaging.ImageFormat.Jpeg)
End Sub

--
Michal A. Valasek, Altair Communications, http://www.altaircom.net
Please do not reply to this e-mail, for contact see http://www.rider.cz
Nov 17 '05 #3
Here is how I did it. I didn't bother with code behind on this one because
there isn't anything other than code. I call the image by setting it's
ImageURL or NavigateURLproperty to
pic.aspx?_p=abc.jpg&_w=123&_h=123&_q=1 (for image, or 2 for thumb)

<%@ Page Language="VB" SmartNavigation="false" Strict="true" %>
<%@ import Namespace="System.Drawing" %>
<%@ import Namespace="System.Drawing.Imaging" %>
<%@ import Namespace="System.Drawing.Drawing2D" %>
<html>

<script language="vb" runat="server">
sub Page_Load(sender as object, e as eventArgs)

dim strPic as string = request.querystring("_p")
dim intWidth as int32 = ctype(request.querystring("_w"),int32)
dim intHeight as int32 = ctype(request.querystring("_h"),int32)
dim intQuality as int32 = ctype(request.querystring("_q"),int32)
dim myNewImage as system.drawing.image
dim strFileLoc as string =
server.mappath(configurationSettings.AppSettings(" picroot"))
try
select case intQuality
case is = 1
if intWidth = 0 then intWidth = 200
if intHeight = 0 then intHeight = 200

mynewimage = mgAdjustBitmap(strFileLoc & strPic, intWidth, intHeight)
case else
if intWidth = 0 then intWidth = 90
if intHeight = 0 then intHeight = 90
mynewimage = mggetthumbnail(strFileLoc & strPic,intWidth,intHeight)

end select
mynewimage.Save(Response.OutputStream, ImageFormat.Jpeg)
catch
mynewimage= mggetthumbnail(strFileLoc & "npicture.jpg",90,90)
mynewimage.Save(Response.OutputStream, ImageFormat.Jpeg)
end try
End Sub

Function mgGetThumbNail(strFile as string, intWidth as integer, intHeight as
integer) as system.drawing.image
Dim myBitmap As bitmap = New Bitmap(strFile)
return mybitmap.getthumbnailimage(intWidth,intHeight,noth ing,nothing)
mybitmap.dispose
End Function

Function mgAdjustBitmap(strFile as string, intHorz as integer, intVert as
integer) as bitmap

Dim mysize as size = new size(inthorz,intVert)
Dim myBitmap As bitmap = New Bitmap(strFile)
dim myImg as bitmap = new bitmap(mybitmap, mysize)
mybitmap.dispose
return myImg
End Function
</script>

</html>
"Jenny" <j.********@SPAMx-mail.ent> wrote in message
news:04****************************@phx.gbl...
Hi all,

I'm using a second page to write dynamical generated images
into the outputstream. This avoids using tmp-files on disc.

My code-behind in the start aspx file is:

'Use second file to write into outputstream
Application("grafix-obj") = ob
button.ImageUrl = "Grafix.aspx"
Panel.Controls.Add(button)

ob is the bitmap with the image! The file Grafix.aspx
contains only code behind:

Public Class grafix
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

.....

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles MyBase.Load

Dim ob As Bitmap = New Bitmap(830, 30)
ob = CType(Application("grafix-obj"), Bitmap)
ob.Save(Response.OutputStream, Imaging.ImageFormat.Jpeg)
End Sub

End Class

I normally expect this to be working! But there is only the
'no image' sign on the imagebutton if I try.
I used the following code before, which worked well:

'Store as tmp file on disk
Dim tempfilepath As String = System.IO.Path.GetTempPath
ob.Save(tempfilepath &"temp.jpg",Imaging.ImageFormat.Jpeg
button.ImageUrl = tempfilepath & "temp.jpg"

What is going wrong?

Thanks for each help
Jenny

Nov 17 '05 #4

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

Similar topics

1
by: Neil Woodvine | last post by:
***Scenario ... I have a DataList with a hyperlink WebControl in the Item Template. I want to display a 64x64 image in the Hyperlink and set the NavigateURL to the full size image. ***Source...
3
by: Zoury | last post by:
Hi folks ! :O) I'm trying to show a PDF in ASP.NET but I can't get to work properly. here's a portion of my code : '** Dim ms As MemoryStream =...
6
by: Joseph | last post by:
Hi! I have this webpage that contains some panels and buttons. I also want to output an Image to that same page, but when I save the image to the OutputStream using the Image.Save...
1
by: Joseff | last post by:
I have this Bitmap object declared and outputted to the browswer this way: invoiceBMP.Save(Response.OutputStream, ImageFormat.Gif); However, the result is that the existing static controls of...
2
by: 1 | last post by:
Hi there, A while back I wrote some code using the .Net drawing libraries... this code takes a datatable and generates a pie or bar chart on the fly. The resulting image is returned using...
0
by: Jared | last post by:
Please note that I posted in the framework.drawing group as well. Hello all, I want to display multipart tiff images in a web browser using the response.outputstream. I know how to do it with...
0
by: Dave | last post by:
Hi, I'm trying to download a pdf from a secure location and writ e the response to the browser as listed below. However, the form that runs this codes appears to postback when I encounter the...
0
by: Chris Ashley | last post by:
I'm writing files directly to Response.OutputStream... setting the headers like so: HttpContext.Current.Response.Buffer = false; HttpContext.Current.Response.Clear();...
3
by: kellygreer1 | last post by:
PHP will alllow you to build up an entire page and before sending that out as the response.... you can grab all the text and do search and replaces, add comments, make more CSS/XHTML compliant,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
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
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
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
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...

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.