修改HGImage的默认DPI为0

This commit is contained in:
luoliangyi 2023-02-27 15:05:40 +08:00
parent f124154249
commit 855c02056d
5 changed files with 22 additions and 22 deletions

View File

@ -26,8 +26,8 @@ struct HGImageImpl
m_top = 0; m_top = 0;
m_right = 0; m_right = 0;
m_bottom = 0; m_bottom = 0;
m_xDpi = 96; m_xDpi = 0;
m_yDpi = 96; m_yDpi = 0;
} }
~HGImageImpl() ~HGImageImpl()
@ -174,7 +174,7 @@ HGResult HGAPI HGBase_CreateImage(HGUInt width, HGUInt height, HGUInt type, HGUI
} }
else else
{ {
hBmp = CreateHBITMAP(width, height, type, origin, 96, 96, &data); hBmp = CreateHBITMAP(width, height, type, origin, 0, 0, &data);
if (NULL == hBmp) if (NULL == hBmp)
return HGBASE_ERR_OUTOFMEMORY; return HGBASE_ERR_OUTOFMEMORY;
else else
@ -206,8 +206,8 @@ HGResult HGAPI HGBase_CreateImage(HGUInt width, HGUInt height, HGUInt type, HGUI
imageImpl->m_top = 0; imageImpl->m_top = 0;
imageImpl->m_right = imageImpl->m_width; imageImpl->m_right = imageImpl->m_width;
imageImpl->m_bottom = imageImpl->m_height; imageImpl->m_bottom = imageImpl->m_height;
imageImpl->m_xDpi = 96; imageImpl->m_xDpi = 0;
imageImpl->m_yDpi = 96; imageImpl->m_yDpi = 0;
*image = (HGImage)imageImpl; *image = (HGImage)imageImpl;
return HGBASE_ERR_OK; return HGBASE_ERR_OK;
@ -265,8 +265,8 @@ HGResult HGAPI HGBase_CreateImageWithData(HGByte* data, const HGImageInfo* info,
imageImpl->m_top = 0; imageImpl->m_top = 0;
imageImpl->m_right = imageImpl->m_width; imageImpl->m_right = imageImpl->m_width;
imageImpl->m_bottom = imageImpl->m_height; imageImpl->m_bottom = imageImpl->m_height;
imageImpl->m_xDpi = 96; imageImpl->m_xDpi = 0;
imageImpl->m_yDpi = 96; imageImpl->m_yDpi = 0;
*image = (HGImage)imageImpl; *image = (HGImage)imageImpl;
return HGBASE_ERR_OK; return HGBASE_ERR_OK;

View File

@ -63,7 +63,7 @@ typedef struct
* (HBITMAP); linux系统上(HBITMAP) * (HBITMAP); linux系统上(HBITMAP)
* 2) width=width; height=height; type=type; widthStep为4字节对齐; origin=origin * 2) width=width; height=height; type=type; widthStep为4字节对齐; origin=origin
* 3) roi为{0, 0, width, height} * 3) roi为{0, 0, width, height}
* 4) xdpi=96, ydpi=96 * 4) xdpi=0, ydpi=0
*/ */
HGEXPORT HGResult HGAPI HGBase_CreateImage(HGUInt width, HGUInt height, HGUInt type, HGUInt origin, HGImage* image); HGEXPORT HGResult HGAPI HGBase_CreateImage(HGUInt width, HGUInt height, HGUInt type, HGUInt origin, HGImage* image);
@ -77,7 +77,7 @@ HGEXPORT HGResult HGAPI HGBase_CreateImage(HGUInt width, HGUInt height, HGUInt t
* 2) width=info->width; height=info->height; type=info->type; widthStep=info->widthStep; * 2) width=info->width; height=info->height; type=info->type; widthStep=info->widthStep;
* origin=info->origin * origin=info->origin
* 3) roi为{0, 0, width, height} * 3) roi为{0, 0, width, height}
* 4) xdpi=96, ydpi=96 * 4) xdpi=0, ydpi=0
*/ */
HGEXPORT HGResult HGAPI HGBase_CreateImageWithData(HGByte* data, const HGImageInfo* info, HGImage* image); HGEXPORT HGResult HGAPI HGBase_CreateImageWithData(HGByte* data, const HGImageInfo* info, HGImage* image);
@ -95,7 +95,7 @@ HGEXPORT HGResult HGAPI HGBase_CreateImageWithData(HGByte* data, const HGImageIn
* 2) width=roi->right-roi->left; height=roi->bottom-roi->top; type=type; widthStep为4字节对齐; * 2) width=roi->right-roi->left; height=roi->bottom-roi->top; type=type; widthStep为4字节对齐;
* origin=origin, origin和info->origin不一致 * origin=origin, origin和info->origin不一致
* 3) roi为{0, 0, width, height} * 3) roi为{0, 0, width, height}
* 4) xdpi=96, ydpi=96 * 4) xdpi=0, ydpi=0
*/ */
HGEXPORT HGResult HGAPI HGBase_CreateImageFromData(HGByte* data, const HGImageInfo *info, const HGImageRoi *roi, HGEXPORT HGResult HGAPI HGBase_CreateImageFromData(HGByte* data, const HGImageInfo *info, const HGImageRoi *roi,
HGUInt type, HGUInt origin, HGImage* image); HGUInt type, HGUInt origin, HGImage* image);

View File

@ -618,7 +618,7 @@ HGResult HGAPI HGImgFmt_SaveImage(HGImage image, HGUInt fmtType, const HGImgFmtS
} }
} }
HGUInt xDpi = 96, yDpi = 96; HGUInt xDpi = 0, yDpi = 0;
HGBase_GetImageDpi(image, &xDpi, &yDpi); HGBase_GetImageDpi(image, &xDpi, &yDpi);
if (HGIMGFMT_TYPE_JPEG == fmtType) if (HGIMGFMT_TYPE_JPEG == fmtType)
@ -1333,7 +1333,7 @@ HGResult HGAPI HGImgFmt_SaveImageToWriter(HGImgFmtWriter writer, HGImage image,
return HGBASE_ERR_INVALIDARG; return HGBASE_ERR_INVALIDARG;
} }
HGUInt xDpi = 96, yDpi = 96; HGUInt xDpi = 0, yDpi = 0;
HGBase_GetImageDpi(image, &xDpi, &yDpi); HGBase_GetImageDpi(image, &xDpi, &yDpi);
HGImgFmtWriterImpl* imgFmtWriterImpl = (HGImgFmtWriterImpl*)writer; HGImgFmtWriterImpl* imgFmtWriterImpl = (HGImgFmtWriterImpl*)writer;

View File

