void get_pixels(char path[]){ int i, j=0; int offset; char depth; FILE *fp; char bmp[5]; for(i=strlen(path)-4;i<strlen(path);i++){ bmp[j]=path[i]; j++; } if(strstr(bmp, ".bmp")==NULL){ printf("\nIndicare un file .bmp come immagine!\n"); exit(1); } fp = fopen(path, "rb"); fseek(fp, 28, SEEK_SET); fscanf(fp, "%c", &depth); if(depth!=8){ printf("\nSelezionare una immagine a 8 bit!\n"); exit(2); } fseek(fp, 10, SEEK_SET); fread(&offset, sizeof(offset), 1, fp); printf("\n%d", offset); fseek(fp, offset, SEEK_SET); fread(&pixels[0], sizeof(char), 1, fp); printf("\n%d", pixels[0]); fclose(fp); }
char
unsigned char
unsigned char * pixels; //... allocate 'pixels' buffer //... fseek(fp, offset, SEEK_SET); fread(&pixels[0], sizeof(pixels[0]), 1, fp); printf("\n%d", pixels[0]);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)