且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在VC ++中将png图像转换为字节数组?

更新时间:2021-11-12 19:12:24

而iImageSize.x是未知的,它可以获得图像大小:

While iImageSize.x is unknown, it is posible to get image size:
INT32 bytes = (atlImage.GetWidth() * depth) / 8;



还可以考虑使用static_cast更改reinterpret_cast



我希望它能帮助


Also consider to change reinterpret_cast with static_cast

I hope it will help


为什么不检查 CImage :: GetWidth [ ^ ]函数给出正确的值?
Why not check if the CImage::GetWidth[^] function gives the right value?


我试过这样做,但问题是获得的值给出宽度而不是x,太大了,代码崩溃给垃圾价值。



无论是否考虑reinterpret_cast或static_cast都没有差异....
I tried doing this, But the issue is that the value obtained on giving width instead of the x, is too huge that the code crashes giving junk value.

No difference is found whether reinterpret_cast or static_cast is considered....