Wednesday, December 05, 2007

Flipped Video problem in DirectShow

Normally in Directshow we face the Flipped image problem...

if we are having image buffer, how can we flip it using code ?

This is being done by the following code...

Solution :
------------

Here what we have done was...

ScanLine1- 0 - Scanwidth pixels
ScanLine2 - 0 to ScanWidth Pixels
upto
ScanLineN

we have to modify it as follows for Flipping the Image Data :

ScanLine N and its pixels...
ScanLine N-1 and its Pixels

upto
ScanLine 1



For Doing this, we have developed the following code :





void FlipUpDown(BYTE* pData,int gWidth,int gHeight,int gChannels)
{
BYTE* scan0 = pData;
BYTE* scan1 = pData + ((gWidth * gHeight * gChannels) - (gWidth * gChannels));

for (unsigned int y = 0; y < gHeight / 2; y++) {
for (unsigned int x = 0; x < gWidth * gChannels; x++)
{
BYTE temp = scan0[x];
scan0[x] = scan1[x];
scan1[x] = temp;
}
scan0 += gWidth * gChannels;
scan1 -= gWidth * gChannels;
}

Labels:

0 Comments:

Post a Comment

<< Home