C++ 处理 PPM 图像

标签 c++ image image-processing ppm

我正在尝试编写一个读取 PPM 图像的函数,该函数应该返回内容。

PPM 图像具有以下文本格式:

P3
numOfRows numOfColumns
maxColor
numOfRows-by-numOfColumns of RGB colors

由于文本格式混合了变量类型,有没有办法将这些都存储在一个数组中?我记得 C++ 不支持不同类型的数组。如果没有,那么我正在考虑定义一个类来存储 PPM 内容。

最佳答案

C++ does not support arrays with different types.

正确。


你可以:

  1. 按你说的定义一个类,像这样:C++ Push Multiple Types onto Vector或者这个:Creating a vector that holds two different data types or classes甚至这个:Vector that can have 3 different data types C++ .
  2. 拥有一个带有 void* 的通用类 C 数组(或者更好的是,一个 std::vector)。

关于C++ 处理 PPM 图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35947757/

相关文章:

c++ - 如何开始为 Linux 编写防火墙?

image - 图像的离散余弦变换 (DCT)

GitHub Enterprise 中 Markdown 文件中的图像

python - 拉普拉斯语的opencv失败并显示cv2。错误:OpenCV(4.1.2)

c++ - cpp : expected primary-expression before ‘.’ token

c++ - Windows Web 服务框架中出现无法识别的错误

image - FFmpeg : I'm looking for a way to put some blur behind the image by cutting it

c - 在c中提取BMP图像的宽度

image-processing - 使用 libswscale 缩放 YUV420P - 输出灰色图像

c++ - GLM 的 vector 矩阵乘法行为?