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

隨筆 - 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>
            国产午夜精品在线| 国产乱理伦片在线观看夜一区| 狠狠色丁香久久婷婷综合_中| 午夜欧美大片免费观看| 亚洲桃花岛网站| 国产真实久久| 欧美激情第二页| 欧美色区777第一页| 午夜精品久久久久影视| 午夜精品久久久久久久久久久久久| 国产性色一区二区| 欧美韩日一区二区三区| 欧美日韩天堂| 久久女同互慰一区二区三区| 一区二区av在线| 亚洲欧美日韩国产中文在线| 狠狠色丁香婷婷综合影院| 亚洲激情女人| 国产精品女主播| 欧美国产成人在线| 国产精品国产三级国产专播品爱网 | 亚洲精品一级| 欧美大片免费久久精品三p | 欧美激情免费观看| 亚洲欧美一级二级三级| 久久深夜福利| 亚洲欧美日韩一区二区在线 | 国产精品亚发布| 欧美激情视频一区二区三区不卡| 欧美性猛交99久久久久99按摩| 久久久国产亚洲精品| 欧美理论电影网| 久久综合九色| 国产精品一区二区欧美| 亚洲国产视频一区| 国产一区二区三区久久久久久久久| 亚洲国产精品第一区二区| 国产日韩1区| 麻豆国产精品777777在线| 国产精品久久久久永久免费观看| 亚洲欧美日产图| 欧美精品性视频| 免费视频一区二区三区在线观看| 欧美交受高潮1| 久久人人九九| 国产精品影片在线观看| 日韩一二三区视频| 日韩西西人体444www| 久久综合给合| 久久久青草婷婷精品综合日韩| 国产精品国产自产拍高清av王其| 91久久中文字幕| 亚洲国产清纯| 另类专区欧美制服同性| 久久综合久久综合久久| 国产精品一区一区| 亚洲夜晚福利在线观看| 亚洲欧美www| 国产精品扒开腿做爽爽爽视频| 亚洲日韩欧美视频一区| 99国产麻豆精品| 欧美日韩国产影片| 亚洲精品三级| 亚洲一区精品电影| 欧美网站在线| 亚洲欧洲综合另类| 久久久久.com| 老妇喷水一区二区三区| 今天的高清视频免费播放成人 | 猛干欧美女孩| 亚洲电影在线看| 9l国产精品久久久久麻豆| 欧美国产激情| 一本色道久久综合狠狠躁的推荐| 亚洲深夜福利网站| 国产精品日韩| 欧美专区中文字幕| 免费观看亚洲视频大全| 在线观看一区二区视频| 欧美高清在线播放| 一本色道久久精品| 欧美有码视频| 精品va天堂亚洲国产| 欧美国产精品人人做人人爱| 亚洲美女视频网| 欧美中文在线观看国产| 在线免费精品视频| 欧美久久在线| 性一交一乱一区二区洋洋av| 久久综合给合| 亚洲精品在线免费| 欧美色道久久88综合亚洲精品| 亚洲综合国产激情另类一区| 噜噜噜91成人网| 中文欧美在线视频| 国模精品一区二区三区| 欧美激情亚洲自拍| 欧美一区二区三区免费观看| 亚洲高清久久| 久久久精品日韩欧美| 亚洲美女视频网| 国产一区二区三区视频在线观看| 欧美福利视频在线观看| 欧美一级久久| 一本大道久久精品懂色aⅴ| 久久久久久久久久久久久女国产乱 | 午夜国产欧美理论在线播放| 久久久久国内| 亚洲亚洲精品在线观看 | 欧美精品福利在线| 欧美一区二区三区免费在线看| 亚洲日本激情| 久久久亚洲午夜电影| 一区二区免费看| 亚洲高清免费在线| 国产亚洲免费的视频看| 欧美日韩亚洲天堂| 欧美成熟视频| 久久天天躁夜夜躁狠狠躁2022| 亚洲一区二区视频在线| 亚洲毛片在线观看| 欧美激情一区二区三区| 久久综合狠狠综合久久激情| 性欧美激情精品| 亚洲一区3d动漫同人无遮挡| 亚洲美女少妇无套啪啪呻吟| 99国产精品久久| 老牛国产精品一区的观看方式| 欧美一区国产在线| 亚洲女ⅴideoshd黑人| 一本久道久久综合婷婷鲸鱼| 最近中文字幕日韩精品| 在线日韩av| 亚洲第一成人在线| 亚洲大胆美女视频| 在线欧美小视频| 亚洲国产精品成人精品| 亚洲福利视频三区| 在线日韩欧美视频| 影音先锋成人资源站| 激情综合色综合久久| 激情欧美一区二区| 在线免费观看日韩欧美| 亚洲国产精品一区二区尤物区| 伊人久久大香线| 亚洲国产第一| 日韩视频一区二区三区| 亚洲日韩欧美一区二区在线| 亚洲国产裸拍裸体视频在线观看乱了| 在线播放不卡| 亚洲国产成人在线播放| 亚洲精品一二| 一区二区高清在线观看| 亚洲神马久久| 亚洲一区在线看| 久久精品视频在线看| 老司机午夜精品视频| 亚洲国产精品福利| 一区二区高清| 亚洲女同同性videoxma| 久久动漫亚洲| 欧美激情精品久久久久久大尺度 | 久久国产黑丝| 玖玖精品视频| 欧美日韩一区二区三区在线 | 欧美影视一区| 欧美黄色一区二区| 国产麻豆精品theporn| 在线视频成人| 亚洲小说春色综合另类电影| 久久精品成人一区二区三区| 欧美国产精品劲爆| 亚洲午夜精品一区二区三区他趣| 欧美在线高清视频| 欧美日韩国产成人在线| 国产小视频国产精品| 亚洲美女网站| 久久尤物视频| 一本久道久久久| 久久久免费精品视频| 欧美日韩亚洲网| 极品中文字幕一区| 亚洲欧美影院| 亚洲国产视频直播| 欧美在线一二三| 欧美视频福利| 最新中文字幕亚洲| 欧美一区二区三区成人| 亚洲日本在线视频观看| 久久久久国产一区二区| 国产精品久久综合| 日韩亚洲欧美成人| 美女网站久久| 欧美一级在线亚洲天堂| 欧美日韩在线免费| 亚洲黄色av| 美日韩精品视频免费看| 篠田优中文在线播放第一区| 国产精品每日更新| 一区二区三区免费看|