Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void image_scan_display::draw_current_image(CDCHandle& dc)
- {
- cv::Mat image(processor_.get_canvas());
- CBitmap bmp;
- create_bitmap_rgb(dc, bmp, image.cols, image.rows, image.ptr());
- CDCHandle mem_dc;
- mem_dc.CreateCompatibleDC(dc);
- HBITMAP old_bmp(mem_dc.SelectBitmap(bmp));
- dc.BitBlt(layout_.image.left
- , layout_.image.top
- , image.cols
- , image.rows
- , mem_dc
- , 0
- , 0
- , SRCCOPY);
- mem_dc.SelectBitmap(old_bmp);
- mem_dc.DeleteDC();
- if (draw_selection_) {
- dc.InvertRect(CRect(mouse_down_point_, mouse_up_point_));
- dc.FrameRect(CRect(mouse_down_point_, mouse_up_point_)
- , AtlGetStockBrush(WHITE_BRUSH));
- }
- }
- // ------------------------------------------------------------------------------------------------
- inline void create_bitmap_rgb(CDCHandle& dc
- , CBitmap& bmp
- , LONG width
- , LONG height
- , uint8_t const* data)
- {
- BITMAPINFO bi = { 0 };
- bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- bi.bmiHeader.biWidth = static_cast<LONG>(width);
- bi.bmiHeader.biHeight = static_cast<LONG>(-height);
- bi.bmiHeader.biPlanes = 1;
- bi.bmiHeader.biBitCount = 24;
- bi.bmiHeader.biCompression = BI_RGB;
- bmp.CreateDIBitmap(dc
- , &bi.bmiHeader
- , CBM_INIT
- , data
- , &bi
- , DIB_RGB_COLORS);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement