websdk返回的字符串用cJson库生成
This commit is contained in:
parent
bbdf86a24e
commit
dbe4fda9aa
|
@ -827,6 +827,38 @@ namespace ver_2
|
|||
return n;
|
||||
}
|
||||
|
||||
static bool GetColor(const std::string& colorText, HGUInt &r, HGUInt &g, HGUInt &b)
|
||||
{
|
||||
if (7 != colorText.size())
|
||||
return false;
|
||||
|
||||
if ('#' != colorText[0])
|
||||
return false;
|
||||
for (int i = 1; i < (int)colorText.size(); ++i)
|
||||
{
|
||||
if ((colorText[i] >= '0' && colorText[i] <= '9') || (colorText[i] >= 'a' && colorText[i] <= 'f')
|
||||
|| (colorText[i] >= 'A' && colorText[i] <= 'F'))
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
char colorR[3] = { 0 };
|
||||
char colorG[3] = { 0 };
|
||||
char colorB[3] = { 0 };
|
||||
strncpy(colorR, colorText.c_str() + 1, 2);
|
||||
strncpy(colorG, colorText.c_str() + 3, 2);
|
||||
strncpy(colorB, colorText.c_str() + 5, 2);
|
||||
r = htoi(colorR);
|
||||
g = htoi(colorG);
|
||||
b = htoi(colorB);
|
||||
return true;
|
||||
}
|
||||
|
||||
int ManagerV2::LocalImageAddWatermark(const std::string& imagePath, const std::string& text, const std::string& textColor, int textOpacity, const std::string& textPos,
|
||||
int marginLeft, int marginTop, int marginRight, int marginBottom, int locationX, int locationY, const std::string& fontName,
|
||||
int fontSize, bool fontBold, bool fontUnderline, bool fontItalic, bool fontStrikeout, std::string& outImagePath, std::string& errInfo)
|
||||
|
@ -834,7 +866,7 @@ namespace ver_2
|
|||
outImagePath.clear();
|
||||
errInfo = "错误";
|
||||
|
||||
if (imagePath.empty() || text.empty() || 7 != textColor.size() || textOpacity < 0 || textOpacity > 255 || marginLeft < 0 || marginTop < 0
|
||||
if (imagePath.empty() || text.empty() || textColor.empty() || textOpacity < 0 || textOpacity > 255 || marginLeft < 0 || marginTop < 0
|
||||
|| marginRight < 0 || marginBottom < 0 || fontName.empty() || fontSize <= 0)
|
||||
return -1;
|
||||
|
||||
|
@ -864,31 +896,12 @@ namespace ver_2
|
|||
return -1;
|
||||
}
|
||||
|
||||
if ('#' != textColor[0])
|
||||
return -1;
|
||||
for (int i = 1; i < (int)textColor.size(); ++i)
|
||||
HGUInt r, g, b;
|
||||
if (!GetColor(textColor, r, g, b))
|
||||
{
|
||||
if ((textColor[i] >= '0' && textColor[i] <= '9') || (textColor[i] >= 'a' && textColor[i] <= 'f')
|
||||
|| (textColor[i] >= 'A' && textColor[i] <= 'F'))
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
char colorR[3] = { 0 };
|
||||
char colorG[3] = { 0 };
|
||||
char colorB[3] = { 0 };
|
||||
strncpy(colorR, textColor.c_str() + 1, 2);
|
||||
strncpy(colorG, textColor.c_str() + 3, 2);
|
||||
strncpy(colorB, textColor.c_str() + 5, 2);
|
||||
HGUInt r = htoi(colorR);
|
||||
HGUInt g = htoi(colorG);
|
||||
HGUInt b = htoi(colorB);
|
||||
|
||||
int ret = -1;
|
||||
HGImage image = NULL;
|
||||
HGImgFmt_LoadImage(imagePath.c_str(), 0, NULL, 0, HGBASE_IMGORIGIN_TOP, &image);
|
||||
|
@ -962,6 +975,50 @@ namespace ver_2
|
|||
return ret;
|
||||
}
|
||||
|
||||
int ManagerV2::LocalImageDecontamination(const std::string& imagePath, const std::string mode, const std::string& color,
|
||||
int x, int y, int width, int height, std::string& outImagePath, std::string& errInfo)
|
||||
{
|
||||
outImagePath.clear();
|
||||
errInfo = "错误";
|
||||
|
||||
if (imagePath.empty() || mode.empty() || color.empty() || x < 0 || y < 0 || width <= 0 || height <= 0)
|
||||
return -1;
|
||||
if ("inside" != mode && "outside" != mode)
|
||||
return -1;
|
||||
|
||||
HGUInt r, g, b;
|
||||
if (!GetColor(color, r, g, b))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ret = -1;
|
||||
HGImage image = NULL;
|
||||
HGImgFmt_LoadImage(imagePath.c_str(), 0, NULL, 0, HGBASE_IMGORIGIN_TOP, &image);
|
||||
if (NULL != image)
|
||||
{
|
||||
HGUInt decoType = HGIMGPROC_DECOTYPE_INSIDE;
|
||||
if ("outside" == mode)
|
||||
decoType = HGIMGPROC_DECOTYPE_OUTSIDE;
|
||||
|
||||
if (HGBASE_ERR_OK == HGImgProc_ImageDecontamination(image, image, decoType, x, y,
|
||||
width, height, HG_MAKECOLOR(r, g, b, 0)))
|
||||
{
|
||||
if (0 == SaveImage(image, outImagePath))
|
||||
{
|
||||
m_saveFilePathList.push_back(outImagePath);
|
||||
RestoreSaveFilePathList(m_saveFilePathList);
|
||||
errInfo.clear();
|
||||
ret = 0;
|
||||
}
|
||||
}
|
||||
|
||||
HGBase_DestroyImage(image);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int ManagerV2::UploadLocalFile(const std::string& filePath, const std::string& remoteFilePath, const std::string& uploadMode,
|
||||
const std::string& httpHost, int httpPort, const std::string& httpPath, const std::string& ftpUser, const std::string& ftpPassword,
|
||||
const std::string& ftpHost, int ftpPort, std::string& errInfo)
|
||||
|
|
|
@ -170,6 +170,9 @@ namespace ver_2
|
|||
int LocalImageAddWatermark(const std::string& imagePath, const std::string& text, const std::string& textColor, int textOpacity, const std::string& textPos,
|
||||
int marginLeft, int marginTop, int marginRight, int marginBottom, int locationX, int locationY, const std::string& fontName,
|
||||
int fontSize, bool fontBold, bool fontUnderline, bool fontItalic, bool fontStrikeout, std::string& outImagePath, std::string& errInfo);
|
||||
// 去污
|
||||
int LocalImageDecontamination(const std::string& imagePath, const std::string mode, const std::string& color,
|
||||
int x, int y, int width, int height, std::string& outImagePath, std::string& errInfo);
|
||||
// 上传文件
|
||||
int UploadLocalFile(const std::string& filePath, const std::string& remoteFilePath, const std::string& uploadMode,
|
||||
const std::string &httpHost, int httpPort, const std::string& httpPath, const std::string &ftpUser, const std::string& ftpPassword,
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -28,7 +28,6 @@ namespace ver_2
|
|||
private:
|
||||
static void SaneEvent2(int code, const char* str, bool err, void* param);
|
||||
static void SaneImageCallback2(const char* path, void* param);
|
||||
static std::string strToJson(const std::string str);
|
||||
bool ShakeHand(const std::string& head);
|
||||
void Pong();
|
||||
bool SendResponse(const HGByte* data, HGUInt size, HGBool text);
|
||||
|
|
Loading…
Reference in New Issue