How Computers Represent ImagesThe PPM File Format(http://cs.anu.edu.au/Student/comp1100.2006.s1/assts/asst1/ppm.html)

本文介绍了计算机屏幕显示颜色的基本原理,包括红绿蓝三基色如何组合成不同的颜色,以及像素和图片是如何通过这些颜色组成的。此外,还介绍了PPM文件格式,这是一种用于存储图像数据的简单格式。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Colours

The colours you see on a computer screen are made up of tiny red, green and blue dots. To specify a colour, you have to say how much red, how much green, and how much blue is in the colour, and the usual range is 0 .. 255 for each value. Here's some examples of colours and the RGB (red green blue) values that go with them:

White: R is 255, G is 255, B is 255
Red: R is 255, G is 0, B is 0
Orange: R is 255, G is 153, B is 62
Yellow: R is 255, G is 255, B is 0
Green: R is 0, G is 255, B is 0
Cyan: R is 0, G is 255, B is 255
Blue: R is 0, G is 0, B is 255
Purple: R is 193, G is 0, B is 159
Black: R is 0, G is 0, B is 0


Pixels and Images

Computers represent images by a grid of tiny coloured dots, called pixels. (The word "pixel" is an abbreviation of "picture element".) The pixels are so small that, when displayed on a computer screen, they appear to merge into a smooth image.

Here is an example of a very small image 4 pixels wide and 3 pixels high, along with an enlargement:

[demo image]

Here is an image which is 300 pixels wide and 184 pixels high:

The colour of each pixel in an image is typically specified by giving its RGB values.


The PPM File Format

In order to store an image, the computer doesn't merely store the colours of the pixels. It has to choose which image format to store it in. All image formats have this same general sort of structure:

Some information to say which sort of image format this is
Some header information (including width and height of image)
Pixel data (usually compressed)

PPM stands for "Portable Pix Map". It is a very old image format, that can represent any ordinary colour image. PPM files are plain text files with uncompressed image data, which means that it is very easy for a human to read the file.

Let's have a look at an actual PPM file, using the sample image

This is the PPM file representing that image:

    P3
# Created by CB-F using emacs
4 3
255
0 0 0 0 0 0 0 0 0 255 0 0
0 0 0 255 255 255 255 0 0 150 150 255
0 0 0 255 0 0 150 150 255 150 150 255

  • The P3 means that the file is a PPM file
  • the # Created by CB-F using emacs is a comment
  • the next line 4 3 gives the width and height of the file
  • the line after that 255 gives the range of values that the colours can take (0 .. 255)
  • All the numbers after that are the pixel data, starting from the top left and moving along each row, row by row. So, for example, the first 0 0 0 refers to the top left pixel having RGB values of (0,0,0), black. The last RGB values are 150 150 255, which refer to the bottom right pixel having RGB values of (150,150,255), a blue colour.

The pixel data in the file is uncompressed (and is text numerals rather than numbers), and therefore it takes up large amounts of memory. For example, the fireworks image above takes up 8K as a JPG image (JPG is another image format), but 176K as a PPM file. So PPMs have the advantage that it's easy to work with the pixel data (you can read it and it's easy to extract from the file) but they take up a lot of space. So when you are writing programs that manipulate PPMs, use small images to test your programs.


 
INFO: Sourcing build tools [INFO] Silentconfig project [INFO] Sourcing build environment [INFO] Generating kconfig for Rootfs [INFO] Silentconfig rootfs [INFO] Generating plnxtool conf [INFO] Generating workspace directory [INFO] Configuring: u-boot [INFO] devtool modify u-boot-xlnx NOTE: Starting bitbake server... NOTE: Reconnecting to bitbake server... NOTE: Retrying server connection (#1)... NOTE: Reconnecting to bitbake server... NOTE: Previous bitbake instance shutting down?, waiting to retry... NOTE: Retrying server connection (#2)... WARNING: Invalid mirror variable value for PREMIRRORS: ['cvs://.*/.*', 'file:///proj/yocto/daily-downloads_2020/', 'svn://.*/.*', 'file:///proj/yocto/daily-downloads_2020/', 'git://.*/.*', 'file:///proj/yocto/daily-downloads_2020/', 'gitsm://.*/.*', 'file:///proj/yocto/daily-downloads_2020/', 'hg://.*/.*', 'file:///proj/yocto/daily-downloads_2020/', 'bzr://.*/.*', 'file:///proj/yocto/daily-downloads_2020/', 'p4://.*/.*', 'file:///proj/yocto/daily-downloads_2020/', 'osc://.*/.*', 'file:///proj/yocto/daily-downloads_2020/', 'https?$://.*/.*', 'file:///proj/yocto/daily-downloads_2020/', 'ftp://.*/.*', 'file:///proj/yocto/daily-downloads_2020/', 'npm://.*/?.*', 'file:///proj/yocto/daily-downloads_2020/', '\\', 'git://.*/.*', 'file:///home/lvvl/hd_workspace/tools/downloads_2020.2/downloads', '\\', 'gitsm://.*/.*', 'file:///home/lvvl/hd_workspace/tools/downloads_2020.2/downloads', '\\', 'ftp://.*/.*', 'file:///home/lvvl/hd_workspace/tools/downloads_2020.2/downloads', '\\', 'http://.*/.*', 'file:///home/lvvl/hd_workspace/tools/downloads_2020.2/downloads', '\\', 'https://.*/.*', 'file:///home/lvvl/hd_workspace/tools/downloads_2020.2/downloads', 'git://.*/.*', 'file:///home/lvvl/hd_workspace/tools/downloads_2020.2/downloads', 'ftp://.*/.*', 'file:///home/lvvl/hd_workspace/tools/downloads_2020.2/downloads', 'http://.*/.*', 'file:///home/lvvl/hd_workspace/tools/downloads_2020.2/downloads', 'https://.*/.*', 'file:///home/lvvl/hd_workspace/tools/downloads_2020.2/downloads', 'git://.*/.*', 'http://petalinux.xilinx.com/sswreleases/rel-v2020/downloads', 'ftp://.*/.*', 'http://petalinux.xilinx.com/sswreleases/rel-v2020/downloads', 'http://.*/.*', 'http://petalinux.xilinx.com/sswreleases/rel-v2020/downloads', 'https://.*/.*', 'http://petalinux.xilinx.com/sswreleases/rel-v2020/downloads'], should contain paired members. Parsing recipes: 100% |######################################################################################################################################################################| Time: 0:01:52 Parsing of 2995 .bb files complete (0 cached, 2995 parsed). 4265 targets, 169 skipped, 0 masked, 0 errors. Summary: There was 1 WARNING message shown. INFO: SRC_URI contains some conditional appends/prepends - will create branches to represent these WARNING: Invalid mirror variable value for PREMIRRORS: ['cvs://.*/.*', 'file:///proj/yocto/daily-downloads_2020/', 'svn://.*/.*', 'file:///proj/yocto/daily-downloads_2020/', 'git://.*/.*', 'file:///proj/yocto/daily-downloads_2020/', 'gitsm://.*/.*', 'file:///proj/yocto/daily-downloads_2020/', 'hg://.*/.*', 'file:///proj/yocto/daily-downloads_2020/', 'bzr://.*/.*', 'file:///proj/yocto/daily-downloads_2020/', 'p4://.*/.*', 'file:///proj/yocto/daily-downloads_2020/', 'osc://.*/.*', 'file:///proj/yocto/daily-downloads_2020/', 'https?$://.*/.*', 'file:///proj/yocto/daily-downloads_2020/', 'ftp://.*/.*', 'file:///proj/yocto/daily-downloads_2020/', 'npm://.*/?.*', 'file:///proj/yocto/daily-downloads_2020/', '\\', 'git://.*/.*', 'file:///home/lvvl/hd_workspace/tools/downloads_2020.2/downloads', '\\', 'gitsm://.*/.*', 'file:///home/lvvl/hd_workspace/tools/downloads_2020.2/downloads', '\\', 'ftp://.*/.*', 'file:///home/lvvl/hd_workspace/tools/downloads_2020.2/downloads', '\\', 'http://.*/.*', 'file:///home/lvvl/hd_workspace/tools/downloads_2020.2/downloads', '\\', 'https://.*/.*', 'file:///home/lvvl/hd_workspace/tools/downloads_2020.2/downloads', 'git://.*/.*', 'file:///home/lvvl/hd_workspace/tools/downloads_2020.2/downloads', 'ftp://.*/.*', 'file:///home/lvvl/hd_workspace/tools/downloads_2020.2/downloads', 'http://.*/.*', 'file:///home/lvvl/hd_workspace/tools/downloads_2020.2/downloads', 'https://.*/.*', 'file:///home/lvvl/hd_workspace/tools/downloads_2020.2/downloads', 'git://.*/.*', 'http://petalinux.xilinx.com/sswreleases/rel-v2020/downloads', 'ftp://.*/.*', 'http://petalinux.xilinx.com/sswreleases/rel-v2020/downloads', 'http://.*/.*', 'http://petalinux.xilinx.com/sswreleases/rel-v2020/downloads', 'https://.*/.*', 'http://petalinux.xilinx.com/sswreleases/rel-v2020/downloads'], should contain paired members. NOTE: Resolving any missing task queue dependencies Initialising tasks: 100% |###################################################################################################################################################################| Time: 0:00:01 Sstate summary: Wanted 0 Found 0 Missed 0 Current 0 (0% match, 0% complete) NOTE: No setscene tasks NOTE: Executing Tasks WARNING: Invalid mirror data cvs://.*/.* file:///proj/yocto/daily-downloads_2020/ \n svn://.*/.* file:///proj/yocto/daily-downloads_2020/ \n git://.*/.* file:///proj/yocto/daily-downloads_2020/ \n gitsm://.*/.* file:///proj/yocto/daily-downloads_2020/ \n hg://.*/.* file:///proj/yocto/daily-downloads_2020/ \n bzr://.*/.* file:///proj/yocto/daily-downloads_2020/ \n p4://.*/.* file:///proj/yocto/daily-downloads_2020/ \n osc://.*/.* file:///proj/yocto/daily-downloads_2020/ \n https?$://.*/.* file:///proj/yocto/daily-downloads_2020/ \n ftp://.*/.* file:///proj/yocto/daily-downloads_2020/ \n npm://.*/?.* file:///proj/yocto/daily-downloads_2020/ \n \ git://.*/.* file:///home/lvvl/hd_workspace/tools/downloads_2020.2/downloads \n \ gitsm://.*/.* file:///home/lvvl/hd_workspace/tools/downloads_2020.2/downloads \n \ ftp://.*/.* file:///home/lvvl/hd_workspace/tools/downloads_2020.2/downloads \n \ http://.*/.* file:///home/lvvl/hd_workspace/tools/downloads_2020.2/downloads \n \ https://.*/.* file:///home/lvvl/hd_workspace/tools/downloads_2020.2/downloads \n git://.*/.* file:///home/lvvl/hd_workspace/tools/downloads_2020.2/downloads \n ftp://.*/.* file:///home/lvvl/hd_workspace/tools/downloads_2020.2/downloads \n http://.*/.* file:///home/lvvl/hd_workspace/tools/downloads_2020.2/downloads \n https://.*/.* file:///home/lvvl/hd_workspace/tools/downloads_2020.2/downloads \n git://.*/.* http://petalinux.xilinx.com/sswreleases/rel-v2020/downloads \n ftp://.*/.* http://petalinux.xilinx.com/sswreleases/rel-v2020/downloads \n http://.*/.* http://petalinux.xilinx.com/sswreleases/rel-v2020/downloads \n https://.*/.* http://petalinux.xilinx.com/sswreleases/rel-v2020/downloads \n, should have paired members. ERROR: The URL: '\' is invalid and cannot be interpreted ERROR: Logfile of failure stored in: /home/lvvl/hd_workspace/b5_prj/build/tmp/work/zynqmp_generic-xilinx-linux/u-boot-xlnx/v2020.01-xilinx-v2020.2+gitAUTOINC+bb4660c33a-r0/devtooltmp-wdh0csko/temp/log.do_fetch.21136
最新发布
07-31
<think>我们正在处理Bitbake构建过程中出现的PREMIRRORS配置错误和无效URL问题。根据用户提供的引用和错误信息,我们可以分析如下: 根据引用[1],出现`ERROR: Failed to source bitbake`和`ERROR: Unable to connect to bitbake server, or start one`,这可能是由于环境配置问题或bitbake服务未正确启动。而引用[2]和[3]则分别提到了安装Yocto SDK失败和cpio命令出错的问题。引用[4]提供了安装petalinux的参考手册。 现在用户的具体问题是:Bitbake构建过程中出现关于PREMIRRORS的警告(WARNING)和错误(ERROR),具体为“Invalid mirror variable value”和“invalid URL”。 ### 分析: 在Bitbake中,`PREMIRRORS`用于指定在下载源代码之前优先使用的镜像站点。如果配置的URL无效,则会导致下载失败。 常见的错误原因包括: 1. `PREMIRRORS`配置的URL格式不正确。 2. 配置的URL不可访问(如网络问题、URL已失效等)。 3. 配置的变量值有误(如拼写错误、使用了不支持的协议等)。 ### 解决步骤: 1. **检查`PREMIRRORS`配置**: - 在Bitbake的配置中(通常在`conf/local.conf`或`conf/site.conf`等文件中),检查`PREMIRRORS`的设置。 - 确保每个URL都是有效的,并且可以访问。 2. **验证URL**: - 使用浏览器或命令行工具(如`curl`或`wget`)测试配置的URL是否可访问。 - 注意URL中使用的协议(如http, https, ftp等)是否被支持。 3. **修正无效的URL**: - 如果发现无效的URL,将其替换为有效的镜像URL。 - 可以参考官方文档或社区推荐的镜像源。 4. **清理并重新构建**: - 在修正配置后,建议清理之前的构建缓存(如删除`downloads`目录和`sstate-cache`目录),然后重新构建。 5. **检查网络设置**: - 确保构建环境可以访问互联网,特别是如果使用了外部镜像源。 ### 示例: 假设在`local.conf`中有如下配置: ```bitbake PREMIRRORS = "git://.*/.* http://my-internal-mirror.com/sources/ \n \ ftp://.*/.* http://my-internal-mirror.com/sources/" ``` 如果出现无效URL的警告,请检查`http://my-internal-mirror.com/sources/`是否可访问,并确保没有拼写错误。 ### 参考引用: - 关于Bitbake的镜像配置,可以参考Yocto项目文档中的相关章节[^1]。 - 如果问题仍然存在,可以尝试搜索类似错误,如引用[2]中提到的安装Yocto SDK失败的问题,可能也是由于网络或镜像配置问题导致的。 §§相关问题§§ 1. 如何配置Bitbake的PREMIRRORS和MIRRORS? 2. Bitbake构建中常见的网络问题有哪些? 3. 如何调试Bitbake的下载失败问题?</think>### Bitbake PREMIRRORS配置错误解决方案 #### 问题分析 在Bitbake/Yocto/Petalinux构建过程中出现`PREMIRRORS`配置错误和无效URL警告的根本原因是: 1. **镜像源配置错误**:`PREMIRRORS`变量包含格式错误的URL或不可访问的镜像地址 2. **网络访问限制**:构建环境无法访问配置的镜像服务器 3. **协议不匹配**:源URL与镜像URL的协议类型(http/https/ftp)不兼容 4. **路径错误**:镜像路径与原始文件路径不匹配 #### 解决步骤 1. **检查PREMIRRORS配置** - 打开配置文件(通常为`conf/local.conf`或`conf/site.conf`) - 查找`PREMIRRORS`变量定义: ```bitbake PREMIRRORS = " \\ git://.*/.* http://my-mirror.com/sources/ \\n \\ ftp://.*/.* http://my-mirror.com/sources/ \\n \\ https?://.*/.* http://my-mirror.com/sources/ \\ " ``` - 验证所有URL格式正确性(需包含协议头`http://`或`https://`) 2. **测试镜像可访问性** ```bash # 测试URL连通性 curl -I http://my-mirror.com/sources/ # 测试文件下载 wget http://my-mirror.com/sources/sample-file ``` 3. **修正无效URL(常见错误示例)** | 错误配置 | 正确配置 | |---|---| | `http:/mirror.com` (缺少斜杠) | `http://mirror.com/` | | `http://mirror.com` (缺少路径) | `http://mirror.com/sources/` | | `git://github.com/.*` (协议不匹配) | `https://github.com/.*` | 4. **添加备用镜像源** ```bitbake PREMIRRORS:append = " \\ https?://.*/.* https://cdn.kernel.org/pub/ \\n \\ git://git.yoctoproject.org/.* https://downloads.yoctoproject.org/mirror/ \\ " ``` 5. **启用详细日志调试** ```bash bitbake -c fetchall <recipe> -vDDD 2>&1 | grep 'mirror fetch' ``` 6. **清理缓存后重建** ```bash rm -rf downloads/* # 清除下载缓存 bitbake <image-name> --runall=fetch ``` #### 预防措施 1. 使用镜像状态检查脚本: ```bash #!/bin/bash for url in $(grep -hoP 'https?://[^ \\]*' conf/local.conf); do curl -sL -w "%{http_code} %{url_effective}\\n" "$url" -o /dev/null done ``` 2. 优先使用HTTPS协议镜像源 3. 定期更新镜像配置(参考[Xilinx官方镜像列表](https://docs.xilinx.com/r/en-US/ug1144-petalinux-tools-reference-guide/Setting-Up-Your-Environment) [^4]) > **关键提示**:当出现`Invalid mirror variable value`错误时,99%的情况是URL格式错误或路径缺失结尾斜杠`/`,需特别注意正则表达式中的协议匹配[^1][^2]。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值