View Single Post
  #1 (permalink)  
Old December 23rd, 2004, 02:50 AM
ck ck is offline
Authorized User
 
Join Date: Dec 2004
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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.
Reply With Quote