bmp 16位 24位 图像变换

上传者: wjh627641217 | 上传时间: 2022-04-27 16:12:37 | 文件大小: 663KB | 文件类型: RAR
void CExample10View::OnSave555BiBitfields() { // TODO: Add your command handler code here if(lpBmpDataBuf==NULL) { MessageBox("当前没有打开的位图"); return; } BYTE r,g,b; LPBYTE lpDest,lpSrc; int i,j; int nheapSize; CFileDialog filesavebox(FALSE,"bmp","BI_BITFIELDS.bmp",OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,"files(*.bmp)|*.bmp|",NULL); CFile file; CString strPathname; if(m_bmi.biBitCount!=24) { MessageBox("当前打开的位图不是24位位图"); return; } memcpy(&m_newbmf,&m_bmf,sizeof(BITMAPFILEHEADER)); memcpy(&m_newbmi,&m_bmi,sizeof(BITMAPINFOHEADER)); m_newbmi.biBitCount=16; m_newbmi.biCompression=BI_BITFIELDS;//即3 m_newbmi.biSizeImage=WIDTHBYTES(m_newbmi.biWidth,m_newbmi.biBitCount)*m_newbmi.biHeight; m_newbmf.bfSize=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER)+sizeof(DWORD)*3 +WIDTHBYTES(m_newbmi.biWidth,m_newbmi.biBitCount)*m_newbmi.biHeight; m_newbmf.bfOffBits=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER)+sizeof(DWORD)*3; nheapSize=sizeof(BITMAPINFOHEADER)+sizeof(DWORD)*3 +WIDTHBYTES(m_newbmi.biWidth,m_newbmi.biBitCount)*m_newbmi.biHeight; if(lpnewBmpDataBuf!=NULL) { delete []lpnewBmpDataBuf; lpnewBmpDataBuf=NULL; } lpnewBmpDataBuf=new BYTE[nheapSize]; memcpy(lpnewBmpDataBuf,&m_newbmi,sizeof(BITMAPINFOHEADER)); DWORD* lp=(DWORD*)(lpnewBmpDataBuf+sizeof(BITMAPINFOHEADER)); *lp++=0x00007c00; *lp++=0x000003e0; *lp =0x0000001f; for(i=0;i>3); } } if(filesavebox.DoModal()!=IDOK) return; strPathname=filesavebox.GetPathName(); if(!file.Open(strPathname,CFile::modeCreate|CFile::modeWrite)) { MessageBox("Can not Create File!"); return; } file.Write(&m_bmf,sizeof(BITMAPFILEHEADER)); file.Write(lpnewBmpDataBuf,nheapSize); file.Close(); Invalidate(TRUE); } void CExample10View::OnSave565() { // TODO: Add your command handler code here if(lpBmpDataBuf==NULL) { MessageBox("当前没有打开的位图"); return; } BYTE r,g,b; LPBYTE lpDest,lpSrc; int i,j; int nheapSize; CFileDialog filesavebox(FALSE,"bmp","565.bmp",OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,"files(*.bmp)|*.bmp|",NULL); CFile file; CString strPathname; if(m_bmi.biBitCount!=24) { MessageBox("当前打开的位图不是24位位图"); return; } memcpy(&m_newbmf,&m_bmf,sizeof(BITMAPFILEHEADER)); memcpy(&m_newbmi,&m_bmi,sizeof(BITMAPINFOHEADER)); m_newbmi.biBitCount=16; m_newbmi.biCompression=BI_BITFIELDS;//即3 m_newbmi.biSizeImage=WIDTHBYTES(m_newbmi.biWidth,m_newbmi.biBitCount)*m_newbmi.biHeight; m_newbmf.bfSize=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER)+sizeof(DWORD)*3 +WIDTHBYTES(m_newbmi.biWidth,m_newbmi.biBitCount)*m_newbmi.biHeight; m_newbmf.bfOffBits=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER)+sizeof(DWORD)*3; nheapSize=sizeof(BITMAPINFOHEADER)+sizeof(DWORD)*3 +WIDTHBYTES(m_newbmi.biWidth,m_newbmi.biBitCount)*m_newbmi.biHeight; if(lpnewBmpDataBuf!=NULL) { delete []lpnewBmpDataBuf; lpnewBmpDataBuf=NULL; } lpnewBmpDataBuf=new BYTE[nheapSize]; memcpy(lpnewBmpDataBuf,&m_newbmi,sizeof(BITMAPINFOHEADER)); DWORD* lp=(DWORD*)(lpnewBmpDataBuf+sizeof(BITMAPINFOHEADER)); *lp++=0x0000f800; *lp++=0x000007e0; *lp =0x0000001f; for(i=0;i>3); } } if(filesavebox.DoModal()!=IDOK) return; strPathname=filesavebox.GetPathName(); if(!file.Open(strPathname,CFile::modeCreate|CFile::modeWrite)) { MessageBox("Can not Create File!"); return; } file.Write(&m_bmf,sizeof(BITMAPFILEHEADER)); file.Write(lpnewBmpDataBuf,nheapSize); file.Close(); Invalidate(TRUE); }

文件下载

资源详情

[{"title":"( 37 个子文件 663KB ) bmp 16位 24位 图像变换","children":[{"title":"example10","children":[{"title":"example10.dsw <span style='color:#111;'> 543B </span>","children":null,"spread":false},{"title":"example10.aps <span style='color:#111;'> 27.66KB </span>","children":null,"spread":false},{"title":"example10View.cpp <span style='color:#111;'> 37.58KB </span>","children":null,"spread":false},{"title":"Resource.h <span style='color:#111;'> 1.04KB </span>","children":null,"spread":false},{"title":"example10.rc <span style='color:#111;'> 10.99KB </span>","children":null,"spread":false},{"title":"example10.ncb <span style='color:#111;'> 121.00KB </span>","children":null,"spread":false},{"title":"example10.clw <span style='color:#111;'> 2.05KB </span>","children":null,"spread":false},{"title":"example10.opt <span style='color:#111;'> 48.50KB </span>","children":null,"spread":false},{"title":"example10Doc.h <span style='color:#111;'> 1.47KB </span>","children":null,"spread":false},{"title":"example10Doc.cpp <span style='color:#111;'> 1.76KB </span>","children":null,"spread":false},{"title":"example10.dsp <span style='color:#111;'> 4.51KB </span>","children":null,"spread":false},{"title":"RES","children":[{"title":"example10.rc2 <span style='color:#111;'> 401B </span>","children":null,"spread":false},{"title":"example10.ico <span style='color:#111;'> 1.05KB </span>","children":null,"spread":false},{"title":"Toolbar.bmp <span style='color:#111;'> 358B </span>","children":null,"spread":false},{"title":"example10Doc.ico <span style='color:#111;'> 1.05KB </span>","children":null,"spread":false}],"spread":true},{"title":"example10.plg <span style='color:#111;'> 2.21KB </span>","children":null,"spread":false},{"title":"example10View.h <span style='color:#111;'> 2.57KB </span>","children":null,"spread":false},{"title":"StdAfx.cpp <span style='color:#111;'> 211B </span>","children":null,"spread":false},{"title":"MainFrm.cpp <span style='color:#111;'> 2.45KB </span>","children":null,"spread":false},{"title":"example10.cpp <span style='color:#111;'> 4.16KB </span>","children":null,"spread":false},{"title":"图像","children":[{"title":"24位彩图","children":[{"title":"BIRD.BMP <span style='color:#111;'> 324.05KB </span>","children":null,"spread":false}],"spread":false},{"title":"黑白图","children":[{"title":"default1.bmp <span style='color:#111;'> 121.55KB </span>","children":null,"spread":false},{"title":"LENA.BMP <span style='color:#111;'> 65.05KB </span>","children":null,"spread":false},{"title":"default2.bmp <span style='color:#111;'> 109.05KB </span>","children":null,"spread":false},{"title":"45度方块.BMP <span style='color:#111;'> 65.05KB </span>","children":null,"spread":false},{"title":"方块.BMP <span style='color:#111;'> 65.05KB </span>","children":null,"spread":false},{"title":"Couple.bmp <span style='color:#111;'> 65.05KB </span>","children":null,"spread":false}],"spread":false},{"title":"16位彩图","children":[{"title":"BI_BITFIELDS.bmp <span style='color:#111;'> 216.06KB </span>","children":null,"spread":false},{"title":"565.BMP <span style='color:#111;'> 216.06KB </span>","children":null,"spread":false},{"title":"default.bmp <span style='color:#111;'> 109.05KB </span>","children":null,"spread":false},{"title":"BI_RGB.BMP <span style='color:#111;'> 216.05KB </span>","children":null,"spread":false}],"spread":false},{"title":"8位彩图","children":[{"title":"default.bmp <span style='color:#111;'> 121.55KB </span>","children":null,"spread":false},{"title":"SPLASH.BMP <span style='color:#111;'> 121.55KB </span>","children":null,"spread":false}],"spread":false}],"spread":false},{"title":"example10.h <span style='color:#111;'> 1.36KB </span>","children":null,"spread":false},{"title":"MainFrm.h <span style='color:#111;'> 1.54KB </span>","children":null,"spread":false},{"title":"StdAfx.h <span style='color:#111;'> 1.03KB </span>","children":null,"spread":false},{"title":"ReadMe.txt <span style='color:#111;'> 4.28KB </span>","children":null,"spread":false}],"spread":false}],"spread":true}]

评论信息

  • lwjstc :
    自己拿头文件进去参考下就好了,不需要编译。只需要转换代码。
    2014-05-21
  • fantangshan :
    真没用, 哎
    2014-04-27
  • guohkg :
    没有什么用。
    2013-07-13
  • samoh :
    这个真的没法用,都是文件,没有程序
    2012-11-28

免责申明

【只为小站】的资源来自网友分享,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,【只为小站】 无法对用户传输的作品、信息、内容的权属或合法性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论 【只为小站】 经营者是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。
本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二条之规定,若资源存在侵权或相关问题请联系本站客服人员,zhiweidada#qq.com,请把#换成@,本站将给予最大的支持与配合,做到及时反馈和处理。关于更多版权及免责申明参见 版权及免责申明