diff --git a/qttool/Tool.cpp b/qttool/Tool.cpp index c703000..ced9af9 100644 --- a/qttool/Tool.cpp +++ b/qttool/Tool.cpp @@ -374,13 +374,24 @@ void Tool::load_dict() { } void Tool::save_dict() { - auto dir = QFileDialog::getSaveFileName(this, "save path", "", tr("dict(*.dict)")); - if (!dir.isEmpty()) { - saved = true; - QTextCodec::setCodecForLocale(QTextCodec::codecForName("GBK")); - QByteArray ba = dir.toLocal8Bit(); - file_dict.write_dict(ba.data()); - } + QString dictfile = ui.editPath->text(); + + if (dictfile.isEmpty() == false) + { + saved = true; + QTextCodec::setCodecForLocale(QTextCodec::codecForName("GBK")); + QByteArray ba = dictfile.toLocal8Bit(); + file_dict.write_dict(ba.data()); + } + else { + auto dir = QFileDialog::getSaveFileName(this, "save path", "", tr("dict(*.dict)")); + if (!dir.isEmpty()) { + saved = true; + QTextCodec::setCodecForLocale(QTextCodec::codecForName("GBK")); + QByteArray ba = dir.toLocal8Bit(); + file_dict.write_dict(ba.data()); + } + } } void Tool::add_word() { @@ -582,31 +593,31 @@ void Tool::capture_full_screen() { _width = rc.right - rc.left; _height = rc.bottom - rc.top; //qDebug() << _width << "," << _height; - _hmdc = CreateCompatibleDC(_hdc); //创建一个与指定设备兼容的内存设备上下文环境 + _hmdc = CreateCompatibleDC(_hdc); //鍒涘缓涓涓笌鎸囧畾璁惧鍏煎鐨勫唴瀛樿澶囦笂涓嬫枃鐜 if (_hmdc == NULL) { //Tool::setlog("CreateCompatibleDC false"); //return -2; } - _hbmpscreen = CreateCompatibleBitmap(_hdc, _width, _height); //创建与指定的设备环境相关的设备兼容的位图 + _hbmpscreen = CreateCompatibleBitmap(_hdc, _width, _height); //鍒涘缓涓庢寚瀹氱殑璁惧鐜鐩稿叧鐨勮澶囧吋瀹圭殑浣嶅浘 - _holdbmp = (HBITMAP)SelectObject(_hmdc, _hbmpscreen); //选择一对象到指定的设备上下文环境中 + _holdbmp = (HBITMAP)SelectObject(_hmdc, _hbmpscreen); //閫夋嫨涓瀵硅薄鍒版寚瀹氱殑璁惧涓婁笅鏂囩幆澧冧腑 - GetObject(_hbmpscreen, sizeof(_bm), (LPSTR)&_bm); //得到指定图形对象的信息 + GetObject(_hbmpscreen, sizeof(_bm), (LPSTR)&_bm); //寰楀埌鎸囧畾鍥惧舰瀵硅薄鐨勪俊鎭 //BITMAPINFOHEADER _bih; - _bih.biBitCount = _bm.bmBitsPixel;//每个像素字节大小 + _bih.biBitCount = _bm.bmBitsPixel;//姣忎釜鍍忕礌瀛楄妭澶у皬 _bih.biCompression = BI_RGB; - _bih.biHeight = _bm.bmHeight;//高度 + _bih.biHeight = _bm.bmHeight;//楂樺害 _bih.biPlanes = 1; _bih.biSize = sizeof(BITMAPINFOHEADER); - _bih.biSizeImage = _bm.bmWidthBytes * _bm.bmHeight;//图像数据大小 - _bih.biWidth = _bm.bmWidth;//宽度 + _bih.biSizeImage = _bm.bmWidthBytes * _bm.bmHeight;//鍥惧儚鏁版嵁澶у皬 + _bih.biWidth = _bm.bmWidth;//瀹藉害 BitBlt(_hmdc, 0, 0, _width, _height, _hdc, 0, 0, SRCCOPY); //if (_pimagedata) // delete[] _pimagedata; //_pimagedata = new byte[_width*_height * 4]; _imagedata.reserve(_width * _height * 4); - //函数获取指定兼容位图的位,然后将其作一个DIB—设备无关位图(Device-Independent Bitmap)使用的指定格式复制到一个缓冲区中 + //鍑芥暟鑾峰彇鎸囧畾鍏煎浣嶅浘鐨勪綅锛岀劧鍚庡皢鍏朵綔涓涓狣IB鈥旇澶囨棤鍏充綅鍥撅紙Device-Independent Bitmap锛変娇鐢ㄧ殑鎸囧畾鏍煎紡澶嶅埗鍒颁竴涓紦鍐插尯涓 GetDIBits(_hmdc, _hbmpscreen, 0L, (DWORD)_height, (LPBYTE)_imagedata.data(), (LPBITMAPINFO)&_bih, (DWORD)DIB_RGB_COLORS); } @@ -632,7 +643,7 @@ void Tool::to_mat() { int y1 = _cap_dlg.srect.top(); for (int i = 0; i < ch; ++i) { p = _imgloc._src.ptr(i); - p2 = _imagedata.data() + (_height - i - 1 - y1) * _width * 4 + x1 * 4;//偏移 + p2 = _imagedata.data() + (_height - i - 1 - y1) * _width * 4 + x1 * 4;//鍋忕Щ for (int j = 0; j < cw; ++j) { *p++ = *p2++; *p++ = *p2++; *p++ = *p2++; *p++ = *p2++;