如何在Microsoft非托管C ++中将jpeg文件读入字节数组? [英] How do I read a jpeg file into a byte array in Microsoft unmanaged C++?

查看:65
本文介绍了如何在Microsoft非托管C ++中将jpeg文件读入字节数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我上次做任何C ++编码已经很多年了。

我用VS非托管C ++编写。



这是可能是一个非常基本的问题。



如何将位图或jpeg文件读入字节数组?

(字节是typedef' d为unsigned char)



谢谢,

JohnB

It's been many years since I last did any C++ coding.
I'm writing in VS unmanaged C++.

This is probably a pretty basic question.

How do I read either a bitmap or jpeg file into a byte array?
(Byte is typedef'd as "unsigned char")

Thanks,
JohnB

推荐答案

阅读文章。



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



如果你使用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+).


这篇关于如何在Microsoft非托管C ++中将jpeg文件读入字节数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