C 版截圖函式

2021-05-23 08:59:36 字數 4628 閱讀 5976

void ccapturedlg::screen(cstring filename)

bitmapinfoheader bih = ;//位圖資訊頭

bih.bibitcount =24;// bmp.bmbitspixel;//每個畫素位元組大小

bih.bicompression = bi_rgb;

bih.biheight = bmp.bmheight;//高度

bih.biplanes = 1;

bih.bisize = sizeof(bitmapinfoheader);

bih.bisizeimage = bmp.bmwidthbytes * bmp.bmheight;//影象資料大小

bih.biwidth = bmp.bmwidth;//寬度

bitmapfileheader bfh = ;//位**件頭

bfh.bfoffbits = sizeof(bitmapfileheader) + sizeof(bitmapinfoheader);//到位圖資料的偏移量

bfh.bfsize = bfh.bfoffbits + bmp.bmwidthbytes * bmp.bmheight;//檔案總的大小

bfh.bftype = (word)0x4d42;

file.write(&bfh,sizeof(bitmapfileheader));//寫入位**件頭

file.write(&bih,sizeof(bitmapinfoheader));//寫入位圖資訊頭  

byte * p = new byte[bmp.bmwidthbytes * bmp.bmheight];//申請記憶體儲存位圖資料

getdibits(memdc.m_hdc, (hbitmap) membitmap.m_hobject, 0, height, p,

(lpbitmapinfo) &bih, dib_rgb_colors);//獲取位圖資料

file.writehuge(p,bmp.bmwidthbytes * bmp.bmheight);

file.close();

delete p;

memdc.selectobject(oldmembitmap);

}void ccapturedlg::screen(cstring filename)

bitmapinfoheader bih = ;//位圖資訊頭

bih.bibitcount =24;// bmp.bmbitspixel;//每個畫素位元組大小

bih.bicompression = bi_rgb;

bih.biheight = bmp.bmheight;//高度

bih.biplanes = 1;

bih.bisize = sizeof(bitmapinfoheader);

bih.bisizeimage = bmp.bmwidthbytes * bmp.bmheight;//影象資料大小

bih.biwidth = bmp.bmwidth;//寬度

bitmapfileheader bfh = ;//位**件頭

bfh.bfoffbits = sizeof(bitmapfileheader) + sizeof(bitmapinfoheader);//到位圖資料的偏移量

bfh.bfsize = bfh.bfoffbits + bmp.bmwidthbytes * bmp.bmheight;//檔案總的大小

bfh.bftype = (word)0x4d42;

file.write(&bfh,sizeof(bitmapfileheader));//寫入位**件頭

file.write(&bih,sizeof(bitmapinfoheader));//寫入位圖資訊頭  

byte * p = new byte[bmp.bmwidthbytes * bmp.bmheight];//申請記憶體儲存位圖資料

getdibits(memdc.m_hdc, (hbitmap) membitmap.m_hobject, 0, height, p,

(lpbitmapinfo) &bih, dib_rgb_colors);//獲取位圖資料

file.writehuge(p,bmp.bmwidthbytes * bmp.bmheight);

file.close();

delete p;

memdc.selectobject(oldmembitmap);

}void ccapturedlg::screen(cstring filename)

bitmapinfoheader bih = ;//位圖資訊頭

bih.bibitcount =24;// bmp.bmbitspixel;//每個畫素位元組大小

bih.bicompression = bi_rgb;

bih.biheight = bmp.bmheight;//高度

bih.biplanes = 1;

bih.bisize = sizeof(bitmapinfoheader);

bih.bisizeimage = bmp.bmwidthbytes * bmp.bmheight;//影象資料大小

bih.biwidth = bmp.bmwidth;//寬度

bitmapfileheader bfh = ;//位**件頭

bfh.bfoffbits = sizeof(bitmapfileheader) + sizeof(bitmapinfoheader);//到位圖資料的偏移量

bfh.bfsize = bfh.bfoffbits + bmp.bmwidthbytes * bmp.bmheight;//檔案總的大小

bfh.bftype = (word)0x4d42;

file.write(&bfh,sizeof(bitmapfileheader));//寫入位**件頭

file.write(&bih,sizeof(bitmapinfoheader));//寫入位圖資訊頭  

byte * p = new byte[bmp.bmwidthbytes * bmp.bmheight];//申請記憶體儲存位圖資料

getdibits(memdc.m_hdc, (hbitmap) membitmap.m_hobject, 0, height, p,

(lpbitmapinfo) &bih, dib_rgb_colors);//獲取位圖資料

file.writehuge(p,bmp.bmwidthbytes * bmp.bmheight);

file.close();

delete p;

memdc.selectobject(oldmembitmap);

cpaintdc dc(this);

cwnd* pwnd=getdlgitem(idc_wenben);

cdc* pdc=pwnd->getdc();

pwnd->invalidate();

pwnd->updatewindow();

pdc->rectangle(0,0,100,100);

//建立畫筆物件**************畫x和y軸

cpen* ppenred=new cpen;

ppenred->createpen(ps_solid,1,rgb(255,0,0));

cgdiobject* poldpen=pdc->selectobject(ppenred);

pdc->moveto(10,10);

pdc->lineto(10,280);

pdc->lineto(280,280);

//創 畫筆物件*****************畫x軸和y軸箭頭

cpen* ppenblue=new cpen;

ppenblue->createpen(ps_solid,1,rgb(0,0,255));

pdc->selectobject(ppenblue); pdc->moveto(5,15);

pdc->lineto(10,10);

pdc->lineto(15,15);

pdc->moveto(275,275);

pdc->lineto(280,280);

pdc->lineto(275,285);

//寫x軸刻值

cstring str;

str.format("0");

pdc->settextcolor(rgb(0,255,0));

pdc->textout(10,283,str); str.format("50");

pdc->textout(60,283,str); str.format("100");

pdc->textout(110,283,str); str.format("150");

pdc->textout(160,283,str); str.format("200");

pdc->textout(210,283,str); str.format("250");

pdc->textout(260,283,str); //寫x軸刻度線

for(int i=0;i<256;i+=5)

else

} pdc->selectobject(poldpen);

// 除新的畫筆

delete ppenred;

delete ppenblue;

Python實現截圖的函式

可指定儲存目錄.截圖名字以時間為檔名 截圖 存為jpg格式,比bmp小多的,乙個 的截圖bmp有 m多,乙個 的jpg只有 k左右.就可做乙個簡單的監控了,每 秒截一屏,放到乙個指定隱藏的資料夾裡,基本掌握機子的使用了,適合監控自家小孩的使用情況 coding cp936 import time,i...

修訂的GRE分類詞彙 截圖版

簡單直接的只有詞表,方便快速複習 詞表的組織形式上它不是字母順序 不是字母逆序 不是亂序 不是詞綴記憶法,而是按照我比較容易接受的方式,把gre單詞按照常人容易理解的方式進行了分類 詞彙選擇上比較精,幾乎見不到太多的四六級詞 考研詞,出現的都是要背的 當然了,這種選詞方法很容易出現引入過於偏門的詞彙...

C 截圖工具開發技術

最近有乙個需要擷取當前螢幕,並儲存成bmp檔案的需求。整個需求,拆分成三步 1 擷取螢幕,獲得位圖資料。2 配合bmp檔案結構資訊,將資料整合。3 對整合後的資料做操作,如儲存在本地 通過網路傳送至伺服器等。截圖首先獲得螢幕的hdc,通過getdc 這個api,接著建立乙個相容hdc,即comhdc...