且构网

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

如何在Microsoft非托管C ++中将jpeg文件读入字节数组?

更新时间:2023-11-13 10:15:46

阅读文章。



你必须首先分配一个足够大的文件数据缓冲区而不是读取它。



如果你使用jpeg那么伟大的文章 Imagestone 可能对您有所帮助。
Read this article.

You must at first allocate a buffer which is big enough for the file data and than read it in.

If you work with the jpeg the great article Imagestone may help you.


您可以阅读每个文件数据只需使用标准的 ifstream 设施(在 Windows 上你必须使用 二进制mo德的)。

另一方面,如果你需要从图像文件提取信息(例如像素颜色),那么你必须使用特定的 API (例如 GDI + 提供的那个)。
You may read every file data into a byte buffer simply using standard ifstream facilities (on Windows you have to use the "binary mode").
On the other hand, if you need to extract info (e.g. pixel colors) from an image file then you have to use a specific API (e.g. the one provided by GDI+).