算法库支持单色位图
This commit is contained in:
parent
586a952180
commit
a910badf26
|
@ -799,11 +799,6 @@ HGResult HGAPI HGBase_ImageMirror(HGImage image, HGImage destImage)
|
|||
}
|
||||
|
||||
HGImageImpl* imageImpl = (HGImageImpl*)image;
|
||||
if (HGBASE_IMGTYPE_BINARY == imageImpl->m_type)
|
||||
{
|
||||
return HGBASE_ERR_INVALIDDATA;
|
||||
}
|
||||
|
||||
HGUInt width = imageImpl->m_width;
|
||||
HGUInt height = imageImpl->m_height;
|
||||
HGUInt type = imageImpl->m_type;
|
||||
|
@ -828,6 +823,24 @@ HGResult HGAPI HGBase_ImageMirror(HGImage image, HGImage destImage)
|
|||
|
||||
if (NULL == destImage || image == destImage)
|
||||
{
|
||||
if (HGBASE_IMGTYPE_BINARY == type)
|
||||
{
|
||||
HGImage imageTmp = NULL;
|
||||
HGResult ret = HGBase_CloneImage(image, HGBASE_IMGTYPE_GRAY, 0, &imageTmp);
|
||||
if (HGBASE_ERR_OK == ret)
|
||||
{
|
||||
ret = HGBase_ImageMirror(imageTmp, imageTmp);
|
||||
if (HGBASE_ERR_OK == ret)
|
||||
{
|
||||
ret = HGBase_CopyImage(imageTmp, image);
|
||||
}
|
||||
|
||||
HGBase_DestroyImage(imageTmp);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
HGByte* p = data + (HGUSize)top * (HGUSize)widthStep + left * channels;
|
||||
HGInt step = (HGInt)widthStep;
|
||||
if (HGBASE_IMGORIGIN_BOTTOM == origin)
|
||||
|
@ -924,6 +937,24 @@ HGResult HGAPI HGBase_ImageMirror(HGImage image, HGImage destImage)
|
|||
return HGBASE_ERR_INVALIDDATA;
|
||||
}
|
||||
|
||||
if (HGBASE_IMGTYPE_BINARY == type)
|
||||
{
|
||||
HGImage imageTmp = NULL;
|
||||
HGResult ret = HGBase_CloneImage(image, HGBASE_IMGTYPE_GRAY, 0, &imageTmp);
|
||||
if (HGBASE_ERR_OK == ret)
|
||||
{
|
||||
ret = HGBase_ImageMirror(imageTmp, imageTmp);
|
||||
if (HGBASE_ERR_OK == ret)
|
||||
{
|
||||
ret = HGBase_CopyImage(imageTmp, destImage);
|
||||
}
|
||||
|
||||
HGBase_DestroyImage(imageTmp);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
HGByte* src = data + (HGUSize)top * (HGUSize)widthStep + left * channels;
|
||||
HGInt srcStep = (HGInt)widthStep;
|
||||
if (HGBASE_IMGORIGIN_BOTTOM == origin)
|
||||
|
@ -1005,11 +1036,6 @@ HGResult HGAPI HGBase_ImageFlip(HGImage image, HGImage destImage)
|
|||
}
|
||||
|
||||
HGImageImpl* imageImpl = (HGImageImpl*)image;
|
||||
if (HGBASE_IMGTYPE_BINARY == imageImpl->m_type)
|
||||
{
|
||||
return HGBASE_ERR_INVALIDDATA;
|
||||
}
|
||||
|
||||
HGUInt width = imageImpl->m_width;
|
||||
HGUInt height = imageImpl->m_height;
|
||||
HGUInt type = imageImpl->m_type;
|
||||
|
@ -1034,6 +1060,24 @@ HGResult HGAPI HGBase_ImageFlip(HGImage image, HGImage destImage)
|
|||
|
||||
if (NULL == destImage || image == destImage)
|
||||
{
|
||||
if (HGBASE_IMGTYPE_BINARY == type)
|
||||
{
|
||||
HGImage imageTmp = NULL;
|
||||
HGResult ret = HGBase_CloneImage(image, HGBASE_IMGTYPE_GRAY, 0, &imageTmp);
|
||||
if (HGBASE_ERR_OK == ret)
|
||||
{
|
||||
ret = HGBase_ImageFlip(imageTmp, imageTmp);
|
||||
if (HGBASE_ERR_OK == ret)
|
||||
{
|
||||
ret = HGBase_CopyImage(imageTmp, image);
|
||||
}
|
||||
|
||||
HGBase_DestroyImage(imageTmp);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
HGByte* p1 = data + (HGUSize)top * (HGUSize)widthStep + left * channels;
|
||||
HGInt step1 = (HGInt)widthStep;
|
||||
HGByte* p2 = data + (HGUSize)(bottom - 1) * (HGUSize)widthStep + left * channels;
|
||||
|
@ -1110,6 +1154,24 @@ HGResult HGAPI HGBase_ImageFlip(HGImage image, HGImage destImage)
|
|||
return HGBASE_ERR_INVALIDDATA;
|
||||
}
|
||||
|
||||
if (HGBASE_IMGTYPE_BINARY == type)
|
||||
{
|
||||
HGImage imageTmp = NULL;
|
||||
HGResult ret = HGBase_CloneImage(image, HGBASE_IMGTYPE_GRAY, 0, &imageTmp);
|
||||
if (HGBASE_ERR_OK == ret)
|
||||
{
|
||||
ret = HGBase_ImageFlip(imageTmp, imageTmp);
|
||||
if (HGBASE_ERR_OK == ret)
|
||||
{
|
||||
ret = HGBase_CopyImage(imageTmp, destImage);
|
||||
}
|
||||
|
||||
HGBase_DestroyImage(imageTmp);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
HGByte* src = data + (HGUSize)top * (HGUSize)widthStep + left * channels;
|
||||
HGInt srcStep = (HGInt)widthStep;
|
||||
if (HGBASE_IMGORIGIN_BOTTOM == origin)
|
||||
|
@ -1146,11 +1208,6 @@ HGResult HGAPI HGBase_ImageRotateLeft(HGImage image, HGImage destImage)
|
|||
}
|
||||
|
||||
HGImageImpl* imageImpl = (HGImageImpl*)image;
|
||||
if (HGBASE_IMGTYPE_BINARY == imageImpl->m_type)
|
||||
{
|
||||
return HGBASE_ERR_INVALIDDATA;
|
||||
}
|
||||
|
||||
HGUInt width = imageImpl->m_width;
|
||||
HGUInt height = imageImpl->m_height;
|
||||
HGUInt type = imageImpl->m_type;
|
||||
|
@ -1189,6 +1246,34 @@ HGResult HGAPI HGBase_ImageRotateLeft(HGImage image, HGImage destImage)
|
|||
return HGBASE_ERR_INVALIDDATA;
|
||||
}
|
||||
|
||||
if (HGBASE_IMGTYPE_BINARY == type)
|
||||
{
|
||||
HGImage imageTmp1 = NULL;
|
||||
HGResult ret = HGBase_CloneImage(image, HGBASE_IMGTYPE_GRAY, 0, &imageTmp1);
|
||||
if (HGBASE_ERR_OK == ret)
|
||||
{
|
||||
HGImageInfo imgInfo;
|
||||
HGBase_GetImageInfo(imageTmp1, &imgInfo);
|
||||
|
||||
HGImage imageTmp2 = NULL;
|
||||
ret = HGBase_CreateImage(imgInfo.height, imgInfo.width, imgInfo.type, imgInfo.origin, &imageTmp2);
|
||||
if (HGBASE_ERR_OK == ret)
|
||||
{
|
||||
ret = HGBase_ImageRotateLeft(imageTmp1, imageTmp2);
|
||||
if (HGBASE_ERR_OK == ret)
|
||||
{
|
||||
ret = HGBase_CopyImage(imageTmp2, destImage);
|
||||
}
|
||||
|
||||
HGBase_DestroyImage(imageTmp2);
|
||||
}
|
||||
|
||||
HGBase_DestroyImage(imageTmp1);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint32_t channels = 1;
|
||||
if (HGBASE_IMGTYPE_BGR == type || HGBASE_IMGTYPE_RGB == type)
|
||||
channels = 3;
|
||||
|
@ -1348,11 +1433,6 @@ HGResult HGAPI HGBase_ImageRotateRight(HGImage image, HGImage destImage)
|
|||
}
|
||||
|
||||
HGImageImpl* imageImpl = (HGImageImpl*)image;
|
||||
if (HGBASE_IMGTYPE_BINARY == imageImpl->m_type)
|
||||
{
|
||||
return HGBASE_ERR_INVALIDDATA;
|
||||
}
|
||||
|
||||
HGUInt width = imageImpl->m_width;
|
||||
HGUInt height = imageImpl->m_height;
|
||||
HGUInt type = imageImpl->m_type;
|
||||
|
@ -1391,6 +1471,34 @@ HGResult HGAPI HGBase_ImageRotateRight(HGImage image, HGImage destImage)
|
|||
return HGBASE_ERR_INVALIDDATA;
|
||||
}
|
||||
|
||||
if (HGBASE_IMGTYPE_BINARY == type)
|
||||
{
|
||||
HGImage imageTmp1 = NULL;
|
||||
HGResult ret = HGBase_CloneImage(image, HGBASE_IMGTYPE_GRAY, 0, &imageTmp1);
|
||||
if (HGBASE_ERR_OK == ret)
|
||||
{
|
||||
HGImageInfo imgInfo;
|
||||
HGBase_GetImageInfo(imageTmp1, &imgInfo);
|
||||
|
||||
HGImage imageTmp2 = NULL;
|
||||
ret = HGBase_CreateImage(imgInfo.height, imgInfo.width, imgInfo.type, imgInfo.origin, &imageTmp2);
|
||||
if (HGBASE_ERR_OK == ret)
|
||||
{
|
||||
ret = HGBase_ImageRotateRight(imageTmp1, imageTmp2);
|
||||
if (HGBASE_ERR_OK == ret)
|
||||
{
|
||||
ret = HGBase_CopyImage(imageTmp2, destImage);
|
||||
}
|
||||
|
||||
HGBase_DestroyImage(imageTmp2);
|
||||
}
|
||||
|
||||
HGBase_DestroyImage(imageTmp1);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint32_t channels = 1;
|
||||
if (HGBASE_IMGTYPE_BGR == type || HGBASE_IMGTYPE_RGB == type)
|
||||
channels = 3;
|
||||
|
@ -1550,11 +1658,6 @@ HGResult HGAPI HGBase_ImageRotateLeftMirror(HGImage image, HGImage destImage)
|
|||
}
|
||||
|
||||
HGImageImpl* imageImpl = (HGImageImpl*)image;
|
||||
if (HGBASE_IMGTYPE_BINARY == imageImpl->m_type)
|
||||
{
|
||||
return HGBASE_ERR_INVALIDDATA;
|
||||
}
|
||||
|
||||
HGUInt width = imageImpl->m_width;
|
||||
HGUInt height = imageImpl->m_height;
|
||||
HGUInt type = imageImpl->m_type;
|
||||
|
@ -1593,6 +1696,34 @@ HGResult HGAPI HGBase_ImageRotateLeftMirror(HGImage image, HGImage destImage)
|
|||
return HGBASE_ERR_INVALIDDATA;
|
||||
}
|
||||
|
||||
if (HGBASE_IMGTYPE_BINARY == type)
|
||||
{
|
||||
HGImage imageTmp1 = NULL;
|
||||
HGResult ret = HGBase_CloneImage(image, HGBASE_IMGTYPE_GRAY, 0, &imageTmp1);
|
||||
if (HGBASE_ERR_OK == ret)
|
||||
{
|
||||
HGImageInfo imgInfo;
|
||||
HGBase_GetImageInfo(imageTmp1, &imgInfo);
|
||||
|
||||
HGImage imageTmp2 = NULL;
|
||||
ret = HGBase_CreateImage(imgInfo.height, imgInfo.width, imgInfo.type, imgInfo.origin, &imageTmp2);
|
||||
if (HGBASE_ERR_OK == ret)
|
||||
{
|
||||
ret = HGBase_ImageRotateLeftMirror(imageTmp1, imageTmp2);
|
||||
if (HGBASE_ERR_OK == ret)
|
||||
{
|
||||
ret = HGBase_CopyImage(imageTmp2, destImage);
|
||||
}
|
||||
|
||||
HGBase_DestroyImage(imageTmp2);
|
||||
}
|
||||
|
||||
HGBase_DestroyImage(imageTmp1);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint32_t channels = 1;
|
||||
if (HGBASE_IMGTYPE_BGR == type || HGBASE_IMGTYPE_RGB == type)
|
||||
channels = 3;
|
||||
|
@ -1753,11 +1884,6 @@ HGResult HGAPI HGBase_ImageRotateRightMirror(HGImage image, HGImage destImage)
|
|||
}
|
||||
|
||||
HGImageImpl* imageImpl = (HGImageImpl*)image;
|
||||
if (HGBASE_IMGTYPE_BINARY == imageImpl->m_type)
|
||||
{
|
||||
return HGBASE_ERR_INVALIDDATA;
|
||||
}
|
||||
|
||||
HGUInt width = imageImpl->m_width;
|
||||
HGUInt height = imageImpl->m_height;
|
||||
HGUInt type = imageImpl->m_type;
|
||||
|
@ -1796,6 +1922,34 @@ HGResult HGAPI HGBase_ImageRotateRightMirror(HGImage image, HGImage destImage)
|
|||
return HGBASE_ERR_INVALIDDATA;
|
||||
}
|
||||
|
||||
if (HGBASE_IMGTYPE_BINARY == type)
|
||||
{
|
||||
HGImage imageTmp1 = NULL;
|
||||
HGResult ret = HGBase_CloneImage(image, HGBASE_IMGTYPE_GRAY, 0, &imageTmp1);
|
||||
if (HGBASE_ERR_OK == ret)
|
||||
{
|
||||
HGImageInfo imgInfo;
|
||||
HGBase_GetImageInfo(imageTmp1, &imgInfo);
|
||||
|
||||
HGImage imageTmp2 = NULL;
|
||||
ret = HGBase_CreateImage(imgInfo.height, imgInfo.width, imgInfo.type, imgInfo.origin, &imageTmp2);
|
||||
if (HGBASE_ERR_OK == ret)
|
||||
{
|
||||
ret = HGBase_ImageRotateRightMirror(imageTmp1, imageTmp2);
|
||||
if (HGBASE_ERR_OK == ret)
|
||||
{
|
||||
ret = HGBase_CopyImage(imageTmp2, destImage);
|
||||
}
|
||||
|
||||
HGBase_DestroyImage(imageTmp2);
|
||||
}
|
||||
|
||||
HGBase_DestroyImage(imageTmp1);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint32_t channels = 1;
|
||||
if (HGBASE_IMGTYPE_BGR == type || HGBASE_IMGTYPE_RGB == type)
|
||||
channels = 3;
|
||||
|
@ -1954,11 +2108,6 @@ HGResult HGAPI HGBase_ImageRotate180(HGImage image, HGImage destImage)
|
|||
}
|
||||
|
||||
HGImageImpl* imageImpl = (HGImageImpl*)image;
|
||||
if (HGBASE_IMGTYPE_BINARY == imageImpl->m_type)
|
||||
{
|
||||
return HGBASE_ERR_INVALIDDATA;
|
||||
}
|
||||
|
||||
HGUInt width = imageImpl->m_width;
|
||||
HGUInt height = imageImpl->m_height;
|
||||
HGUInt type = imageImpl->m_type;
|
||||
|
@ -1983,6 +2132,24 @@ HGResult HGAPI HGBase_ImageRotate180(HGImage image, HGImage destImage)
|
|||
|
||||
if (NULL == destImage || image == destImage)
|
||||
{
|
||||
if (HGBASE_IMGTYPE_BINARY == type)
|
||||
{
|
||||
HGImage imageTmp = NULL;
|
||||
HGResult ret = HGBase_CloneImage(image, HGBASE_IMGTYPE_GRAY, 0, &imageTmp);
|
||||
if (HGBASE_ERR_OK == ret)
|
||||
{
|
||||
ret = HGBase_ImageRotate180(imageTmp, imageTmp);
|
||||
if (HGBASE_ERR_OK == ret)
|
||||
{
|
||||
ret = HGBase_CopyImage(imageTmp, image);
|
||||
}
|
||||
|
||||
HGBase_DestroyImage(imageTmp);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
HGByte* p1 = data + (HGUSize)top * (HGUSize)widthStep + left * channels;
|
||||
HGInt step1 = (HGInt)widthStep;
|
||||
HGByte* p2 = data + (HGUSize)(bottom - 1) * (HGUSize)widthStep + left * channels;
|
||||
|
@ -2143,6 +2310,24 @@ HGResult HGAPI HGBase_ImageRotate180(HGImage image, HGImage destImage)
|
|||
return HGBASE_ERR_INVALIDDATA;
|
||||
}
|
||||
|
||||
if (HGBASE_IMGTYPE_BINARY == type)
|
||||
{
|
||||
HGImage imageTmp = NULL;
|
||||
HGResult ret = HGBase_CloneImage(image, HGBASE_IMGTYPE_GRAY, 0, &imageTmp);
|
||||
if (HGBASE_ERR_OK == ret)
|
||||
{
|
||||
ret = HGBase_ImageRotate180(imageTmp, imageTmp);
|
||||
if (HGBASE_ERR_OK == ret)
|
||||
{
|
||||
ret = HGBase_CopyImage(imageTmp, destImage);
|
||||
}
|
||||
|
||||
HGBase_DestroyImage(imageTmp);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
HGByte* src = data + (HGUSize)top * (HGUSize)widthStep + left * channels;
|
||||
HGInt srcStep = (HGInt)widthStep;
|
||||
if (HGBASE_IMGORIGIN_BOTTOM == origin)
|
||||
|
@ -2224,11 +2409,6 @@ HGResult HGAPI HGBase_ImageGrayscale(HGImage image, HGImage destImage)
|
|||
}
|
||||
|
||||
HGImageImpl* imageImpl = (HGImageImpl*)image;
|
||||
if (HGBASE_IMGTYPE_BINARY == imageImpl->m_type)
|
||||
{
|
||||
return HGBASE_ERR_INVALIDDATA;
|
||||
}
|
||||
|
||||
HGUInt width = imageImpl->m_width;
|
||||
HGUInt height = imageImpl->m_height;
|
||||
HGUInt type = imageImpl->m_type;
|
||||
|
@ -2253,6 +2433,11 @@ HGResult HGAPI HGBase_ImageGrayscale(HGImage image, HGImage destImage)
|
|||
|
||||
if (NULL == destImage || image == destImage)
|
||||
{
|
||||
if (HGBASE_IMGTYPE_BINARY == type)
|
||||
{
|
||||
return HGBASE_ERR_OK;
|
||||
}
|
||||
|
||||
HGByte* p = data + (HGUSize)top * (HGUSize)widthStep + left * channels;
|
||||
HGInt step = (HGInt)widthStep;
|
||||
if (HGBASE_IMGORIGIN_BOTTOM == origin)
|
||||
|
@ -2323,6 +2508,11 @@ HGResult HGAPI HGBase_ImageGrayscale(HGImage image, HGImage destImage)
|
|||
return HGBASE_ERR_INVALIDDATA;
|
||||
}
|
||||
|
||||
if (HGBASE_IMGTYPE_BINARY == type)
|
||||
{
|
||||
return HGBase_CopyImage(image, destImage);
|
||||
}
|
||||
|
||||
HGByte* src = data + (HGUSize)top * (HGUSize)widthStep + left * channels;
|
||||
HGInt srcStep = (HGInt)widthStep;
|
||||
if (HGBASE_IMGORIGIN_BOTTOM == origin)
|
||||
|
@ -2402,11 +2592,6 @@ HGResult HGAPI HGBase_ReverseImage(HGImage image, HGImage destImage)
|
|||
}
|
||||
|
||||
HGImageImpl* imageImpl = (HGImageImpl*)image;
|
||||
if (HGBASE_IMGTYPE_BINARY == imageImpl->m_type)
|
||||
{
|
||||
return HGBASE_ERR_INVALIDDATA;
|
||||
}
|
||||
|
||||
HGUInt width = imageImpl->m_width;
|
||||
HGUInt height = imageImpl->m_height;
|
||||
HGUInt type = imageImpl->m_type;
|
||||
|
@ -2431,6 +2616,24 @@ HGResult HGAPI HGBase_ReverseImage(HGImage image, HGImage destImage)
|
|||
|
||||
if (NULL == destImage || image == destImage)
|
||||
{
|
||||
if (HGBASE_IMGTYPE_BINARY == type)
|
||||
{
|
||||
HGImage imageTmp = NULL;
|
||||
HGResult ret = HGBase_CloneImage(image, HGBASE_IMGTYPE_GRAY, 0, &imageTmp);
|
||||
if (HGBASE_ERR_OK == ret)
|
||||
{
|
||||
ret = HGBase_ReverseImage(imageTmp, imageTmp);
|
||||
if (HGBASE_ERR_OK == ret)
|
||||
{
|
||||
ret = HGBase_CopyImage(imageTmp, image);
|
||||
}
|
||||
|
||||
HGBase_DestroyImage(imageTmp);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
HGByte* p = data + (HGUSize)top * (HGUSize)widthStep + left * channels;
|
||||
HGInt step = (HGInt)widthStep;
|
||||
if (HGBASE_IMGORIGIN_BOTTOM == origin)
|
||||
|
@ -2499,6 +2702,24 @@ HGResult HGAPI HGBase_ReverseImage(HGImage image, HGImage destImage)
|
|||
return HGBASE_ERR_INVALIDDATA;
|
||||
}
|
||||
|
||||
if (HGBASE_IMGTYPE_BINARY == type)
|
||||
{
|
||||
HGImage imageTmp = NULL;
|
||||
HGResult ret = HGBase_CloneImage(image, HGBASE_IMGTYPE_GRAY, 0, &imageTmp);
|
||||
if (HGBASE_ERR_OK == ret)
|
||||
{
|
||||
ret = HGBase_ReverseImage(imageTmp, imageTmp);
|
||||
if (HGBASE_ERR_OK == ret)
|
||||
{
|
||||
ret = HGBase_CopyImage(imageTmp, destImage);
|
||||
}
|
||||
|
||||
HGBase_DestroyImage(imageTmp);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
HGByte* src = data + (HGUSize)top * (HGUSize)widthStep + left * channels;
|
||||
HGInt srcStep = (HGInt)widthStep;
|
||||
if (HGBASE_IMGORIGIN_BOTTOM == origin)
|
||||
|
|
|
@ -19,11 +19,6 @@ HGResult HGAPI HGImgProc_ResizeImage(HGImage image, HGImage destImage, HGUInt in
|
|||
|
||||
HGImageInfo imgInfo;
|
||||
HGBase_GetImageInfo(image, &imgInfo);
|
||||
if (HGBASE_IMGTYPE_BINARY == imgInfo.type)
|
||||
{
|
||||
return HGBASE_ERR_INVALIDDATA;
|
||||
}
|
||||
|
||||
HGImageInfo destImgInfo;
|
||||
HGBase_GetImageInfo(destImage, &destImgInfo);
|
||||
|
||||
|
@ -54,6 +49,31 @@ HGResult HGAPI HGImgProc_ResizeImage(HGImage image, HGImage destImage, HGUInt in
|
|||
return HGBase_CopyImage(image, destImage);
|
||||
}
|
||||
|
||||
if (HGBASE_IMGTYPE_BINARY == type)
|
||||
{
|
||||
HGImage imageTmp1 = NULL;
|
||||
HGResult ret = HGBase_CloneImage(image, HGBASE_IMGTYPE_GRAY, 0, &imageTmp1);
|
||||
if (HGBASE_ERR_OK == ret)
|
||||
{
|
||||
HGImage imageTmp2 = NULL;
|
||||
ret = HGBase_CreateImage(destRoiWidth, destRoiHeight, HGBASE_IMGTYPE_GRAY, imgInfo.origin, &imageTmp2);
|
||||
if (HGBASE_ERR_OK == ret)
|
||||
{
|
||||
ret = HGImgProc_ResizeImage(imageTmp1, imageTmp2, interp);
|
||||
if (HGBASE_ERR_OK == ret)
|
||||
{
|
||||
ret = HGBase_CopyImage(imageTmp2, destImage);
|
||||
}
|
||||
|
||||
HGBase_DestroyImage(imageTmp2);
|
||||
}
|
||||
|
||||
HGBase_DestroyImage(imageTmp1);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint32_t channels = 1;
|
||||
if (HGBASE_IMGTYPE_BGR == type || HGBASE_IMGTYPE_RGB == type)
|
||||
channels = 3;
|
||||
|
@ -90,12 +110,8 @@ HGResult HGAPI HGImgProc_ImageAdjustColors(HGImage image, HGImage destImage,
|
|||
|
||||
HGImageInfo imgInfo;
|
||||
HGBase_GetImageInfo(image, &imgInfo);
|
||||
if (HGBASE_IMGTYPE_BINARY == imgInfo.type)
|
||||
{
|
||||
return HGBASE_ERR_INVALIDDATA;
|
||||
}
|
||||
|
||||
HGUInt type = imgInfo.type;
|
||||
|
||||
HGByte* data = NULL;
|
||||
HGBase_GetImageData(image, &data);
|
||||
|
||||
|
@ -115,6 +131,24 @@ HGResult HGAPI HGImgProc_ImageAdjustColors(HGImage image, HGImage destImage,
|
|||
|
||||
if (NULL == destImage || image == destImage)
|
||||
{
|
||||
if (HGBASE_IMGTYPE_BINARY == type)
|
||||
{
|
||||
HGImage imageTmp = NULL;
|
||||
HGResult ret = HGBase_CloneImage(image, HGBASE_IMGTYPE_GRAY, 0, &imageTmp);
|
||||
if (HGBASE_ERR_OK == ret)
|
||||
{
|
||||
ret = HGImgProc_ImageAdjustColors(imageTmp, imageTmp, brightness, contrast, gamma);
|
||||
if (HGBASE_ERR_OK == ret)
|
||||
{
|
||||
ret = HGBase_CopyImage(imageTmp, image);
|
||||
}
|
||||
|
||||
HGBase_DestroyImage(imageTmp);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
CImageApplyAdjustColors imgApply(brightness, contrast, gamma);
|
||||
imgApply.apply(img, 0);
|
||||
}
|
||||
|
@ -141,6 +175,24 @@ HGResult HGAPI HGImgProc_ImageAdjustColors(HGImage image, HGImage destImage,
|
|||
return HGBASE_ERR_INVALIDDATA;
|
||||
}
|
||||
|
||||
if (HGBASE_IMGTYPE_BINARY == type)
|
||||
{
|
||||
HGImage imageTmp = NULL;
|
||||
HGResult ret = HGBase_CloneImage(image, HGBASE_IMGTYPE_GRAY, 0, &imageTmp);
|
||||
if (HGBASE_ERR_OK == ret)
|
||||
{
|
||||
ret = HGImgProc_ImageAdjustColors(imageTmp, imageTmp, brightness, contrast, gamma);
|
||||
if (HGBASE_ERR_OK == ret)
|
||||
{
|
||||
ret = HGBase_CopyImage(imageTmp, destImage);
|
||||
}
|
||||
|
||||
HGBase_DestroyImage(imageTmp);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
HGBase_CopyImage(image, destImage);
|
||||
|
||||
uint8_t* pDest = destData + destRoi.top * destImgInfo.widthStep + destRoi.left * channels;
|
||||
|
@ -163,10 +215,24 @@ HGResult HGAPI HGImgProc_ImageAutoCrop(HGImage image, HGBool autoCrop, HGBool de
|
|||
|
||||
HGImageInfo imgInfo;
|
||||
HGBase_GetImageInfo(image, &imgInfo);
|
||||
if (HGBASE_IMGTYPE_GRAY != imgInfo.type && HGBASE_IMGTYPE_RGB != imgInfo.type
|
||||
&& HGBASE_IMGTYPE_BGR != imgInfo.type)
|
||||
if (HGBASE_IMGTYPE_BINARY == imgInfo.type || HGBASE_IMGTYPE_RGBA == imgInfo.type
|
||||
|| HGBASE_IMGTYPE_BGRA == imgInfo.type)
|
||||
{
|
||||
return HGBASE_ERR_INVALIDDATA;
|
||||
HGImage imageTmp = NULL;
|
||||
HGResult ret = HGBase_CloneImage(image, HGBASE_IMGTYPE_RGB, 0, &imageTmp);
|
||||
if (HGBASE_ERR_OK == ret)
|
||||
{
|
||||
if (0 == destType)
|
||||
destType = imgInfo.type;
|
||||
if (0 == destOrigin)
|
||||
destOrigin = imgInfo.origin;
|
||||
|
||||
ret = HGImgProc_ImageAutoCrop(imageTmp, autoCrop, deskew, fillBlank, param,
|
||||
destWidth, destHeight, destType, destOrigin, destImage);
|
||||
HGBase_DestroyImage(imageTmp);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool convex = true;
|
||||
|
@ -217,6 +283,12 @@ HGResult HGAPI HGImgProc_ImageAutoCrop(HGImage image, HGBool autoCrop, HGBool de
|
|||
newImgInfo.type = imgInfo.type;
|
||||
newImgInfo.widthStep = (HGUInt)destImg.step;
|
||||
newImgInfo.origin = imgInfo.origin;
|
||||
|
||||
if (0 == destType)
|
||||
destType = imgInfo.type;
|
||||
if (0 == destOrigin)
|
||||
destOrigin = imgInfo.origin;
|
||||
|
||||
return HGBase_CreateImageFromData(destImg.data, &newImgInfo, NULL, destType, destOrigin, destImage);
|
||||
}
|
||||
|
||||
|
@ -229,10 +301,18 @@ HGResult HGAPI HGImgProc_ImageBlankCheck(HGImage image, const HGImgBlankCheckPar
|
|||
|
||||
HGImageInfo imgInfo;
|
||||
HGBase_GetImageInfo(image, &imgInfo);
|
||||
if (HGBASE_IMGTYPE_GRAY != imgInfo.type && HGBASE_IMGTYPE_RGB != imgInfo.type
|
||||
&& HGBASE_IMGTYPE_BGR != imgInfo.type)
|
||||
if (HGBASE_IMGTYPE_BINARY == imgInfo.type || HGBASE_IMGTYPE_RGBA == imgInfo.type
|
||||
|| HGBASE_IMGTYPE_BGRA == imgInfo.type)
|
||||
{
|
||||
return HGBASE_ERR_INVALIDDATA;
|
||||
HGImage imageTmp = NULL;
|
||||
HGResult ret = HGBase_CloneImage(image, HGBASE_IMGTYPE_RGB, 0, &imageTmp);
|
||||
if (HGBASE_ERR_OK == ret)
|
||||
{
|
||||
ret = HGImgProc_ImageBlankCheck(imageTmp, param, blank);
|
||||
HGBase_DestroyImage(imageTmp);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
HGDouble threshold = 40.0;
|
||||
|
|
|
@ -71,12 +71,11 @@ HGEXPORT HGResult HGAPI HGImgProc_ImageAdjustColors(HGImage image, HGImage destI
|
|||
* 5) param: in, 参数, 为NULL时使用默认参数
|
||||
* 6) destWidth: in, 目标图像宽度
|
||||
* 7) destHeight: in, 目标图像高度
|
||||
* 8) destType: in, 目标图像类型
|
||||
* 9) destOrigin: in, 目标图像数据排列方式
|
||||
* 8) destType: in, 目标图像类型, 0表示和image一样
|
||||
* 9) destOrigin: in, 目标图像数据排列方式, 0表示和image一样
|
||||
* 10) destImage: out, 输出的目标图像句柄
|
||||
* 说明:
|
||||
* 1) 操作的只是image的ROI区域
|
||||
* 2) 目前只支持image的类型为HGBASE_IMGTYPE_GRAY、HGBASE_IMGTYPE_RGB和HGBASE_IMGTYPE_BGR
|
||||
*/
|
||||
HGEXPORT HGResult HGAPI HGImgProc_ImageAutoCrop(HGImage image, HGBool autoCrop, HGBool deskew, HGBool fillBlank, const HGImgAutoCropParam* param,
|
||||
HGUInt destWidth, HGUInt destHeight, HGUInt destType, HGUInt destOrigin, HGImage* destImage);
|
||||
|
@ -87,7 +86,6 @@ HGEXPORT HGResult HGAPI HGImgProc_ImageAutoCrop(HGImage image, HGBool autoCrop,
|
|||
* 3) blank: out, HGTRUE为空白图像, HGFALSE为非空白图像
|
||||
* 说明:
|
||||
* 1) 操作的只是image的ROI区域
|
||||
* 2) 目前只支持image的类型为HGBASE_IMGTYPE_GRAY、HGBASE_IMGTYPE_RGB和HGBASE_IMGTYPE_BGR
|
||||
*/
|
||||
HGEXPORT HGResult HGAPI HGImgProc_ImageBlankCheck(HGImage image, const HGImgBlankCheckParam *param, HGBool *blank);
|
||||
|
||||
|
|
Loading…
Reference in New Issue