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

隨筆 - 74, 文章 - 0, 評論 - 26, 引用 - 0
數據加載中……

Write HBITMAP Object in to BMP File 轉

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) 評論(2)  編輯 收藏 引用

評論

# re: Write HBITMAP Object in to BMP File 轉  回復  更多評論   

結果是什么
2010-03-09 16:12 | nfl 2010

# re: Write HBITMAP Object in to BMP File 轉  回復  更多評論   

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
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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精品国产| 99综合在线| 日韩亚洲欧美高清| 亚洲巨乳在线| 国产精品99久久久久久www| 一区二区三区四区五区在线| 亚洲视频一区| 亚洲欧美影音先锋| 久久精品国产亚洲一区二区| 美国成人直播| 亚洲韩国精品一区| 亚洲精品综合| 亚洲一二三区在线观看| 久久成人精品一区二区三区| 女仆av观看一区| 国产精品国产| 在线日本欧美| 亚洲欧美偷拍卡通变态| 免费观看一级特黄欧美大片| 亚洲日本aⅴ片在线观看香蕉| 亚洲无玛一区| 蜜臀久久99精品久久久久久9 | 免费看的黄色欧美网站| 欧美日韩久久久久久| 国产麻豆综合| 一区二区三区国产盗摄| 免费不卡在线观看| 99视频精品在线| 久久爱91午夜羞羞| 欧美另类videos死尸| 国产欧美日本| 99视频超级精品| 免费成人网www| 亚洲视频免费观看| 欧美成人午夜| 国产在线精品二区| 亚洲欧美电影院| 亚洲欧洲日本国产| 久久午夜精品| 国产亚洲一区在线播放| 亚洲一品av免费观看| 欧美激情视频一区二区三区不卡| 午夜精品久久久久久久久久久久久| 欧美激情影音先锋| 亚洲激情影院| 男人插女人欧美| 欧美在线999| 国产欧美一区二区精品秋霞影院 | 久久精品女人的天堂av| 亚洲欧洲日夜超级视频| 狂野欧美激情性xxxx欧美| 国产婷婷色综合av蜜臀av| 亚洲欧美高清| 国产精品99久久久久久久vr| 日韩一区二区福利| 麻豆av福利av久久av| 欧美三区美女| 亚洲精品男同| 免费成人性网站| 性做久久久久久久久| 国产欧美精品一区| 性做久久久久久| 久久青草欧美一区二区三区| 国语自产偷拍精品视频偷| 久久久999精品| 久久成人精品无人区| 国内自拍亚洲| 亚洲激情在线视频| 欧美日韩精品一本二本三本| 日韩视频免费在线| 亚洲视频欧美在线| 日韩天堂在线观看| 久久精品91久久久久久再现| 在线观看国产日韩| 国产精品久久福利| 欧美激情一级片一区二区| 国产精品毛片va一区二区三区 | av成人免费观看| 99精品久久免费看蜜臀剧情介绍| 久久精品国产99| 亚洲国产aⅴ天堂久久| 亚洲黑丝在线| 国产精品腿扒开做爽爽爽挤奶网站| 久久夜色精品亚洲噜噜国产mv| 国产精品区免费视频| 亚洲一区二区三区在线观看视频| 午夜激情综合网| 国产一区二区日韩精品| 亚洲黄色av| 亚洲天堂视频在线观看| 午夜精品区一区二区三| 国产日韩欧美不卡在线| 久久天天狠狠| 一本久久知道综合久久| 久久精品一区二区| 日韩午夜在线视频| 国产裸体写真av一区二区| 亚洲女同精品视频| 亚洲国产一区二区三区高清 | 欧美在线一二三| 久久久精品一区二区三区| 影音先锋亚洲一区| 国产精品一区三区| 欧美天堂在线观看| 欧美一二三视频| 久久久精品日韩欧美| 国产一区视频网站| 欧美精品一区二区三区蜜桃 | 国产精品美女久久久浪潮软件| 亚洲美女毛片| 久久久亚洲综合| 91久久嫩草影院一区二区| 国产精品视频久久| 国产精品vvv| 欧美午夜精品理论片a级大开眼界 欧美午夜精品理论片a级按摩 | 99精品免费视频| 亚洲区在线播放| 亚洲国产美女| 国产一区欧美| 在线日韩精品视频| 亚洲另类自拍| 欧美专区在线观看一区| 欧美在线999| 久久综合九色综合欧美就去吻| 久久av红桃一区二区小说| 久久亚洲综合网| 亚洲免费观看在线观看| 午夜精品视频在线| 久久一区二区精品| 国产精品嫩草99av在线| 加勒比av一区二区| 亚洲国产一区二区三区高清| 亚洲一区二区三区高清| 久久婷婷国产麻豆91天堂| 欧美大色视频| 欧美亚洲免费| 国产精品久久久久久久7电影| 亚洲国产精品成人精品| 午夜精品国产精品大乳美女| 亚洲高清不卡av| 欧美制服第一页| 国产欧美日本| 欧美亚洲网站| 亚洲综合色视频| 欧美日韩在线观看一区二区| 亚洲美女网站| 99re在线精品| 欧美日韩亚洲视频| 91久久香蕉国产日韩欧美9色| 美日韩精品免费| 久久婷婷综合激情| 亚洲日本久久| 亚洲国内精品在线| 欧美日韩国产大片| 亚洲一品av免费观看| 亚洲午夜激情在线| 国产欧美精品在线| 欧美v国产在线一区二区三区| 久久综合九色| 一区二区欧美日韩| 亚洲欧洲99久久| 在线成人欧美| 日韩视频免费观看| 在线播放国产一区中文字幕剧情欧美 | 黑人一区二区三区四区五区| 久久成人在线| 美国成人直播| 欧美亚洲一区二区在线观看| 久久手机免费观看| 在线精品国产欧美| 有码中文亚洲精品| 亚洲乱码日产精品bd| 一区二区三区欧美激情| 久久躁日日躁aaaaxxxx| 欧美一站二站| 国产精品香蕉在线观看| 亚洲午夜一级| 亚洲欧美日韩综合aⅴ视频| 久久综合激情| 欧美顶级少妇做爰| 韩日精品视频| 久热国产精品| 久久理论片午夜琪琪电影网| 国产欧美日本一区视频| 午夜精品久久久久久99热软件| 欧美在线一二三| 在线成人性视频| 欧美高清视频在线播放| 亚洲日本中文字幕免费在线不卡| 亚洲激情偷拍| 国产精品久久久久久久app| 亚洲视频电影在线| 免费成人小视频| 亚洲综合日本| 亚洲人成亚洲人成在线观看| 国产在线精品自拍| 欧美aⅴ一区二区三区视频| 国产综合色产| 亚洲国产日韩一区|