我想把 png 转成 txt 的,然后发现 png 中的透明背景色那些的,被默认转成黑色的了,能不能将 PNG 中但凡是透明色的,可以转成我自己指定的颜色(比如白色)的?谢谢
#include <stdio.h>
int main()
{
initgraph(500, 500, 1);
loadimage(NULL, _T("1.png"));
int a = 0;
ofstream out("1.txt", ios::out);
if (!out)
{
cout << "未找到1.txt" << endl;
exit(0);
}
for (int i = 0; i < 500; i++)
{
for (int j = 0; j < 500; j++)
{
a = getpixel(j, i);
out << hex << a << " ";
}
}
return 0;
}