| 发表于:2007-06-23 20:42:294楼 得分:0 |
先loadimage,再attach,再getdibits就将像素颜色信息取在了一个数组中了。 cbitmap *mclsbmp=null; hbitmap mhdlbmp; bitmap m_bitmap; mclsbmp=new cbitmap(); mhdlbmp=(hbitmap)loadimage(null,lpszpathname,image_bitmap,0,0,lr_createdibsection ¦ lr_loadfromfile); mclsbmp-> attach(mhdlbmp); mclsbmp-> getbitmap(&m_bitmap); mclsbmp-> detach(); uint * pdata = new uint[m_bitmap.bmwidth * m_bitmap.bmheight]; bitmapinfo bmpinfo; bmpinfo.bmiheader.bisize = sizeof(bitmapinfoheader); bmpinfo.bmiheader.biwidth = m_bitmap.bmwidth; bmpinfo.bmiheader.biheight = -m_bitmap.bmheight; bmpinfo.bmiheader.biplanes = 1; bmpinfo.bmiheader.bicompression = bi_rgb; bmpinfo.bmiheader.bibitcount = 32; hdc hdc = ::getwindowdc(null); getdibits(hdc,mhdlbmp,0,m_bitmap.bmheight,pdata,&bmpinfo,dib_rgb_colors); | | |
|