P2Image

A class that provides the ability to work with color images in P2 format. NB: The format is raw text.

Note: This class supports indexing and assigning values ​​to specific pixels via 1D or 2D indexing, and provides P2 file loading/saving capabilities. According to the accepted convention, in the original description of the format inside the Netpbm package, the extension of these files should be *.pgm.

Typical usage:

// creating of empty image
auto img = new P2Image;  					
// load image from file `Lenna.pgm`
img.load(`Lenna.pgm`);   					
// change pixel at coords (10; 10), now are white
img[10, 10] = new RGBColor(255, 255, 255); 	
// get color of 11th pixel
img[10].writeln;							
// save file as `Lenna2.pgm`
img.save(`Lenna2.pgm`);						

// creating image of 10x10, pixels are black
auto img2 = new P2Image(10, 10, new RGBColor(0, 0, 0)); 
// increasing luminance by two
img2[10] = img2[10] * 2; 									
// save as `test.pgm`
img2.save(`test.pgm`);

Members

Functions

loader
void loader()
Undocumented in source. Be warned that the author may not have intended to support it.
saver
void saver()
Undocumented in source. Be warned that the author may not have intended to support it.

Mixins

__anonymous
mixin addConstructor!(PixMapFormat.PGM_TEXT)
Undocumented in source.

Inherited Members

From PixMapFile

_file
File _file;
Undocumented in source.
_header
PixMapFormat _header;
Undocumented in source.
loader
void loader()
Undocumented in source.
saver
void saver()
Undocumented in source.
load
void load(string filename)

Basic file loading procedure

save
void save(string filename)

Basic file saving procedure

isBinaryFormat
bool isBinaryFormat()

Is raw format ?

isTextFormat
bool isTextFormat()

Is text format ?

image
PixMapImage image()

Get image object as PixMapImage object

image
void image(PixMapImage image)

Set image object as PixMapImage object

Meta