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月30日 星期五
2009年10月29日 星期四
Windows\Direct Show SDK\About DirectShow Folder\Time and Clocks in DirectShow
2009年10月28日 星期三
Windows\Direct Show SDK\About DirectShow Folder\Event Notification in DirectShow
Quote of the Day 2009/10/28
Men are not prisoners of fate, but only prisoners of their own minds.
Franklin D. Roosevelt
Franklin D. Roosevelt
2009年10月27日 星期二
Windows\Direct Show SDK\About DirectShow Folder\Data Flow in the Filter Graph
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
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
2009年10月25日 星期日
Windows\Direct Show SDK\About DirectShow Folder\The Filter Graph and Its Components
2009年10月23日 星期五
Windows\Programming Tips\Walkthrough Creating and Using a Static Library
Windows\Programming Tips\Walkthrough Creating and Using a Dynamic Link Library
2009年10月22日 星期四
Windows\Direct Show SDK\About DirectShow Folder\DirectShow System Overview
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
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
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
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
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
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
訂閱:
文章 (Atom)