Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading the pixels of an AVI File 1

Status
Not open for further replies.

goren

Programmer
Mar 19, 2002
6
IL
Hello,
I'm trying to read the pixels, i.e. the raw data of an AVI File. How do I do that ?
I am searching for something like GetPixel(x,y,FrameN) ???
Thanks
 
Hello goren,
before you can access a pixel of an AVI frame, you must decrompress it (nearly all AVIs are comressed).
See following example; hope this will help you
-Klaus-


=====================================================
PAVIFILE pAviFile;
PAVISTREAM pVideoStream;
ULONG Result;
ULONG FrameNr;
LONG BytesRead;
static BYTE Buffer[2000000];

AVIFileInit();

Result = AVIFileOpen (&pAviFile, "D:\\TEMP\\SAMPLE.AVI", OF_READ |
OF_SHARE_DENY_WRITE, NULL);
if (Result)
{
... cleanup, display error and return
}

Result = AVIFileGetStream (pAviFile, &pVideoStream, streamtypeVIDEO,
0);
if (Result)
{
... cleanup, display error and return
}

PGETFRAME pGetFrame;
pGetFrame = AVIStreamGetFrameOpen (pVideoStream, NULL);
if (!pGetFrame)
{
... cleanup, display error and return
}

FrameNr = 0; // first frame
LPBITMAPINFO *pBitmapInfo
*pBitmapInfo = (LPBITMAPINFO)AVIStreamGetFrame(pGetFrame, FrameNr);
// NULL on error or no more frames
if (pBitmapInfo)
{
// here you have the complete Frame as a DIB (device independant bitmap)
// the header contains the format, followed by the real pixel data
// process bitmap . . .
}

AVIStreamGetFrameClose (pGetFrame));

... cleanup and return
===========================================================

 
Thanks,

However, I'm not so knowledgable in DIB's, also.
What variable contain the DIB, in the program?
How do I access the specific pixels in the given frame/DIB ?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top