青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

隨筆 - 74, 文章 - 0, 評(píng)論 - 26, 引用 - 0
數(shù)據(jù)加載中……

Write HBITMAP Object in to BMP File 轉(zhuǎn)

void WriteBMPFile(HBITMAP bitmap, LPTSTR filename, HDC hDC)
{
BITMAP bmp;
PBITMAPINFO pbmi;
WORD cClrBits;
HANDLE hf; // file handle
BITMAPFILEHEADER hdr; // bitmap file-header
PBITMAPINFOHEADER pbih; // bitmap info-header
LPBYTE lpBits; // memory pointer
DWORD dwTotal; // total count of bytes
DWORD cb; // incremental count of bytes
BYTE *hp; // byte pointer
DWORD dwTmp;

// create the bitmapinfo header information

if (!GetObject( (bitmap, sizeof(BITMAP), (LPSTR)&bmp)){
AfxMessageBox("Could not retrieve bitmap info");
return;
}

// Convert the color format to a count of bits.
cClrBits = (WORD)(bmp.bmPlanes * bmp.bmBitsPixel);
if (cClrBits == 1)
cClrBits = 1;
else if (cClrBits <= 4)
cClrBits = 4;
else if (cClrBits <= 8)
cClrBits = 8;
else if (cClrBits <= 16)
cClrBits = 16;
else if (cClrBits <= 24)
cClrBits = 24;
else cClrBits = 32;

// Allocate memory for the BITMAPINFO structure.
if (cClrBits != 24)
pbmi = (PBITMAPINFO) LocalAlloc(LPTR,
sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * (1<< cClrBits));
else
pbmi = (PBITMAPINFO) LocalAlloc(LPTR, sizeof(BITMAPINFOHEADER));

// Initialize the fields in the BITMAPINFO structure.

pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
pbmi->bmiHeader.biWidth = bmp.bmWidth;
pbmi->bmiHeader.biHeight = bmp.bmHeight;
pbmi->bmiHeader.biPlanes = bmp.bmPlanes;
pbmi->bmiHeader.biBitCount = bmp.bmBitsPixel;
if (cClrBits < 24)
pbmi->bmiHeader.biClrUsed = (1<<cClrBits);

// If the bitmap is not compressed, set the BI_RGB flag.
pbmi->bmiHeader.biCompression = BI_RGB;

// Compute the number of bytes in the array of color
// indices and store the result in biSizeImage.
pbmi->bmiHeader.biSizeImage = (pbmi->bmiHeader.biWidth + 7) /8 * pbmi->bmiHeader.biHeight * cClrBits;
// Set biClrImportant to 0, indicating that all of the
// device colors are important.
pbmi->bmiHeader.biClrImportant = 0;

// now open file and save the data
pbih = (PBITMAPINFOHEADER) pbmi;
lpBits = (LPBYTE) GlobalAlloc(GMEM_FIXED, pbih->biSizeImage);

if (!lpBits) {
AfxMessageBox("writeBMP::Could not allocate memory");
return;
}

// Retrieve the color table (RGBQUAD array) and the bits
if (!GetDIBits(hDC, HBITMAP(bitmap), 0, (WORD) pbih->biHeight, lpBits, pbmi,
DIB_RGB_COLORS)) {
AfxMessageBox("writeBMP::GetDIB error");
return;
}

// Create the .BMP file.
hf = CreateFile(filename, GENERIC_READ | GENERIC_WRITE, (DWORD) 0,
NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL,
(HANDLE) NULL);
if (hf == INVALID_HANDLE_VALUE){
AfxMessageBox("Could not create file for writing");
return;
}
hdr.bfType = 0x4d42; // 0x42 = "B" 0x4d = "M"
// Compute the size of the entire file.
hdr.bfSize = (DWORD) (sizeof(BITMAPFILEHEADER) +
pbih->biSize + pbih->biClrUsed
* sizeof(RGBQUAD) + pbih->biSizeImage);
hdr.bfReserved1 = 0;
hdr.bfReserved2 = 0;

// Compute the offset to the array of color indices.
hdr.bfOffBits = (DWORD) sizeof(BITMAPFILEHEADER) +
pbih->biSize + pbih->biClrUsed
* sizeof (RGBQUAD);

// Copy the BITMAPFILEHEADER into the .BMP file.
if (!WriteFile(hf, (LPVOID) &hdr, sizeof(BITMAPFILEHEADER),
(LPDWORD) &dwTmp, NULL)) {
AfxMessageBox("Could not write in to file");
return;
}

// Copy the BITMAPINFOHEADER and RGBQUAD array into the file.
if (!WriteFile(hf, (LPVOID) pbih, sizeof(BITMAPINFOHEADER)
+ pbih->biClrUsed * sizeof (RGBQUAD),
(LPDWORD) &dwTmp, ( NULL))){
AfxMessageBox("Could not write in to file");
return;
}


// Copy the array of color indices into the .BMP file.
dwTotal = cb = pbih->biSizeImage;
hp = lpBits;
if (!WriteFile(hf, (LPSTR) hp, (int) cb, (LPDWORD) &dwTmp,NULL)){
AfxMessageBox("Could not write in to file");
return;
}

// Close the .BMP file.
if (!CloseHandle(hf)){
AfxMessageBox("Could not close file");
return;
}

// Free memory.
GlobalFree((HGLOBAL)lpBits);
}

posted on 2009-02-16 11:32 井泉 閱讀(1229) 評(píng)論(2)  編輯 收藏 引用

評(píng)論

# re: Write HBITMAP Object in to BMP File 轉(zhuǎn)  回復(fù)  更多評(píng)論   

結(jié)果是什么
2010-03-09 16:12 | nfl 2010

# re: Write HBITMAP Object in to BMP File 轉(zhuǎn)  回復(fù)  更多評(píng)論   

I have the functions to check if there is an image on the clipboard and to get the HBITMAP data of that image. Now I only have one question: How can I save, in C++, an HBITMAP structure into a Bitmap file on the computer?
2011-04-20 18:36 | Human Health

只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。
網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問(wèn)   Chat2DB   管理


青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            久久狠狠一本精品综合网| 久久久国产视频91| 午夜日韩在线观看| 亚洲欧美综合v| 欧美成人一区二区在线| 精品成人久久| 羞羞色国产精品| 亚洲精品在线二区| 久久这里有精品视频| 韩国精品久久久999| 欧美在线资源| 亚洲欧美国产精品va在线观看| 欧美日本国产在线| 亚洲精品三级| 亚洲国内自拍| 久久精品一二三区| 国产日韩亚洲| 久久免费国产精品1| 久久久久久久91| 黄色亚洲免费| 六月天综合网| 女同一区二区| 99re6这里只有精品视频在线观看| 欧美成人蜜桃| 欧美高清不卡在线| 亚洲欧美视频一区| 亚洲欧美视频在线| 极品中文字幕一区| 91久久一区二区| 欧美午夜精品久久久久久孕妇| 亚洲男女毛片无遮挡| 亚洲免费视频成人| 伊人色综合久久天天| 亚洲国产欧美不卡在线观看| 欧美理论视频| 性亚洲最疯狂xxxx高清| 久久久久久穴| 免费欧美日韩| 国产欧美一区二区三区在线老狼| 欧美一区二区三区啪啪| 久久精品国产久精国产爱| 精品av久久707| 亚洲国产91色在线| 国产精品福利在线观看网址| 久久精品一区二区三区四区| 噜噜噜躁狠狠躁狠狠精品视频| 最新国产成人av网站网址麻豆| 一二三区精品福利视频| 黄色成人免费观看| 日韩一级不卡| 伊人春色精品| 亚洲美女免费精品视频在线观看| 国产精一区二区三区| 欧美国产视频一区二区| 国产精品视频你懂的| 欧美国产精品一区| 国产毛片一区| av成人国产| 亚洲国产婷婷香蕉久久久久久99| 亚洲小说欧美另类社区| 91久久久久久国产精品| 亚洲精品欧美极品| 一区二区三区在线看| 亚洲午夜视频在线观看| 亚洲大胆视频| 国产情人综合久久777777| 巨胸喷奶水www久久久免费动漫| 欧美韩国日本一区| 久久国产毛片| 亚洲综合色视频| 欧美www在线| 久久综合九色99| 国产精品一区一区三区| 亚洲国产天堂久久综合网| 国产精品一区二区久激情瑜伽| 亚洲国产第一| 激情偷拍久久| 欧美影院在线| 欧美一区二区国产| 欧美视频一区二区三区在线观看| 欧美成人官网二区| 亚洲第一页中文字幕| 欧美一区二区免费观在线| 亚洲欧美在线看| 国产精品国产亚洲精品看不卡15| 亚洲精品国产视频| 亚洲精品日韩一| 欧美精品激情在线| 亚洲精品欧洲| 亚洲一区二区免费| 欧美午夜不卡在线观看免费| 亚洲国产另类久久精品| 亚洲激情婷婷| 欧美成人综合一区| 亚洲日本中文字幕区| 亚洲最快最全在线视频| 欧美日韩一级黄| 在线视频精品| 一区二区毛片| 国产精品第一页第二页第三页| 在线午夜精品自拍| 久久激情视频| 欧美主播一区二区三区美女 久久精品人| 欧美巨乳在线| 一区二区三区国产精品| 亚洲天堂网站在线观看视频| 国产精品盗摄一区二区三区| 亚洲你懂的在线视频| 久久久91精品国产| 欧美三级视频| 国产综合久久久久影院| 欧美新色视频| 欧美日韩一区二区欧美激情| 国产精品日韩精品欧美在线| 国产精品h在线观看| 欧美激情一区二区三区蜜桃视频| 欧美日产国产成人免费图片| 欧美久久久久免费| 国产欧美一区二区视频| 亚洲欧美在线高清| 欧美一区二区三区四区在线观看地址| 国产精品中文字幕在线观看| 久久99伊人| 亚洲黄色在线看| 亚洲一级黄色片| 激情欧美一区二区三区在线观看| 亚洲一区精品在线| 亚洲欧洲日韩在线| 欧美激情视频网站| 一本久道综合久久精品| 欧美一级网站| 亚洲精品男同| 国产精品久久久| 久久综合久色欧美综合狠狠 | 亚洲美女福利视频网站| 欧美日韩和欧美的一区二区| 亚洲欧美日韩专区| 亚洲欧洲日本专区| 久久青草久久| 在线视频欧美精品| 亚洲国产成人久久综合| 国产精品美女| 欧美成人亚洲成人| 欧美有码在线视频| 在线视频欧美日韩| 亚洲激情二区| 久久夜色精品国产噜噜av| 亚洲一区精品视频| 亚洲精品美女在线观看| 国产主播一区二区三区四区| 欧美色欧美亚洲另类七区| 久久亚洲精品一区| 香蕉久久久久久久av网站| 夜夜嗨一区二区三区| 欧美成人在线免费视频| 午夜视频在线观看一区二区| 亚洲美女中出| 亚洲欧洲日产国码二区| 在线日韩中文字幕| 国产一区二区你懂的| 欧美午夜美女看片| 欧美久久视频| 一区二区三区日韩在线观看 | 99香蕉国产精品偷在线观看| 国模叶桐国产精品一区| 国产精品美女诱惑| 欧美精品久久一区二区| 久久久美女艺术照精彩视频福利播放 | 久热综合在线亚洲精品| 久久精品国产第一区二区三区最新章节 | 欧美在线啊v一区| 亚洲免费在线| 亚洲综合精品自拍| 亚洲香蕉网站| 一本久久青青| 亚洲少妇诱惑| 亚洲综合首页| 性欧美在线看片a免费观看| 亚洲欧美国产一区二区三区| 亚洲午夜激情| 亚洲欧美日韩第一区| 亚洲女同精品视频| 欧美一二三视频| 欧美一区二区三区另类| 久久狠狠亚洲综合| 老司机午夜精品视频| 欧美日韩国产精品一区二区亚洲| 99国产精品久久久| 日韩一级网站| 亚洲一区二区三区涩| 亚洲男女自偷自拍| 午夜天堂精品久久久久| 久久激情综合网| 免费成人高清| 亚洲国产精品精华液2区45| 亚洲欧洲三级电影| 宅男精品视频| 欧美专区一区二区三区| 久久躁日日躁aaaaxxxx| 欧美久久久久免费|