1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <fstream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include "bitmap_image.hpp"
using namespace std;
int main () {
FILE *streamIn;
streamIn = fopen("./Lenna.bmp", "r");
if (streamIn == (FILE *)0) {
printf("File opening error ocurred. Exiting program.\n");
return 0;
}
unsigned char info[54];
fread(info, sizeof(unsigned char), 54, streamIn);
unsigned int width1 = *(int*)&info[18];
unsigned int height1 = *(int*)&info[22];
unsigned char image11[width1*height1][3];
unsigned int i = 0;
FILE *fw;
fw = fopen("blabla.txt","w");
for(i=0;i<width1*height1;i++) {
image11[i][2] = getc(streamIn);
image11[i][1] = getc(streamIn);
image11[i][0] = getc(streamIn);
//printf("pixel %d : [%d,%d,%d]\n",i+1,image11[i][0],image11[i][1],image11[i][2]);
fprintf(fw,"%d %d %d\n",image11[i][0],image11[i][1],image11[i][2]);
}
/*
fclose(streamIn);
bitmap_image image(512,512);
image_drawer draw(image);
int k = 0;
for (unsigned int d = 0; d < image.width(); ++d)
{
for (unsigned int m = 0; m < image.height(); ++m)
{
image.set_pixel(d,m,image11[k][0],image11[k][1],image11[k][2]);
k++;
}
}
image.save_image("test18_color_maps.bmp");
*/
return 0;
}
|