How to get bitmap pixel to store in the array
hi,
i'm a beginner of visual C++, anybody know or can teach me how to get bitmap pixel, read it, write it, then save it, then load & display it on the static control in MFC??? & all tis codes is it write in header file(.h) or source file(.cpp)??? thanks
below is the codes..but dunnno right or wrong...& it got bugs also...
struct Image {
int rows;
int colds;
unsigned char *Data;
unsigned char Type;
};
#define BASIC 0
#include <stdlib.h>
#include <memory.h>
void ReadArray(Image *Img, const char *filename)
{
FILE *fl;
int x;
fl = fopen(filename, "ra");
for(x=0; x<Img->rows; ++x)
fread(Img->Data + x*Img->cols, Img->cols,1,fl);
fclose(fl);
}
void WriteArray(Image *Img, const char *filename)
{
FILE *fl;
int y;
fl = fopen(filename, "wa");
for(y=0; y<Img->rows; ++y)
fwrite(Img->Data + y*Img->cols, Img->cols,1,fl);
fclose(fl);
}
__________________
ck.
|