Response.OutputStream

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default 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

  2. Similar Questions and Discussions

    1. 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...
    2. 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...
    3. 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...
    4. 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...
    5. 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...
  3. #2

    Default 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

  4. #3

    Default 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

  5. #4

    Default 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

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139