@@ -11,22 +11,22 @@ int jpeg_to_bmp(const char *input_filename, const char *output_filename)
1111 return 1 ;
1212 }
1313
14- // Initialize JPEG decompressor object
14+ // initialize JPEG decompressor object
1515 struct jpeg_decompress_struct cinfo ;
1616 struct jpeg_error_mgr jerr ;
1717 cinfo .err = jpeg_std_error (& jerr );
1818 jpeg_create_decompress (& cinfo );
1919
20- // Specify input file for JPEG decompressor
20+ // specify input file for JPEG decompressor
2121 jpeg_stdio_src (& cinfo , input_file );
2222 jpeg_read_header (& cinfo , TRUE);
2323 jpeg_start_decompress (& cinfo );
2424
25- // Get image dimensions
25+ // get image dimensions
2626 int width = cinfo .output_width ;
2727 int height = cinfo .output_height ;
2828
29- // Allocate memory for JPEG image data
29+ // allocate memory for JPEG image data
3030 unsigned char * jpeg_data = (unsigned char * )malloc (width * height * cinfo .output_components );
3131 if (!jpeg_data )
3232 {
@@ -36,21 +36,21 @@ int jpeg_to_bmp(const char *input_filename, const char *output_filename)
3636 return 1 ;
3737 }
3838
39- // Read JPEG image data
39+ // read JPEG image data
4040 while (cinfo .output_scanline < cinfo .output_height )
4141 {
4242 JSAMPROW row_pointer = & jpeg_data [(cinfo .output_height - cinfo .output_scanline - 1 ) * width * cinfo .output_components ];
4343 jpeg_read_scanlines (& cinfo , & row_pointer , 1 );
4444 }
4545
46- // Finish decompression
46+ // finish decompression
4747 jpeg_finish_decompress (& cinfo );
4848
49- // Close JPEG file
49+ // close JPEG file
5050 fclose (input_file );
5151 jpeg_destroy_decompress (& cinfo );
5252
53- // Open output BMP file for writing
53+ // open output BMP file for writing
5454 FILE * output_file = fopen (output_filename , "wb" );
5555 if (!output_file )
5656 {
@@ -59,23 +59,23 @@ int jpeg_to_bmp(const char *input_filename, const char *output_filename)
5959 return 1 ;
6060 }
6161
62- // Write BMP header
62+ // write BMP header
6363 unsigned char bmp_header [54 ] = {
64- 'B' , 'M' , // Signature
65- 0 , 0 , 0 , 0 , // File size (to be filled later)
66- 0 , 0 , 0 , 0 , // Reserved
67- 54 , 0 , 0 , 0 , // Offset to pixel data
68- 40 , 0 , 0 , 0 , // Header size
69- 0 , 0 , 0 , 0 , // Image width (to be filled later)
70- 0 , 0 , 0 , 0 , // Image height (to be filled later)
71- 1 , 0 , // Number of color planes
72- 24 , 0 , // Bits per pixel (3 bytes)
73- 0 , 0 , 0 , 0 , // Compression method
74- 0 , 0 , 0 , 0 , // Image size (can be 0)
75- 0 , 0 , 0 , 0 , // Horizontal resolution (can be 0)
76- 0 , 0 , 0 , 0 , // Vertical resolution (can be 0)
77- 0 , 0 , 0 , 0 , // Number of colors in palette (0 for 24-bit)
78- 0 , 0 , 0 , 0 // Number of important colors (can be 0)
64+ 'B' , 'M' , // signature
65+ 0 , 0 , 0 , 0 , // file size (to be filled later)
66+ 0 , 0 , 0 , 0 , // reserved
67+ 54 , 0 , 0 , 0 , // offset to pixel data
68+ 40 , 0 , 0 , 0 , // header size
69+ 0 , 0 , 0 , 0 , // image width (to be filled later)
70+ 0 , 0 , 0 , 0 , // image height (to be filled later)
71+ 1 , 0 , // number of color planes
72+ 24 , 0 , // bits per pixel (3 bytes)
73+ 0 , 0 , 0 , 0 , // compression method
74+ 0 , 0 , 0 , 0 , // image size (can be 0)
75+ 0 , 0 , 0 , 0 , // horizontal resolution (can be 0)
76+ 0 , 0 , 0 , 0 , // vertical resolution (can be 0)
77+ 0 , 0 , 0 , 0 , // number of colors in palette (0 for 24-bit)
78+ 0 , 0 , 0 , 0 // number of important colors (can be 0)
7979 };
8080
8181 int bmp_file_size = sizeof (bmp_header ) + width * height * 3 ;
@@ -94,7 +94,7 @@ int jpeg_to_bmp(const char *input_filename, const char *output_filename)
9494
9595 fwrite (bmp_header , sizeof (unsigned char ), sizeof (bmp_header ), output_file );
9696
97- // Write BMP image data
97+ // write BMP image data
9898 for (int y = height - 1 ; y >= 0 ; y -- )
9999 {
100100 for (int x = 0 ; x < width ; x ++ )
@@ -105,7 +105,7 @@ int jpeg_to_bmp(const char *input_filename, const char *output_filename)
105105 fwrite (& jpeg_data [jpeg_index + 0 ], sizeof (unsigned char ), 1 , output_file ); // Red
106106 }
107107
108- // Write padding if necessary (multiple of 4 bytes)
108+ // write padding if necessary (multiple of 4 bytes)
109109 for (int p = 0 ; p < (4 - (width * 3 ) % 4 ) % 4 ; p ++ )
110110 {
111111 fputc (0 , output_file );
0 commit comments