Ask a Question related to ASP.NET General, Design and Development.
-
Jenny #1
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
Jenny Guest
-
Slow login response response on TS 03 in AD mixed mode
We upgraded our NT 4 domain to an AD mixed until we get rid of the NT 4 BDC;s after completing this upgrade users began complaining about how long... -
Response.Flush / Response.Redirect
Hi, I've had a good google and can't find anything already on this so : I'm currently trying to have a 'Page Loading' page on a site. The way... -
AW7 vs. DirectorMX for psychology experiment using response times AND response answers
Hello, I'm very new to application design, but need to develop a web based application to use at multiple schools as part of an experimental... -
Response.Write and Response.Redirect
On my Page_Load event, i need to do some validation and then either let them proceed, or display a error message and boot them back to the previous... -
extended ascii delimiters when when writing to outputstream
Whenever I write to Response.Outputstream after doing a plain response.write, I get a delimiter between the two writes that is made up of three... -
Roberto López #2
Re: Response.OutputStream
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.malloyNO@SPAMx-mail.ent> escribió en el mensaje
news:04a201c35a5c$fd21fce0$a401280a@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
Roberto López Guest
-
Michal A. Valasek #3
Re: Response.OutputStream
| 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 [url]http://webcam.rider.cz:[/url]
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, [url]http://www.altaircom.net[/url]
Please do not reply to this e-mail, for contact see [url]http://www.rider.cz[/url]
Michal A. Valasek Guest
-
vMike #4
Re: Response.OutputStream
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.malloyNO@SPAMx-mail.ent> wrote in message
news:04a201c35a5c$fd21fce0$a401280a@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
vMike Guest



Reply With Quote

