2009年10月30日 星期五

Write BYTE Stream to BMP File

Write BYTE Stream to BMP File

void SaveBitmapToFile( BYTE* pBitmapBits, LONG lWidth, LONG lHeight,WORD wBitsPerPixel, LPCTSTR lpszFileName )


{

BITMAPINFOHEADER bmpInfoHeader = {0};

// Set the size

bmpInfoHeader.biSize = sizeof(BITMAPINFOHEADER);

// Bit count

bmpInfoHeader.biBitCount = wBitsPerPixel;

// Use all colors

bmpInfoHeader.biClrImportant = 0;

// Use as many colors according to bits per pixel

bmpInfoHeader.biClrUsed = 0;

// Store as un Compressed

bmpInfoHeader.biCompression = BI_RGB;

// Set the height in pixels

bmpInfoHeader.biHeight = lHeight;

// Width of the Image in pixels

bmpInfoHeader.biWidth = lWidth;

// Default number of planes

bmpInfoHeader.biPlanes = 1;

// Calculate the image size in bytes

bmpInfoHeader.biSizeImage = lWidth* lHeight * (wBitsPerPixel/8);



BITMAPFILEHEADER bfh = {0};

// This value should be values of BM letters i.e 0×4D42

// 0×4D = M 0×42 = B storing in reverse order to match with endian

// bfh.bfType=0×4D42;

//or

bfh.bfType = 'B'+('M' << 8);

// <<8 used to shift ‘M’ to end



// Offset to the RGBQUAD

bfh.bfOffBits = sizeof(BITMAPINFOHEADER) + sizeof(BITMAPFILEHEADER);

// Total size of image including size of headers

bfh.bfSize = bfh.bfOffBits + bmpInfoHeader.biSizeImage;

// Create the file in disk to write

HANDLE hFile = CreateFile( lpszFileName,GENERIC_WRITE, 0,NULL,



CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL,NULL);



if( !hFile ) // return if error opening file

{

return;

}



DWORD dwWritten = 0;

// Write the File header

WriteFile( hFile, &bfh, sizeof(bfh), &dwWritten , NULL );

// Write the bitmap info header

WriteFile( hFile, &bmpInfoHeader, sizeof(bmpInfoHeader), &dwWritten, NULL );

// Write the RGB Data

WriteFile( hFile, pBitmapBits, bmpInfoHeader.biSizeImage, &dwWritten, NULL );

// Close the file handle

CloseHandle( hFile );

}

2009年10月29日 星期四

Video and Image\Misc\YUV Formats




http://cid-3530681d972afc07.skydrive.live.com/self.aspx/Video%20and%20Image/Misc/YUV%20Formats.rar

Quote of the Day 2009/10/29

Silence is one of the hardest arguments to refute.

Josh Billings

Windows\Direct Show SDK\About DirectShow Folder\Time and Clocks in DirectShow




http://cid-3530681d972afc07.skydrive.live.com/self.aspx/Direct%20Show%20SDK/About%20DirectShow%20Folder/Time%20and%20Clocks%20in%20DirectShow.rar

2009年10月28日 星期三

Windows\Direct Show SDK\About DirectShow Folder\Event Notification in DirectShow




http://cid-3530681d972afc07.skydrive.live.com/self.aspx/Direct%20Show%20SDK/About%20DirectShow%20Folder/Event%20Notification%20in%20DirectShow.rar

Quote of the Day 2009/10/28

Men are not prisoners of fate, but only prisoners of their own minds.

Franklin D. Roosevelt

2009年10月27日 星期二

Windows\Direct Show SDK\About DirectShow Folder\Data Flow in the Filter Graph




http://cid-3530681d972afc07.skydrive.live.com/self.aspx/Direct%20Show%20SDK/About%20DirectShow%20Folder/Data%20Flow%20in%20the%20Filter%20Graph.rar

2009年10月26日 星期一

Quote of the Day 2009/10/27

"If you want to live a happy life, tie it to a goal, not to people or things."



Albert Einstein

Windows\Programming Tips\C Sharp 4.0:Covariance 與 Contravariance 觀念入門



http://cid-3530681d972afc07.skydrive.live.com/self.aspx/Programming%20Tips/C%204.0^7Covariance%20%e8%88%87%20Contravariance%20%e8%a7%80%e5%bf%b5%e5%85%a5%e9%96%80.rar

Windows\Direct Show SDK\About DirectShow Folder\Building the Filter Graph




http://cid-3530681d972afc07.skydrive.live.com/self.aspx/Direct%20Show%20SDK/About%20DirectShow%20Folder/Building%20the%20Filter%20Graph.rar

2009年10月25日 星期日

Windows\Direct Show SDK\About DirectShow Folder\The Filter Graph and Its Components




http://cid-3530681d972afc07.skydrive.live.com/self.aspx/Direct%20Show%20SDK/About%20DirectShow%20Folder/The%20Filter%20Graph%20and%20Its%20Components.rar

2009年10月23日 星期五

Quote of the Day 2009/10/23

There is just one life for each of us: our own.

Euripides

Windows\Programming Tips\Walkthrough Creating and Using a Static Library




http://cid-3530681d972afc07.skydrive.live.com/self.aspx/Programming%20Tips/Walkthrough%20Creating%20and%20Using%20a%20Static%20Library.rar

Windows\Programming Tips\Walkthrough Creating and Using a Dynamic Link Library




http://cid-3530681d972afc07.skydrive.live.com/self.aspx/Programming%20Tips/Walkthrough%20Creating%20and%20Using%20a%20Dynamic%20Link%20Library.rar

2009年10月22日 星期四

Windows\Direct Show SDK\About DirectShow Folder\DirectShow System Overview




http://cid-3530681d972afc07.skydrive.live.com/self.aspx/Direct%20Show%20SDK/About%20DirectShow%20Folder/DirectShow%20System%20Overview.rar

Windows\Direct Show SDK\About DirectShow Folder\About DirectShow



http://cid-3530681d972afc07.skydrive.live.com/self.aspx/Direct%20Show%20SDK/About%20DirectShow%20Folder/About%20DirectShow.rar

Quote of the Day 2009/10/22

The way to get started is to quit talking and begin doing.

Walt Disney

2009年10月21日 星期三

Windows\Direct Show SDK\Getting Started Folder\Getting Started



http://cid-3530681d972afc07.skydrive.live.com/self.aspx/Direct%20Show%20SDK/Getting%20Started%20Folder/Getting%20Started.rar

Quote of the Day 2009/10/21

I am extraordinarily patient, provided I get my own way in the end.

Margaret Thatcher

2009年10月20日 星期二

Windows\Direct Show SDK\Introduction to DirectShow Folder\DirectShow FAQ



http://cid-3530681d972afc07.skydrive.live.com/self.aspx/Direct%20Show%20SDK/Introduction%20to%20DirectShow%20Folder/DirectShow%20FAQ.rar

Windows\Direct Show SDK\Introduction to DirectShow Folder\Supported Formats in DirectShow





http://cid-3530681d972afc07.skydrive.live.com/self.aspx/Direct%20Show%20SDK/Introduction%20to%20DirectShow%20Folder/Supported%20Formats%20in%20DirectShow.rar

Quote of the Day 2009/10/20

He who is not courageous enough to take risks will accomplish nothing in life.

Muhammad Ali

2009年10月19日 星期一

Windows\Direct Show SDK\Introduction to DirectShow Folder\What's New in DirectShow



http://cid-3530681d972afc07.skydrive.live.com/self.aspx/Direct%20Show%20SDK/Introduction%20to%20DirectShow%20Folder/What^4s%20New%20in%20DirectShow.rar

Quote of the Day 2009/10/19

Reality leaves a lot to the imagination.

John Lennon

2009年10月16日 星期五

Video and Image\H.264 Web article\H.264先進視訊編解碼標準



http://cid-3530681d972afc07.skydrive.live.com/self.aspx/Others/H.264%e5%85%88%e9%80%b2%e8%a6%96%e8%a8%8a%e7%b7%a8%e8%a7%a3%e7%a2%bc%e6%a8%99%e6%ba%96.rar

Quote of the Day 2009/10/16

Dreams are necessary to life.


Anais Nin

2009年10月15日 星期四

Windows\Direct Show SDK\Introduction to DirectShow Folder\Introduction to DirectShow



http://cid-3530681d972afc07.skydrive.live.com/self.aspx/Direct%20Show%20SDK/Introduction%20to%20DirectShow%20Folder/Introduction%20to%20DirectShow.rar

Quote of the Day 2009/10/15

Every man is the architect of his own fortune.


Sallust

Windows\Direct Show SDK



http://cid-3530681d972afc07.skydrive.live.com/self.aspx/Direct%20Show%20SDK/Direct%20Show%20SDK.rar