Skip to content

Classic C code for converting a BMP image to PGM file format

License

Notifications You must be signed in to change notification settings

DIP-BurdwanUniversity/BMPtoPGM

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BMPtoPGM

Description

Classic C code for converting a BMP (bitmap image) image to PGM (portable graymap) file format. The code can successfully convert 1-channel, 24-bit bitmap images to its .pgm format.

Running instructions

Compile the imageio.c file using C compiler and execute the binary file in terminal.

Sample inputs and outputs are present in input and output directory respectively.

Terminal View

Screenshot of terminal

Sample runs

  • Pure 1-Channel, 24-Bit Image

    lena.bmp arrow lena.pgm
  • 3-Channel, 24-Bit Image

    colors.bmp arrow colors.pgm

Note

  • Representations above are made in formats viewable in browsers. Actual images present in output directory

  • 3-Channel, 24-Bit Image changes to 1-Channel at line:87 in file:imageio.c. Please make changes accordingly for specific channel output.

    for red channel: fwrite(&((image+i*width+j)->r),1,sizeof(unsigned char),fp);
    
    for green channel: fwrite(&((image+i*width+j)->g),1,sizeof(unsigned char),fp);
    
    for blue channel: fwrite(&((image+i*width+j)->b),1,sizeof(unsigned char),fp);
    
    

About

Classic C code for converting a BMP image to PGM file format

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages