use winapi::*;
use std::ptr;
use ::core::mem::size_of;
fn get_sct(){
unsafe{
let mut HDC_screen = um::winuser::GetDC(ptr::null_mut());
let mut HDC_compatible_DC = um::wingdi::CreateCompatibleDC(HDC_screen);
let bmi = um::wingdi::BITMAPINFO {
bmiHeader: um::wingdi::BITMAPINFOHEADER {
biSize: size_of::<um::wingdi::BITMAPINFOHEADER>() as shared::minwindef::DWORD,
biWidth: 1920,
biHeight: 1080,
biPlanes: 1,
biBitCount: 32,
biCompression: um::wingdi::BI_RGB,
biSizeImage: 0,
biXPelsPerMeter: 0,
biYPelsPerMeter: 0,
biClrUsed: 0,
biClrImportant: 0,
},
bmiColors: [um::wingdi::RGBQUAD {
rgbBlue: 0,
rgbGreen: 0,
rgbRed: 0,
rgbReserved: 0
}],
};
let mut my_dib_data: *mut ctypes::c_void = ptr::null_mut();
let hbitmap: shared::windef::HBITMAP = um::wingdi::CreateDIBSection(HDC_screen,
&bmi,
um::wingdi::DIB_RGB_COLORS,
&mut my_dib_data,
ptr::null_mut(),
0);
um::wingdi::SelectObject(HDC_compatible_DC, hbitmap as shared::windef::HGDIOBJ);
let my_bit_blt: shared::minwindef::BOOL = um::wingdi::BitBlt(HDC_compatible_DC,
0,
0,
1920,
1080,
HDC_screen,
0,
0,
um::wingdi::SRCCOPY);
println!("{}", my_bit_blt);
}
}
use opencv::prelude::*;
use opencv::core::{Mat, CV_8UC4};
unsafe {
let height = 1080;
let width = 1920;
let mat = Mat::new_rows_cols_with_data(
height,
width,
CV_8UC4,
my_dib_data,
Mat_AUTO_STEP
).unwrap();
um::wingdi::DeleteObject(hbitmap as shared::windef::HGDIOBJ);
um::wingdi::DeleteDC(HDC_compatible_DC);
um::winuser::ReleaseDC(ptr::null_mut(), HDC_screen);
}