Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <iostream>
- #include <string.h>
- #define FILE_IN "i23.bmp"
- #define FILE_OUT "i23_enc.bmp"
- using namespace std;
- int main() {
- int i;
- char header[54], headerNew[54];
- char R0, G0, B0, R, G, B;
- int size; //correspond to number of pixels of image
- FILE *fin;
- FILE *fout;
- fin = fopen(FILE_IN, "rb");
- fout = fopen(FILE_OUT, "wb");
- if (fin == NULL) {
- printf("Cannot open file.\n");
- exit(1);
- }
- fread(header, sizeof(char), 54, fin);
- fseek(fout, 0, SEEK_SET);
- for (i = 0; i < 54; i++) {
- fputc(header[i], fout);
- }
- fread(headerNew, sizeof(char), 54, fout);
- int width = *(int*)&header[18];
- int height = *(int*)&header[22];
- int width1 = *(int*)&headerNew[18];
- int height2 = *(int*)&headerNew[22];
- cout <<width1 << " " << height2 << endl;
- fclose(fin);
- fclose(fout);
- }
Advertisement
Add Comment
Please, Sign In to add comment