修改HGImage的默认DPI为0
This commit is contained in:
parent
f124154249
commit
855c02056d
|
@ -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;
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue