Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Using stream without using memory

Using stream without using memory

Scheduled Pinned Locked Moved C#
performancegraphicsquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kensai
    wrote on last edited by
    #1

    I have an aspx page to serve images. Basically it reads image from file using FileStream, creates a Bitmap using Image.FromStream and writes the bitmap to the output using bitmap.Save(Response.OutputStream). The image files are small in size but this page will get a lot of hits so I'm anxious about performance hit. Is there a way to read an image using streams (or any other better way) to the client without using memory like Response.TransmitMemory()?

    S G 2 Replies Last reply
    0
    • K kensai

      I have an aspx page to serve images. Basically it reads image from file using FileStream, creates a Bitmap using Image.FromStream and writes the bitmap to the output using bitmap.Save(Response.OutputStream). The image files are small in size but this page will get a lot of hits so I'm anxious about performance hit. Is there a way to read an image using streams (or any other better way) to the client without using memory like Response.TransmitMemory()?

      S Offline
      S Offline
      Simon P Stevens
      wrote on last edited by
      #2

      No. Everything you do requires memory. The CPU performs operations on stored memory, (usually in registers), not from disk. Without some kind of hardware gizmo you cannot do things without moving the data through memory. Just manage your memory carefully. Ensure that once the image has been sent to the client, it is removed from local memory.

      Simon

      1 Reply Last reply
      0
      • K kensai

        I have an aspx page to serve images. Basically it reads image from file using FileStream, creates a Bitmap using Image.FromStream and writes the bitmap to the output using bitmap.Save(Response.OutputStream). The image files are small in size but this page will get a lot of hits so I'm anxious about performance hit. Is there a way to read an image using streams (or any other better way) to the client without using memory like Response.TransmitMemory()?

        G Offline
        G Offline
        Guffa
        wrote on last edited by
        #3

        Why are you decoding the file into a Bitmap object? Do you change the image in any way before sending it as response? Otherwise just use Response.WriteFile.

        Despite everything, the person most likely to be fooling you next is yourself.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups