From 21ab4e4d0ebe80b9005446e290e0d16b61cf70e0 Mon Sep 17 00:00:00 2001 From: mi84kabv9 Date: Sat, 8 Jun 2024 17:42:40 +0800 Subject: [PATCH] ADD file via upload --- Function.h | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 Function.h diff --git a/Function.h b/Function.h new file mode 100644 index 0000000..86093d4 --- /dev/null +++ b/Function.h @@ -0,0 +1,63 @@ +#include +#include +#include +#include +#include +#include + +std::string int_to_str(int n) { + std::stringstream ss; + std::string str; + ss << n; + ss >> str; + return str; +} +int str_to_num1(const char*& str) //转换类型 +{ + if (!(str[0] == '-' || (str[0] >= '0' && str[0] <= '9'))) { + return INT_MIN; + } + int n = 0; + while (str[n] != '\0') { + n++; + } + int number = 0; + if (str[0] != '-') { + for (int i = 0; i < n; i++) { + if (!(str[i] >= '0' && str[i] <= '9')) { + return INT_MIN; + } + number += (str[i] - '0') * pow(10, n - i - 1); + } + } + if (str[0] == '-') { + for (int i = 1; i < n; i++) { + if (!(str[i] >= '0' && str[i] <= '9')) { + return INT_MIN; + } + number += (str[i] - '0') * pow(10, n - i - 1); + } + number *= -1; + } + return number; +} +int str_to_num(const std::string& str) //转换类型 +{ + const char* data = str.c_str(); + int number = str_to_num1(data); + return number; +} + +// 无背景贴图 +//void transparentimage3(IMAGE* dstimg, int x, int y, IMAGE* srcimg) //新版png +//{ +// HDC dstDC = GetImageHDC(dstimg); +// HDC srcDC = GetImageHDC(srcimg); +// int w = srcimg->getwidth(); +// int h = srcimg->getheight(); +// BLENDFUNCTION bf = { AC_SRC_OVER, 0, 255, AC_SRC_ALPHA }; +// AlphaBlend(dstDC, x, y, w, h, srcDC, 0, 0, w, h, bf); +//} + + +#pragma once