Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
blog:x68_launcher_3 [2020/09/07 11:15] – [bmp.c / bmp.h] johnblog:x68_launcher_3 [2020/09/07 11:51] (current) john
Line 2: Line 2:
  
 ==== bmp.c / bmp.h ==== ==== bmp.c / bmp.h ====
 +
 +   * https://github.com/megatron-uk/x68klauncher/blob/master/src/bmp.c
 +   * https://github.com/megatron-uk/x68klauncher/blob/master/src/bmp.h
  
 The header includes these common files: The header includes these common files:
Line 108: Line 111:
 </code> </code>
  
-The bitmap library has a single function, __bmp_ReadImage()__, that is called in several different ways to parse BMP headersread pixel data+The bitmap library has a single function, __bmp_ReadImage()__, that is called in several different ways to parse BMP headers and subsequently read pixel data
 + 
 +The reason the function is called in two passes is to ensure that when the header data is retrieved the image does not exceeded any specific size: 
 + 
 +   * Open file 
 +   * Read BMP header 
 +   * Check BMP is correct pixel depth and size 
 +   * Read pixel data 
 + 
 + 
 +<code "C"> 
 +FILE *f; 
 +int status; 
 + 
 +f = fopen("bitmap.bmp", "rb"); 
 +if (f == NULL){ 
 +   return -1;  
 +
 + 
 +bmp = (bmpdata_t *) malloc(sizeof(bmpdata_t)); 
 +bmp->pixels = NULL; 
 +status = bmp_ReadImageHeader(f, bmp); 
 +if (status != 0){ 
 +   fclose(f); 
 +   return -1; 
 +
 + 
 +if (bmp->width > 200){ 
 +  printf("Error, image is more than 200 pixels wide!\n"); 
 +} else ( 
 +  printf("Loading pixel data\n"); 
 +  status = bmp_ReadImageData(f, bmp); 
 +
 + 
 +fclose(f); 
 +</code> 
 + 
 +---- 
 + 
 +[[blog:x68_launcher_2|<< Back (#2: Filesystem tools, data scraping)]] | [[blog:x68_launcher_4|(#4: Graphics hardware functions) Next >>]] 
 + 
  • blog/x68_launcher_3.1599473715.txt.gz
  • Last modified: 2020/09/07 11:15
  • by john