@ -220,7 +220,7 @@ HGLibDeviceImpl::HGLibDeviceImpl()
HGBase_CreateLock(&m_lock); HGBase_CreateLock(&m_lock);
m_devHandle = NULL; m_devHandle = NULL;
m_devName.clear(); m_devName.clear();
m_dpi = 96; m_dpi = 0;
m_scanning = HGFALSE; m_scanning = HGFALSE;
m_scanEvent = NULL; m_scanEvent = NULL;
m_eventFunc = NULL; m_eventFunc = NULL;
@ -1011,7 +1011,7 @@ HGBool HGLibDeviceImpl::StartScan(HGLibDeviceScanEventFunc eventFunc, HGPointer
m_imageParam = NULL; m_imageParam = NULL;
HGBase_DestroyEvent(m_scanEvent); HGBase_DestroyEvent(m_scanEvent);
m_scanEvent = NULL; m_scanEvent = NULL;
m_dpi = 96; m_dpi = 0;
} }
else else
{ {
@ -1039,7 +1039,7 @@ HGBool HGLibDeviceImpl::StopScan()
m_imageFunc = NULL; m_imageFunc = NULL;
m_imageParam = NULL; m_imageParam = NULL;
m_scanning = HGFALSE; m_scanning = HGFALSE;
m_dpi = 96; m_dpi = 0;
ret = HGTRUE; ret = HGTRUE;
} }
HGBase_LeaveLock(m_lock); HGBase_LeaveLock(m_lock);
@ -1197,7 +1197,7 @@ int HGLibDeviceImpl::sane_ex_callback(SANE_Handle hdev, int code, void* data, un
deviceImpl->m_imageFunc = NULL; deviceImpl->m_imageFunc = NULL;
deviceImpl->m_imageParam = NULL; deviceImpl->m_imageParam = NULL;
deviceImpl->m_scanning = HGFALSE; deviceImpl->m_scanning = HGFALSE;
deviceImpl->m_dpi = 96; deviceImpl->m_dpi = 0;
HGBase_LeaveLock(deviceImpl->m_lock); HGBase_LeaveLock(deviceImpl->m_lock);
if (NULL != eventFunc) if (NULL != eventFunc)

View File

@ -212,7 +212,7 @@ WebUser::WebUser(WebServer* server, HGUInt id, HGMsgPump msgPump, const std::str
m_devNameList.clear(); m_devNameList.clear();
m_devName.clear(); m_devName.clear();
m_devHandle = NULL; m_devHandle = NULL;
m_dpi = 96; m_dpi = 0;
m_scanEvent = NULL; m_scanEvent = NULL;
SANE_Int version_code = 0; SANE_Int version_code = 0;
@ -233,7 +233,7 @@ WebUser::~WebUser()
if (NULL != m_devHandle) if (NULL != m_devHandle)
{ {
m_dpi = 96; m_dpi = 0;
sane_close(m_devHandle); sane_close(m_devHandle);
m_devHandle = NULL; m_devHandle = NULL;
m_devName.clear(); m_devName.clear();
@ -285,7 +285,7 @@ void WebUser::CloseDev(const CloseDevParam* param)
if (NULL != m_devHandle) if (NULL != m_devHandle)
{ {
m_dpi = 96; m_dpi = 0;
sane_close(m_devHandle); sane_close(m_devHandle);
m_devHandle = NULL; m_devHandle = NULL;
m_devName.clear(); m_devName.clear();
@ -424,7 +424,7 @@ void WebUser::SelectDevice(cJSON* json)
if (NULL != m_devHandle) if (NULL != m_devHandle)
{ {
m_dpi = 96; m_dpi = 0;
sane_close(m_devHandle); sane_close(m_devHandle);
m_devHandle = NULL; m_devHandle = NULL;
m_devName.clear(); m_devName.clear();
@ -1287,7 +1287,7 @@ HGBool WebUser::SetParam(const char* optionName, const HGVoid* data)
HGInt WebUser::GetDpi() HGInt WebUser::GetDpi()
{ {
assert(NULL != m_devHandle); assert(NULL != m_devHandle);
HGInt dpi = 96; HGInt dpi = 0;
SANE_Int num_dev_options = 0; SANE_Int num_dev_options = 0;
sane_control_option(m_devHandle, 0, SANE_ACTION_GET_VALUE, &num_dev_options, NULL); sane_control_option(m_devHandle, 0, SANE_ACTION_GET_VALUE, &num_dev_options, NULL);
@ -1305,7 +1305,7 @@ HGInt WebUser::GetDpi()
{ {
if (SANE_TYPE_INT == desp->type) if (SANE_TYPE_INT == desp->type)
{ {
SANE_Int value = 96; SANE_Int value = 0;
sane_control_option(m_devHandle, i, SANE_ACTION_GET_VALUE, &value, NULL); sane_control_option(m_devHandle, i, SANE_ACTION_GET_VALUE, &value, NULL);
dpi = value; dpi = value;
} }