Welcome, Guest. Please login or register.

Author Topic: Uncompressed Graphic Format  (Read 1175 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16867
  • Country: gb
  • Thanked: 4 times
    • Show all replies
Re: Uncompressed Graphic Format
« on: April 08, 2003, 11:17:06 PM »
Hi,

For true colour images, PPM is by far the simplest. For greyscale, PGM is the way to go.

PPM has an ASCII header with the following structure

P6


255


From a C perspective, reading the header is a simple as using

int width, height;
fscanf(fileName, "P6\n%d\n%d\n255\n", &width, &height);

The data is stored as triplets of bytes (red green and blue respectively), one for each pixel and follows immediately on the line after the '255' value.

PGM is very similar:

P5


255


So you could use the following to read the header

int width, height;
fscanf(fileName, "P5\n%d\n%d\n255\n", &width, &height);

Here the data consists of single bytes representing a grayscale value of 0-255.

I can't think of a simpler pair of formats that can be used within any serious image manipulation package.
int p; // A
 

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16867
  • Country: gb
  • Thanked: 4 times
    • Show all replies
Re: Uncompressed Graphic Format
« Reply #1 on: April 08, 2003, 11:22:46 PM »
Quote

olegil wrote:
@Karlos:

Well, if you're on the Amiga IFF is _kind_ of standard, so it makes sense to use that. Then the user could use the pictures in ANY other program. I like netpbm, though.


Perhaps, but he did ask for the simplest uncompressed formats with RGB pixels. AFAIK, you can't get simpler than ppm :-) Well, raw is simpler but not much use!
Besides, pgm/ppm is supported by all the amiga graphics apps that I know (apart from dpaint). Plus it works on lots of other platforms too.
int p; // A