Logo Search packages:      
Sourcecode: inkscape version File versions

bool org::siox::SioxImage::writePPM ( const std::string  fileName  ) 

Saves this image as a simple color PPM

Write the image to a PPM file

Definition at line 587 of file siox.cpp.

References getPixel().

{

    FILE *f = fopen(fileName.c_str(), "wb");
    if (!f)
        return false;

    fprintf(f, "P6 %d %d 255\n", width, height);

    for (unsigned int y=0 ; y<height; y++)
        {
        for (unsigned int x=0 ; x<width ; x++)
            {
            unsigned int rgb = getPixel(x, y);
            //unsigned int alpha = (rgb>>24) & 0xff;
            unsigned int r = ((rgb>>16) & 0xff);
            unsigned int g = ((rgb>> 8) & 0xff);
            unsigned int b = ((rgb    ) & 0xff);
            fputc((unsigned char) r, f);
            fputc((unsigned char) g, f);
            fputc((unsigned char) b, f);
            }
        }
    fclose(f);
    return true;
}


Generated by  Doxygen 1.6.0   Back to index