联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codinghelp

您当前位置:首页 >> C/C++编程C/C++编程

日期:2019-01-06 10:13

Working with PPM Files

Raster graphics (http://en.wikipedia.org/wiki/Raster_graphics), unless vector-graphics, rely and

operate on pixels where every pixel is typically made up of an RGB value.

Portable Pixel Map (PPM)

PPM images can eithr be stored in an ASCII or in a BINARY format, see here

(http://de.wikipedia.org/wiki/Portable_Pixmap) for details. For the implementation of the task you

may select one of these formats.

An example of an ASCII ppm image loaded with a text editor looks like:

P3

# feep.ppm

4 4

15

0 0 0 0 0 0 0 0 0 15 0 15

0 0 0 0 15 7 0 0 0 0 0 0

0 0 0 0 0 0 0 15 7 0 0 0

15 0 15 0 0 0 0 0 0 0 0 0

Here the first line holds a unique image identifier (magic number), in particular, the ASCII

letters P3.

The PPM format allows for line comments that start with a # symbol.

The first three ASCII numbers following the magic number represent the image width,

height and the maximum color depth of every pixels color value.

The rest of the image is made up of ASCII numbers separated with whitespace characters -

three numbers in RED GREEN BLUE sequence per single pixel. Every single value is

between 0 and the maximum color depth (the maximum number for the latter is 255).

In order to implement the task using binary PPM images you’ll need to check the respective

file using a HEX editor (Windows: XVI32

(http://www.chmaas.handshake.de/delphi/freeware/xvi32/xvi32.htm), HxD (http://mh-nexus.de/de/hxd/),

FSHED (http://www.funduc.com/fshexedit.htm), etc.; Linux: ghex, dhex (http://www.dettus.net/dhex/),

bless (http://home.gna.org/bless/), wxhexeditor (http://www.wxhexeditor.org/), emacs, vi, etc.; MAC

OSX: Hex Fiend (http://ridiculousfish.com/hexfiend/), 0xED (http://www.suavetech.com/0xed/0xed.html),

etc.).

The structure of binary PPM images is the same as those of ASCII PPM images, however,

without comments and P6 (0x50 0x36) as magic number.

2019/1/4 Working with PPM Files

https://cis.technikum-wien.at/documents/bel/1/prg/semesterplan/tasks/imglib/ppm.html 2/2

A BINARY PPM image looks like:

P6 # unique identifier for BINARY PPM format

# some comment # an optional comment line

3 2 # image size: width and height

255 # color depth (0-255)

!@#$%^&*()_+|{}:"< # RGB pixel values in binary

TIP

In order to work with the binary format, it is highly recommended to install

and use a HEX editor.

Last updated 2015-11-05 10:09:35 CET


版权所有:留学生编程辅导网 2020 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。 站长地图

python代写
微信客服:codinghelp