Last post Jun 20, 2018 01:05 PM by PatriceSc
Jun 20, 2018 07:19 AM|dileep Sanker|LINK
I have asp.net application. In my application , trying to write a bitmap image text into memorystream. But it is writing the text very slowly. How can I improve the performance.The below line of code used for ,
for(int k=0; k<25;
System.Drawing.Bitmap bmpMap =
using (System.IO.MemoryStream stream =
stream.WriteTo(Response.OutputStream);// If I commentout it is loading fast
The above block of code, if I have commented out the stream.WriteTo(Response.OutputStream) , then it is loading very fast. How we can write the bitmap image text to memorystream very fastly
Jun 20, 2018 07:29 AM|PatriceSc|LINK
It is when sending to the browser so the network is likely the llimit here. What is the size of your image ? It seems to be in a loop which is weird or the loop is done before to process images ???
Jun 20, 2018 09:25 AM|dileep Sanker|LINK
BMP height and width is 75px. Every time my image text will change, thts why put the logic inside loop.
Jun 20, 2018 09:36 AM|PatriceSc|LINK
75x75 seems fine. What is the actual size in KB ? This is a multi frame GIF ?
I still don't see the purpose of this loop as you should send back a single image file ? I suspect that for now it's rather some kind of logic programming issue that might cause maybe exceptions and slow down your code rather than really a problem with raw
Jun 20, 2018 10:06 AM|dileep Sanker|LINK
why we are using loop is , we are using 20 different image text, not the same on every time. bmp image sixe text is less than a kb.
Jun 20, 2018 11:23 AM|PatriceSc|LINK
I still don't get it. For now it seems you have your response block inside a loop which doesn't seems something that should work moreover with Response.End(); When an http query is done you are usually expected to send back a single response. Sending less
than a Kb to a browser shouldn't be a problem.
I suspect the problem is not where you think. Either it is actually bigger than what you think or the loop is causing issues (working the first time and generating excepting for the other iterations).
What if you try for(int
k=0; k<1; k++) // Typo on K++ ?
You are sending back multiple images and expect to see them in close succession in the page that asked for them ??? If this is an animation you should rather write each frame to the same animated
gif file and then send back this file.
Jun 20, 2018 12:53 PM|dileep Sanker|LINK
This is not related with a size or loop iteration problem. I am able to write image text suceesfuly , but is very slowly one by one.
The line of code stream.WriteTo(Response.OutputStream); only taking time for each iteration. and supposed to comment out this line code, then no time delay , but no text is writing.
it is typo error in previous post, now the loop changed to
(int k=0; k<10; k++)
You are sending back multiple images and expect to see them in close succession in the page that asked for them ??? YES
There is no animation is used in the gif image.
sending multiple images thorough the loop.
Jun 20, 2018 01:05 PM|PatriceSc|LINK
I don't see how it could work. You are expected to send a single response for each http request and it seems you are calling Response.End() inside this loop. If you want to show an animation you should send a single gif image with multiple frames rather
than trying to send multiple images in close succession (or request each image in turn from the client side).
I suspect that an exception happens for all expect the first iteration and that the time you see is spent in processing those exceptions rather than in sending actual content. Have you tried to check the Windows application log to see if exception messages
are written there?