Last post Nov 29, 2008 09:55 AM by xoro
Nov 23, 2008 06:12 AM|shameerashaik|LINK
Hi Every One,
Iam storing the image as byte into sql server database .And Iam pulling all these images as one thumbnail page in an aspx page where
iam loading the images into repeater control using Handler.ashx .
In handler.ashx , iam getting the image from database, then writing that byte using response object.Some time I need to show 100 images in that aspx page
Now the page is loading too slowly crossing minutes.Please help
I need to deliver the project so urgently
Kind help requested
Nov 23, 2008 10:23 AM|Ken Tucker|LINK
Image size can definately affect speed here. 100 images 10k each will load fairly quickly. 100 Images 1meg each will take a while.
You might have to render a smaller version of the image in the handler. Load the image in a bitmap. Then create a smaller version of the bitmap for example 25% the orginal size. Paint the loaded image in that bitmap. Have your handler render the small
version to keep load time down
Nov 24, 2008 01:08 AM|shameerashaik|LINK
gr.SmoothingMode = System.Drawing.Drawing2D.
gr.InterpolationMode = System.Drawing.Drawing2D.
gr.DrawImage(dbImage, rectDestination, 0, 0, dbImage.Size.Width, dbImage.Size.Height,
stream.Position = 0;
This is my code.Please help.I need to show atleast 200 images at one shot
Nov 25, 2008 10:26 PM|Nai-Dong Jin - MSFT|LINK
From your description, it seems that you want to create a bitmap from an array of bytes, right? I’ve found someone in other forums use the following practice to
achieve your target and it maybe can improve the performance.
Assuming you have the pixel data in a byte array called 'data':
// Create the 8bpp indexed bitmap
Bitmap bmp = new Bitmap(512, 512, PixelFormat.Format8bppIndexed);
// To access the raw image data we need to use pointers
// Note that you need to compile with /unsafe
// or set "Allow unsafe code blocks" in your project's
// configuration properties
// Lock the bitmap data to a fixed position
// You only write data, you might as well use WriteOnly
BitmapData bmData = bmp.LockBits(
new Rectangle(0, 0, bmp.Width, bmp.Height),
// Get a pointer to the beginning of the pixel data
byte* p = (byte*)bmData.Scan0;
// Since a Bitmap scan line is ALWAYS multiples of
// 4 bytes we need to 'step over' the unused bytes
// at the end.
// Stride tells us the size of the scan line
int diff = bmData.Stride - bmp.Width;
// Loop through your array and add each byte
// For each loop increment the pointer by 1
// When we reach the end of a line step over
// the unused bytes
for(int i = 0; i < data.Length; i++)
*p++ = data[ i ];
if(i % bmp.Width == 0 && i > 0)
p += diff;
// Release the memory
To set the colors for the Bitmap, change the entries in its palette like this:
ColorPalette cp = bmp.Palette;
for( int i = 0; i < cp.Entries.Length; i++ )
cp.Entries[ i ] = Color.FromArgb(i, 0, 0);
bmp.Palette = cp;
Nov 29, 2008 09:55 AM|xoro|LINK
You can use a Custom Image Thumbnail generator with JPEG Compression optimization in order to reduce Page Load cost and use a seperate Image Viewer for Original Image Size.
I talked about that on my blog, take a look
Hope this help's