How can I draw a picture to a web form dynamically.

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

  1. #1

    Default Re: How can I draw a picture to a web form dynamically.

    you will need something like an image placeholder in your client form. then
    you can load your gif file into that place holder.

    //Add the image into the placeholder.

    string strImageTag = "<IMG SRC='" + strRelativePath + "'/>";

    ChartHolder.Controls.Add(new LiteralControl(strImageTag));

    hth

    "Steve" <horsfall@cmmts.com> wrote in message
    news:09a001c34fa3$923905e0$a501280a@phx.gbl...
    > I would like to programmatically build a picture in memory
    > and the assign it to an image on a web form when the form
    > is loaded. I built the image in memory but could not see a
    > way to assign it to the image. GDI failed when I tried to
    > save it temporarly to the server. Thanks.

    Alvin Bruney Guest

  2. Similar Questions and Discussions

    1. Dynamically Adding Form Fields to CF Flash Form
      I think I know the answer to this but, after some failed Googles, I wanted to double-check here. I have a Flash-based event registration form I'm...
    2. Draw a circle/rectangle dynamically
      I want to draw a rectangle or circle dynamically and fill it with the gradient color. Any examples (codes) ? thanks a lot. Derek
    3. MX : 10.3 "Cannot Draw Picture - Not Enough Memory"
      Have installed fix patch for activation, but FH continues to crash, not open when dblclicked and worst of all, will not re-draw, not enough memory!...
    4. Could not draw picture
      I've got a similar problem. If you've found an answer, please contact me at allisond@si.edu. Thanks! -- Posted via http://dbforums.com
    5. Move around a picture file dynamically in an asp page.
      How to move around a picture file dynamically in an asp page? Any link to sample code will be great. Thanks. *** Sent via Developersdex...
  3. #2

    Default Re: How can I draw a picture to a web form dynamically.

    I still can't figure out how the image I am drawing gets
    into the image on the web form. It seems like you assume I
    already have an image. The real problem here is that the
    bmp.Save(....) method raises a GDI error under a web
    application which works in a windows one. Or it is
    entirely possible that I don't fully understand your
    previous post. If this is the case please give me further
    information to help me understand this. Thanks for your
    trouble.
    >-----Original Message-----
    >you will need something like an image placeholder in your
    client form. then
    >you can load your gif file into that place holder.
    >
    >//Add the image into the placeholder.
    >
    >string strImageTag = "<IMG SRC='" + strRelativePath
    + "'/>";
    >
    >ChartHolder.Controls.Add(new LiteralControl(strImageTag));
    >
    >hth
    >
    >"Steve" <horsfall@cmmts.com> wrote in message
    >news:09a001c34fa3$923905e0$a501280a@phx.gbl...
    >> I would like to programmatically build a picture in
    memory
    >> and the assign it to an image on a web form when the
    form
    >> is loaded. I built the image in memory but could not
    see a
    >> way to assign it to the image. GDI failed when I tried
    to
    >> save it temporarly to the server. Thanks.
    >
    >
    >.
    >
    Steve Guest

  4. #3

    Default Re: How can I draw a picture to a web form dynamically.

    GDI error is because the ASP.Net worker process does not have permission to
    write your image to a file.
    You can stream images to the browser from RAM without the use of files. This
    works in the following way. You have a webpage that includes an image. The
    image path points to another ASP.Net webpage (Image Page). The Image Page
    draws the image in RAM and then streams the final image to the browser. It
    acheives this by doing something like:

    this.Context.Response.Clear();

    this.Context.Response.ContentType="Image/Jpeg";

    MyBitmap.Save(this.Context.Response.OutputStream, ImageFormat.Jpeg);

    this.Context.Response.End();



    This essentially alters the response to a standard ASP.Net webpage and turns
    the response into a streamed image. You still need to draw on your Bitmap
    (obviously)

    Hope this helps,

    Neil


    "Steve" <horsfall@cmmts.com> wrote in message
    news:021401c34fa7$a7199430$a101280a@phx.gbl...
    > I still can't figure out how the image I am drawing gets
    > into the image on the web form. It seems like you assume I
    > already have an image. The real problem here is that the
    > bmp.Save(....) method raises a GDI error under a web
    > application which works in a windows one. Or it is
    > entirely possible that I don't fully understand your
    > previous post. If this is the case please give me further
    > information to help me understand this. Thanks for your
    > trouble.
    >
    > >-----Original Message-----
    > >you will need something like an image placeholder in your
    > client form. then
    > >you can load your gif file into that place holder.
    > >
    > >//Add the image into the placeholder.
    > >
    > >string strImageTag = "<IMG SRC='" + strRelativePath
    > + "'/>";
    > >
    > >ChartHolder.Controls.Add(new LiteralControl(strImageTag));
    > >
    > >hth
    > >
    > >"Steve" <horsfall@cmmts.com> wrote in message
    > >news:09a001c34fa3$923905e0$a501280a@phx.gbl...
    > >> I would like to programmatically build a picture in
    > memory
    > >> and the assign it to an image on a web form when the
    > form
    > >> is loaded. I built the image in memory but could not
    > see a
    > >> way to assign it to the image. GDI failed when I tried
    > to
    > >> save it temporarly to the server. Thanks.
    > >
    > >
    > >.
    > >

    Neil Kimber Guest

  5. #4

    Default Re: How can I draw a picture to a web form dynamically.

    You can use someting I created see below. You set the image src to aspx file
    like
    pic.aspx?imagename.ext?_w=100&_h=100&_q=1 (or 2)

    In the pic.aspx file do something like the following. will need the
    System.Drawing and System.Drawing.Imaging and System.Drawing.Drawing2D
    namespaces. You will have to adjust somethings for you particular situation.

    sub Page_Load(sender as object, e as eventArgs)

    dim strPic as string = request.querystring("_p")
    dim intWidth as integer = request.querystring("_w")
    dim intHeight as integer = request.querystring("_h")
    dim intQuality as integer = request.querystring("_q")
    dim myNewImage as system.drawing.image
    dim strFileLoc as string = "your path to your pictures"


    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)
    return myImg
    mybitmap.dispose
    End Function
    "Steve" <horsfall@cmmts.com> wrote in message
    news:09a001c34fa3$923905e0$a501280a@phx.gbl...
    > I would like to programmatically build a picture in memory
    > and the assign it to an image on a web form when the form
    > is loaded. I built the image in memory but could not see a
    > way to assign it to the image. GDI failed when I tried to
    > save it temporarly to the server. Thanks.

    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