Displaying Images ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Vinay

    #1

    Displaying Images ?

    Hi All:

    I have a small application that stores images either in the database or as
    files (depending on the user preference). I'm in the process of providing a
    web interface to this application.

    1. If the images are stored in the DB then, every an image is requested, it
    will need to be pulled out and a temp file created and then displayed? What
    is the best way to do this?

    2. If the images are stored as files, how do I ensure security? For example
    if I store all the images in a folder called \database\image s and that has a
    file 3.tif or 3.jpg, how do I ensure that people dont point their browsers
    to http://mysite/database/images/3.jpg ?

    Any pointers would be very helpful :)

    TIA

    Vinay
    vinay_hs@nospam .yahoo.com.nospam


  • William Ryan

    #2
    Re: Displaying Images ?



    If you store them as Binary, then they'd have to query your database to hit
    the images and extract data from the stream. I think the above article
    should help you, but just check for BLOB and ADO.NEt on Google, there's tons
    of examples

    "Vinay" <vinay_hs_nospa m@nospam.yahoo. com> wrote in message
    news:OrikdrkmDH A.2592@TK2MSFTN GP10.phx.gbl...[color=blue]
    > Hi All:
    >
    > I have a small application that stores images either in the database or as
    > files (depending on the user preference). I'm in the process of providing[/color]
    a[color=blue]
    > web interface to this application.
    >
    > 1. If the images are stored in the DB then, every an image is requested,[/color]
    it[color=blue]
    > will need to be pulled out and a temp file created and then displayed?[/color]
    What[color=blue]
    > is the best way to do this?
    >
    > 2. If the images are stored as files, how do I ensure security? For[/color]
    example[color=blue]
    > if I store all the images in a folder called \database\image s and that has[/color]
    a[color=blue]
    > file 3.tif or 3.jpg, how do I ensure that people dont point their browsers
    > to http://mysite/database/images/3.jpg ?
    >
    > Any pointers would be very helpful :)
    >
    > TIA
    >
    > Vinay
    > vinay_hs@nospam .yahoo.com.nospam
    >
    >[/color]


    Comment

    • Vinay

      #3
      Re: Displaying Images ?

      Thanks for the lead.
      However if I want to save the images as files, do you have any pointers on
      how I can ensure that users will not be able to point their browsers to
      http://mysite/imagestore/imagename and have the image come up on the
      browser?

      Vinay

      "Vinay" <vinay_hs_nospa m@nospam.yahoo. com> wrote in message
      news:OrikdrkmDH A.2592@TK2MSFTN GP10.phx.gbl...[color=blue]
      > Hi All:
      >
      > I have a small application that stores images either in the database or as
      > files (depending on the user preference). I'm in the process of providing[/color]
      a[color=blue]
      > web interface to this application.
      >
      > 1. If the images are stored in the DB then, every an image is requested,[/color]
      it[color=blue]
      > will need to be pulled out and a temp file created and then displayed?[/color]
      What[color=blue]
      > is the best way to do this?
      >
      > 2. If the images are stored as files, how do I ensure security? For[/color]
      example[color=blue]
      > if I store all the images in a folder called \database\image s and that has[/color]
      a[color=blue]
      > file 3.tif or 3.jpg, how do I ensure that people dont point their browsers
      > to http://mysite/database/images/3.jpg ?
      >
      > Any pointers would be very helpful :)
      >
      > TIA
      >
      > Vinay
      > vinay_hs@nospam .yahoo.com.nospam
      >
      >[/color]


      Comment

      • vMike

        #4
        Re: Displaying Images ?

        You could have your src=yourpicture routine.aspx and have your aspx file do

        Response.Conten tType = "image/jpeg"
        mynewimage.Save (Response.Outpu tStream, ImageFormat.Jpe g)

        Where mynewimage is a system.drawing. image from file. You could mask the
        file name or put the pictures in a non-www directory and do something like
        mynewimage=mgGe tThumbNail(...)

        Function mgGetThumbNail( strFile as string, intWidth as integer, intHeight as
        integer) as system.drawing. image
        Dim myBitmap As bitmap = New Bitmap(strFile)
        return mybitmap.getthu mbnailimage(int Width,intHeight ,nothing,nothin g)
        End Function

        Someone can still right click the picture and save the thumbnail. But they
        won't be able to get the actual image file. If you want to keep a higher
        quality but smaller size you can use something like this.

        Function mgAdjustBitmap( strFile as string, intHorz as integer, intVert as
        integer) as bitmap
        Dim mysize as size = new size(inthorz,in tVert)
        Dim myBitmap As bitmap = New Bitmap(strFile)
        myBitmap = new bitmap(mybitmap ,mysize)
        return myBitmap 'myImg
        End Function


        Finally, once you have the image you can add text to the graphic using
        something like this (snip)

        dim objGraphic as Graphics = Graphics.FromIm age(objBitmap)
        objGraphic.Draw String(strText, New Font("Tahoma",i ntFontSize),New
        SolidBrush(sysC olor),intHorzPo s, intVertPos)
        return objBitMap

        Hope this helps.
        I have heard that some people put clear transparent images over the page
        images so someone can't right click it but that seems to be a bit extreme.

        Hope this helps in some way.

        "Vinay" <vinay_hs_nospa m@nospam.yahoo. com> wrote in message
        news:OrikdrkmDH A.2592@TK2MSFTN GP10.phx.gbl...[color=blue]
        > Hi All:
        >
        > I have a small application that stores images either in the database or as
        > files (depending on the user preference). I'm in the process of providing[/color]
        a[color=blue]
        > web interface to this application.
        >
        > 1. If the images are stored in the DB then, every an image is requested,[/color]
        it[color=blue]
        > will need to be pulled out and a temp file created and then displayed?[/color]
        What[color=blue]
        > is the best way to do this?
        >
        > 2. If the images are stored as files, how do I ensure security? For[/color]
        example[color=blue]
        > if I store all the images in a folder called \database\image s and that has[/color]
        a[color=blue]
        > file 3.tif or 3.jpg, how do I ensure that people dont point their browsers
        > to http://mysite/database/images/3.jpg ?
        >
        > Any pointers would be very helpful :)
        >
        > TIA
        >
        > Vinay
        > vinay_hs@nospam .yahoo.com.nospam
        >
        >[/color]


        Comment

        • Vinay

          #5
          Re: Displaying Images ?

          Thanks for the pointers Mike.
          At the risk of sounding daft...what do you mean by?
          [color=blue]
          > You could have your src=yourpicture routine.aspx and have your aspx file do[/color]

          Here's what I am trying to do:
          I have an aspx page that has a list box, that has lets say 3 entries. When
          the user clicks on each entry I want to show the corresponding image. These
          images could be big tif files or jpg files. I want to show these images in a
          new window. I've not worked a great deal with this before..hence the
          confusion on my part.

          Thanks!

          Vinay


          [color=blue]
          > Response.Conten tType = "image/jpeg"
          > mynewimage.Save (Response.Outpu tStream, ImageFormat.Jpe g)
          >
          > Where mynewimage is a system.drawing. image from file. You could mask the
          > file name or put the pictures in a non-www directory and do something like
          > mynewimage=mgGe tThumbNail(...)
          >
          > Function mgGetThumbNail( strFile as string, intWidth as integer, intHeight[/color]
          as[color=blue]
          > integer) as system.drawing. image
          > Dim myBitmap As bitmap = New Bitmap(strFile)
          > return mybitmap.getthu mbnailimage(int Width,intHeight ,nothing,nothin g)
          > End Function
          >
          > Someone can still right click the picture and save the thumbnail. But[/color]
          they[color=blue]
          > won't be able to get the actual image file. If you want to keep a higher
          > quality but smaller size you can use something like this.
          >
          > Function mgAdjustBitmap( strFile as string, intHorz as integer, intVert as
          > integer) as bitmap
          > Dim mysize as size = new size(inthorz,in tVert)
          > Dim myBitmap As bitmap = New Bitmap(strFile)
          > myBitmap = new bitmap(mybitmap ,mysize)
          > return myBitmap 'myImg
          > End Function
          >
          >
          > Finally, once you have the image you can add text to the graphic using
          > something like this (snip)
          >
          > dim objGraphic as Graphics = Graphics.FromIm age(objBitmap)
          > objGraphic.Draw String(strText, New Font("Tahoma",i ntFontSize),New
          > SolidBrush(sysC olor),intHorzPo s, intVertPos)
          > return objBitMap
          >
          > Hope this helps.
          > I have heard that some people put clear transparent images over the page
          > images so someone can't right click it but that seems to be a bit extreme.
          >
          > Hope this helps in some way.
          >
          > "Vinay" <vinay_hs_nospa m@nospam.yahoo. com> wrote in message
          > news:OrikdrkmDH A.2592@TK2MSFTN GP10.phx.gbl...[color=green]
          > > Hi All:
          > >
          > > I have a small application that stores images either in the database or[/color][/color]
          as[color=blue][color=green]
          > > files (depending on the user preference). I'm in the process of[/color][/color]
          providing[color=blue]
          > a[color=green]
          > > web interface to this application.
          > >
          > > 1. If the images are stored in the DB then, every an image is requested,[/color]
          > it[color=green]
          > > will need to be pulled out and a temp file created and then displayed?[/color]
          > What[color=green]
          > > is the best way to do this?
          > >
          > > 2. If the images are stored as files, how do I ensure security? For[/color]
          > example[color=green]
          > > if I store all the images in a folder called \database\image s and that[/color][/color]
          has[color=blue]
          > a[color=green]
          > > file 3.tif or 3.jpg, how do I ensure that people dont point their[/color][/color]
          browsers[color=blue][color=green]
          > > to http://mysite/database/images/3.jpg ?
          > >
          > > Any pointers would be very helpful :)
          > >
          > > TIA
          > >
          > > Vinay
          > > vinay_hs@nospam .yahoo.com.nospam
          > >
          > >[/color]
          >
          >[/color]


          Comment

          • vMike

            #6
            Re: Displaying Images ?

            I thought you where referring to images on the page. If you want images in a
            new window you probably want to do a response.redire ct in the onclick event
            of the listbox. In that case you would not use the src= . That would only be
            used for images on the page. If you're openning a new window then your image
            is probably larger and higher quality. In that case, someone can just right
            click it and save it to their disk. I don't think there is much you can do
            about that. If you have a really high quality picture you can downgrade it
            using an aspx file that calls up the image and then makes it a thumbnail or
            smaller image using the info in my last post. You can also you a mask in
            your code so that the user does not know the actual file name of the image
            so they can't go back and try to get the base image. Hope this helps. There
            was a site that had some other ideas, I will try to find it and post a link
            when I get the chance.
            Here is some code I use for some of my pictures. This codes does not mask
            the file name but you could easily add it. Also if some of you file are tiff
            then you would need to build that into the content type. I snipped this so
            hopefully I got all the pieces.

            sub Page_Load(sende r as object, e as eventArgs)

            dim strPic as string = request.queryst ring("_p")
            dim strDesigner as string = request.queryst ring("_d") & ""
            dim intWidth as int32 = ctype(request.q uerystring("_w" ),int32)
            dim intHeight as int32 = ctype(request.q uerystring("_h" ),int32)
            dim intQuality as int32 = ctype(request.q uerystring("_q" ),int32)
            dim myNewImage as system.drawing. image
            dim intCacheTime as int32 = ctype(request.q uerystring("_c" ),int32)
            if intCacheTime > 3600 then intCacheTime = 3600

            dim strFileLoc as string =
            server.mappath( configurationSe ttings.AppSetti ngs("picroot"))
            Response.Conten tType = "image/jpeg"
            if intCacheTime > 0 then
            Response.Cache. SetExpires(Date Time.Now.AddSec onds(intCacheTi me))
            Response.Cache. SetCacheability (HttpCacheabili ty.Public)
            Response.Cache. SetValidUntilEx pires(True)
            Response.Cache. VaryByParams("_ p") = True
            Response.Cache. VaryByParams("_ h") = True
            Response.Cache. VaryByParams("_ c") = True
            end if


            try
            select case intQuality
            case is = 1
            Dim bFlag as boolean = false
            if intWidth = 0 then intWidth = 200
            if intHeight = 0 then intHeight = 200
            if strDesigner.len gth > 0 then bFlag = true
            mynewimage = mgAdjustBitmap( strFileLoc & strPic, intWidth,
            intHeight,bFlag ,strDesigner)
            case is = 2
            if intWidth = 0 then intWidth = 90
            if intHeight = 0 then intHeight = 90
            mynewimage = mggetthumbnail( strFileLoc & strPic,intWidth ,intHeight)
            case is = 3
            if intWidth = 0 then intWidth = 90
            if intHeight = 0 then intHeight = 90
            mynewimage = mggetthumbnail( strFileLoc & strPic,intWidth ,intHeight)
            dim strSaveLoc as string =
            server.mappath( configurationSe ttings.AppSetti ngs("thumbroot" ))
            mynewimage.save (strSaveLoc & strpic,ImageFor mat.Jpeg)
            case is = 4
            if intWidth = 0 then intWidth = 90
            if intHeight = 0 then intHeight = 90
            mynewimage = mggetthumbnail( strFileLoc & strPic,intWidth ,intHeight)
            dim strSaveLoc as string =
            server.mappath( configurationSe ttings.AppSetti ngs("thumbroot" ))
            mynewimage.save (strSaveLoc & strpic,ImageFor mat.Jpeg)
            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.Outpu tStream, ImageFormat.Jpe g)
            mynewimage.disp ose
            catch
            mynewimage= mggetthumbnail( strFileLoc & "npicture.jpg", 240,180)

            mynewimage.Save (Response.Outpu tStream, ImageFormat.Jpe g)
            mynewimage.disp ose
            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.getthu mbnailimage(int Width,intHeight ,nothing,nothin g)
            End Function

            Function mgAdjustBitmap( strFile as string, intHorz as integer, intVert as
            integer,bDrawTe xtFlag as boolean, strText as string) as bitmap

            Dim mysize as size = new size(inthorz,in tVert)
            Dim myBitmap As bitmap = New Bitmap(strFile)
            myBitmap = new bitmap(mybitmap ,mysize)
            if bDrawTextFlag then
            myBitmap = mgDrawText(myBi tmap, strText, 8,
            color.blue,ctyp e(intHorz*.05,i nt32),ctype(int Vert * .92,int32))
            end if


            return myBitmap
            End Function

            Function mgDrawText(objB itmap as bitmap, strText as string, intFontSize as
            int32, sysColor as color, intHorzPos as int32, intVertPos as int32) as
            bitmap
            dim objGraphic as Graphics = Graphics.FromIm age(objBitmap)
            objGraphic.Draw String(strText, New Font("Tahoma",i ntFontSize),New
            SolidBrush(sysC olor),intHorzPo s, intVertPos)
            return objBitMap
            End Function



            "Vinay" <vinay_hs_nospa m@nospam.yahoo. com> wrote in message
            news:%23DVdo%23 lmDHA.2528@TK2M SFTNGP10.phx.gb l...[color=blue]
            > Thanks for the pointers Mike.
            > At the risk of sounding daft...what do you mean by?
            >[color=green]
            > > You could have your src=yourpicture routine.aspx and have your aspx file[/color][/color]
            do[color=blue]
            >
            > Here's what I am trying to do:
            > I have an aspx page that has a list box, that has lets say 3 entries. When
            > the user clicks on each entry I want to show the corresponding image.[/color]
            These[color=blue]
            > images could be big tif files or jpg files. I want to show these images in[/color]
            a[color=blue]
            > new window. I've not worked a great deal with this before..hence the
            > confusion on my part.
            >
            > Thanks!
            >
            > Vinay
            >
            >
            >[color=green]
            > > Response.Conten tType = "image/jpeg"
            > > mynewimage.Save (Response.Outpu tStream, ImageFormat.Jpe g)
            > >
            > > Where mynewimage is a system.drawing. image from file. You could mask the
            > > file name or put the pictures in a non-www directory and do something[/color][/color]
            like[color=blue][color=green]
            > > mynewimage=mgGe tThumbNail(...)
            > >
            > > Function mgGetThumbNail( strFile as string, intWidth as integer,[/color][/color]
            intHeight[color=blue]
            > as[color=green]
            > > integer) as system.drawing. image
            > > Dim myBitmap As bitmap = New Bitmap(strFile)
            > > return mybitmap.getthu mbnailimage(int Width,intHeight ,nothing,nothin g)
            > > End Function
            > >
            > > Someone can still right click the picture and save the thumbnail. But[/color]
            > they[color=green]
            > > won't be able to get the actual image file. If you want to keep a higher
            > > quality but smaller size you can use something like this.
            > >
            > > Function mgAdjustBitmap( strFile as string, intHorz as integer, intVert[/color][/color]
            as[color=blue][color=green]
            > > integer) as bitmap
            > > Dim mysize as size = new size(inthorz,in tVert)
            > > Dim myBitmap As bitmap = New Bitmap(strFile)
            > > myBitmap = new bitmap(mybitmap ,mysize)
            > > return myBitmap 'myImg
            > > End Function
            > >
            > >
            > > Finally, once you have the image you can add text to the graphic using
            > > something like this (snip)
            > >
            > > dim objGraphic as Graphics = Graphics.FromIm age(objBitmap)
            > > objGraphic.Draw String(strText, New Font("Tahoma",i ntFontSize),New
            > > SolidBrush(sysC olor),intHorzPo s, intVertPos)
            > > return objBitMap
            > >
            > > Hope this helps.
            > > I have heard that some people put clear transparent images over the page
            > > images so someone can't right click it but that seems to be a bit[/color][/color]
            extreme.[color=blue][color=green]
            > >
            > > Hope this helps in some way.
            > >
            > > "Vinay" <vinay_hs_nospa m@nospam.yahoo. com> wrote in message
            > > news:OrikdrkmDH A.2592@TK2MSFTN GP10.phx.gbl...[color=darkred]
            > > > Hi All:
            > > >
            > > > I have a small application that stores images either in the database[/color][/color][/color]
            or[color=blue]
            > as[color=green][color=darkred]
            > > > files (depending on the user preference). I'm in the process of[/color][/color]
            > providing[color=green]
            > > a[color=darkred]
            > > > web interface to this application.
            > > >
            > > > 1. If the images are stored in the DB then, every an image is[/color][/color][/color]
            requested,[color=blue][color=green]
            > > it[color=darkred]
            > > > will need to be pulled out and a temp file created and then displayed?[/color]
            > > What[color=darkred]
            > > > is the best way to do this?
            > > >
            > > > 2. If the images are stored as files, how do I ensure security? For[/color]
            > > example[color=darkred]
            > > > if I store all the images in a folder called \database\image s and that[/color][/color]
            > has[color=green]
            > > a[color=darkred]
            > > > file 3.tif or 3.jpg, how do I ensure that people dont point their[/color][/color]
            > browsers[color=green][color=darkred]
            > > > to http://mysite/database/images/3.jpg ?
            > > >
            > > > Any pointers would be very helpful :)
            > > >
            > > > TIA
            > > >
            > > > Vinay
            > > > vinay_hs@nospam .yahoo.com.nospam
            > > >
            > > >[/color]
            > >
            > >[/color]
            >
            >[/color]


            Comment

            • Vinay

              #7
              Re: Displaying Images ?

              Mike:

              Thanks - the code will certainly help me understand how I can go about
              trying to do what I need to do. Appreciate you taking the time to help :)

              Vinay

              "vMike" <Michael.George @nospam.gewarre n.com.delete> wrote in message
              news:bnc34h$sis $1@ngspool-d02.news.aol.co m...[color=blue]
              > I thought you where referring to images on the page. If you want images in[/color]
              a[color=blue]
              > new window you probably want to do a response.redire ct in the onclick[/color]
              event[color=blue]
              > of the listbox. In that case you would not use the src= . That would only[/color]
              be[color=blue]
              > used for images on the page. If you're openning a new window then your[/color]
              image[color=blue]
              > is probably larger and higher quality. In that case, someone can just[/color]
              right[color=blue]
              > click it and save it to their disk. I don't think there is much you can do
              > about that. If you have a really high quality picture you can downgrade it
              > using an aspx file that calls up the image and then makes it a thumbnail[/color]
              or[color=blue]
              > smaller image using the info in my last post. You can also you a mask in
              > your code so that the user does not know the actual file name of the image
              > so they can't go back and try to get the base image. Hope this helps.[/color]
              There[color=blue]
              > was a site that had some other ideas, I will try to find it and post a[/color]
              link[color=blue]
              > when I get the chance.
              > Here is some code I use for some of my pictures. This codes does not mask
              > the file name but you could easily add it. Also if some of you file are[/color]
              tiff[color=blue]
              > then you would need to build that into the content type. I snipped this so
              > hopefully I got all the pieces.
              >
              > sub Page_Load(sende r as object, e as eventArgs)
              >
              > dim strPic as string = request.queryst ring("_p")
              > dim strDesigner as string = request.queryst ring("_d") & ""
              > dim intWidth as int32 = ctype(request.q uerystring("_w" ),int32)
              > dim intHeight as int32 = ctype(request.q uerystring("_h" ),int32)
              > dim intQuality as int32 = ctype(request.q uerystring("_q" ),int32)
              > dim myNewImage as system.drawing. image
              > dim intCacheTime as int32 = ctype(request.q uerystring("_c" ),int32)
              > if intCacheTime > 3600 then intCacheTime = 3600
              >
              > dim strFileLoc as string =
              > server.mappath( configurationSe ttings.AppSetti ngs("picroot"))
              > Response.Conten tType = "image/jpeg"
              > if intCacheTime > 0 then
              > Response.Cache. SetExpires(Date Time.Now.AddSec onds(intCacheTi me))
              > Response.Cache. SetCacheability (HttpCacheabili ty.Public)
              > Response.Cache. SetValidUntilEx pires(True)
              > Response.Cache. VaryByParams("_ p") = True
              > Response.Cache. VaryByParams("_ h") = True
              > Response.Cache. VaryByParams("_ c") = True
              > end if
              >
              >
              > try
              > select case intQuality
              > case is = 1
              > Dim bFlag as boolean = false
              > if intWidth = 0 then intWidth = 200
              > if intHeight = 0 then intHeight = 200
              > if strDesigner.len gth > 0 then bFlag = true
              > mynewimage = mgAdjustBitmap( strFileLoc & strPic, intWidth,
              > intHeight,bFlag ,strDesigner)
              > case is = 2
              > if intWidth = 0 then intWidth = 90
              > if intHeight = 0 then intHeight = 90
              > mynewimage = mggetthumbnail( strFileLoc & strPic,intWidth ,intHeight)
              > case is = 3
              > if intWidth = 0 then intWidth = 90
              > if intHeight = 0 then intHeight = 90
              > mynewimage = mggetthumbnail( strFileLoc & strPic,intWidth ,intHeight)
              > dim strSaveLoc as string =
              > server.mappath( configurationSe ttings.AppSetti ngs("thumbroot" ))
              > mynewimage.save (strSaveLoc & strpic,ImageFor mat.Jpeg)
              > case is = 4
              > if intWidth = 0 then intWidth = 90
              > if intHeight = 0 then intHeight = 90
              > mynewimage = mggetthumbnail( strFileLoc & strPic,intWidth ,intHeight)
              > dim strSaveLoc as string =
              > server.mappath( configurationSe ttings.AppSetti ngs("thumbroot" ))
              > mynewimage.save (strSaveLoc & strpic,ImageFor mat.Jpeg)
              > 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.Outpu tStream, ImageFormat.Jpe g)
              > mynewimage.disp ose
              > catch
              > mynewimage= mggetthumbnail( strFileLoc & "npicture.jpg", 240,180)
              >
              > mynewimage.Save (Response.Outpu tStream, ImageFormat.Jpe g)
              > mynewimage.disp ose
              > end try
              > End Sub
              >
              > Function mgGetThumbNail( strFile as string, intWidth as integer, intHeight[/color]
              as[color=blue]
              > integer) as system.drawing. image
              > Dim myBitmap As bitmap = New Bitmap(strFile)
              > return mybitmap.getthu mbnailimage(int Width,intHeight ,nothing,nothin g)
              > End Function
              >
              > Function mgAdjustBitmap( strFile as string, intHorz as integer, intVert as
              > integer,bDrawTe xtFlag as boolean, strText as string) as bitmap
              >
              > Dim mysize as size = new size(inthorz,in tVert)
              > Dim myBitmap As bitmap = New Bitmap(strFile)
              > myBitmap = new bitmap(mybitmap ,mysize)
              > if bDrawTextFlag then
              > myBitmap = mgDrawText(myBi tmap, strText, 8,
              > color.blue,ctyp e(intHorz*.05,i nt32),ctype(int Vert * .92,int32))
              > end if
              >
              >
              > return myBitmap
              > End Function
              >
              > Function mgDrawText(objB itmap as bitmap, strText as string, intFontSize as
              > int32, sysColor as color, intHorzPos as int32, intVertPos as int32) as
              > bitmap
              > dim objGraphic as Graphics = Graphics.FromIm age(objBitmap)
              > objGraphic.Draw String(strText, New Font("Tahoma",i ntFontSize),New
              > SolidBrush(sysC olor),intHorzPo s, intVertPos)
              > return objBitMap
              > End Function
              >
              >
              >
              > "Vinay" <vinay_hs_nospa m@nospam.yahoo. com> wrote in message
              > news:%23DVdo%23 lmDHA.2528@TK2M SFTNGP10.phx.gb l...[color=green]
              > > Thanks for the pointers Mike.
              > > At the risk of sounding daft...what do you mean by?
              > >[color=darkred]
              > > > You could have your src=yourpicture routine.aspx and have your aspx[/color][/color][/color]
              file[color=blue]
              > do[color=green]
              > >
              > > Here's what I am trying to do:
              > > I have an aspx page that has a list box, that has lets say 3 entries.[/color][/color]
              When[color=blue][color=green]
              > > the user clicks on each entry I want to show the corresponding image.[/color]
              > These[color=green]
              > > images could be big tif files or jpg files. I want to show these images[/color][/color]
              in[color=blue]
              > a[color=green]
              > > new window. I've not worked a great deal with this before..hence the
              > > confusion on my part.
              > >
              > > Thanks!
              > >
              > > Vinay
              > >
              > >
              > >[color=darkred]
              > > > Response.Conten tType = "image/jpeg"
              > > > mynewimage.Save (Response.Outpu tStream, ImageFormat.Jpe g)
              > > >
              > > > Where mynewimage is a system.drawing. image from file. You could mask[/color][/color][/color]
              the[color=blue][color=green][color=darkred]
              > > > file name or put the pictures in a non-www directory and do something[/color][/color]
              > like[color=green][color=darkred]
              > > > mynewimage=mgGe tThumbNail(...)
              > > >
              > > > Function mgGetThumbNail( strFile as string, intWidth as integer,[/color][/color]
              > intHeight[color=green]
              > > as[color=darkred]
              > > > integer) as system.drawing. image
              > > > Dim myBitmap As bitmap = New Bitmap(strFile)
              > > > return mybitmap.getthu mbnailimage(int Width,intHeight ,nothing,nothin g)
              > > > End Function
              > > >
              > > > Someone can still right click the picture and save the thumbnail. But[/color]
              > > they[color=darkred]
              > > > won't be able to get the actual image file. If you want to keep a[/color][/color][/color]
              higher[color=blue][color=green][color=darkred]
              > > > quality but smaller size you can use something like this.
              > > >
              > > > Function mgAdjustBitmap( strFile as string, intHorz as integer, intVert[/color][/color]
              > as[color=green][color=darkred]
              > > > integer) as bitmap
              > > > Dim mysize as size = new size(inthorz,in tVert)
              > > > Dim myBitmap As bitmap = New Bitmap(strFile)
              > > > myBitmap = new bitmap(mybitmap ,mysize)
              > > > return myBitmap 'myImg
              > > > End Function
              > > >
              > > >
              > > > Finally, once you have the image you can add text to the graphic using
              > > > something like this (snip)
              > > >
              > > > dim objGraphic as Graphics = Graphics.FromIm age(objBitmap)
              > > > objGraphic.Draw String(strText, New Font("Tahoma",i ntFontSize),New
              > > > SolidBrush(sysC olor),intHorzPo s, intVertPos)
              > > > return objBitMap
              > > >
              > > > Hope this helps.
              > > > I have heard that some people put clear transparent images over the[/color][/color][/color]
              page[color=blue][color=green][color=darkred]
              > > > images so someone can't right click it but that seems to be a bit[/color][/color]
              > extreme.[color=green][color=darkred]
              > > >
              > > > Hope this helps in some way.
              > > >
              > > > "Vinay" <vinay_hs_nospa m@nospam.yahoo. com> wrote in message
              > > > news:OrikdrkmDH A.2592@TK2MSFTN GP10.phx.gbl...
              > > > > Hi All:
              > > > >
              > > > > I have a small application that stores images either in the database[/color][/color]
              > or[color=green]
              > > as[color=darkred]
              > > > > files (depending on the user preference). I'm in the process of[/color]
              > > providing[color=darkred]
              > > > a
              > > > > web interface to this application.
              > > > >
              > > > > 1. If the images are stored in the DB then, every an image is[/color][/color]
              > requested,[color=green][color=darkred]
              > > > it
              > > > > will need to be pulled out and a temp file created and then[/color][/color][/color]
              displayed?[color=blue][color=green][color=darkred]
              > > > What
              > > > > is the best way to do this?
              > > > >
              > > > > 2. If the images are stored as files, how do I ensure security? For
              > > > example
              > > > > if I store all the images in a folder called \database\image s and[/color][/color][/color]
              that[color=blue][color=green]
              > > has[color=darkred]
              > > > a
              > > > > file 3.tif or 3.jpg, how do I ensure that people dont point their[/color]
              > > browsers[color=darkred]
              > > > > to http://mysite/database/images/3.jpg ?
              > > > >
              > > > > Any pointers would be very helpful :)
              > > > >
              > > > > TIA
              > > > >
              > > > > Vinay
              > > > > vinay_hs@nospam .yahoo.com.nospam
              > > > >
              > > > >
              > > >
              > > >[/color]
              > >
              > >[/color]
              >
              >[/color]


              Comment

              • vMike

                #8
                Re: Displaying Images ?

                Here a link to a site that has some other idea.

                http://www.htmlite.com/faq010.php

                "Vinay" <vinay_hs_nospa m@nospam.yahoo. com> wrote in message
                news:OrikdrkmDH A.2592@TK2MSFTN GP10.phx.gbl...[color=blue]
                > Hi All:
                >
                > I have a small application that stores images either in the database or as
                > files (depending on the user preference). I'm in the process of providing[/color]
                a[color=blue]
                > web interface to this application.
                >
                > 1. If the images are stored in the DB then, every an image is requested,[/color]
                it[color=blue]
                > will need to be pulled out and a temp file created and then displayed?[/color]
                What[color=blue]
                > is the best way to do this?
                >
                > 2. If the images are stored as files, how do I ensure security? For[/color]
                example[color=blue]
                > if I store all the images in a folder called \database\image s and that has[/color]
                a[color=blue]
                > file 3.tif or 3.jpg, how do I ensure that people dont point their browsers
                > to http://mysite/database/images/3.jpg ?
                >
                > Any pointers would be very helpful :)
                >
                > TIA
                >
                > Vinay
                > vinay_hs@nospam .yahoo.com.nospam
                >
                >[/color]


                Comment

                Working...