Okay, it sounds like you've got several problems that I'm not really going to be able to solve quickly for you, but I'll give you some pointers :
1. It sounds like you've got problems with your buffer start/end points. Check that you can take data in and send it back out to the soundcard at 48kHz without any degradation before you start worrying about downsampling and doing uLaw encoding.
2. You need to low pass filter before you do the decimation. The routine you posted isn't doing this - it's just giving you a weighted average of every 6 samples which is completely different. It's actually best done in two stages - LPF the buffer in place (corner freqency just above 4kHz), then decimate using the routine that I posted. The filtering is probably best done with a biquad IIR filter - you'll probably get away with a 2nd order LPF filter at 5kHz for what you're doing. To implement the IIR filter, do a search on the web - that's a big topic in itself.
3. If I were you I'd do all the intermediate calculation in floating point and only convert back to fixed point at the last minute. There's relatively little performance hit in Windows and it helps avoid some hideous problems that you can encounter with fixed-point IIR filtering.
After I tried it with recoding in 8kHz and without any manipulation on the raw data it sounds a bit better.
Someone has graphed my raw data and after downsampling. This both graphs looks really good to us.
But I will try to do your tips.
I had thought if I capture the sound with DirectSound the low pass filtering is still done.
Therefore I don´t do low pass filtering.
The GetDIBits function retrieves the bits of the specified compatible bitmap and copies them into a buffer as a DIB using the specified format.
HDC hdc, // handle to DC
HBITMAP hbmp, // handle to bitmap
UINT uStartScan, // first scan line to set
UINT cScanLines, // number of scan lines to copy
LPVOID lpvBits, // array for bitmap bits
LPBITMAPINFO lpbi, // bitmap data buffer
UINT uUsage // RGB or palette index
Actually i am writing code to diaply image read by an imagescanner device.
In this i need to support all formats of images. So, i need to display an image which is in byte array format. How to do that?