Plz Help Me Check What's Wrong Of This Code !
hi,
can some1 help me check wat wrong of my code..it have not error..but memory can't read the file..dunno y?? especially the read file...coz i want to read the image to the array...so, can some1 help me...thanks a lot, coz i rushing my project..& the due date coming soon, so plz help me :(....thanks a lot....;)below is my codes:
// Finger_Array.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "Finger_Array.h"
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <memory.h>
#include <tchar.h>
#include <wingdi.h>
#include <wchar.h>
#define MAX_SIZE 1024
#define NULL_LEN 1
#define REAL 2
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// The one and only application object
CWinApp theApp;
using namespace std;
struct Image {
int rows;
int cols;
unsigned char *Data;
unsigned char Type;
}; Image *img;
int main()
{
char Bitmap[MAX_SIZE + NULL_LEN];
int x, sz_pix;
float *fptr;
//char Name[20];
//Write text file to tmp or create tmp
/*FILE *tFile = fopen("FASS.inv", "w");
cout << "Enter the following information\n";
cout << "Name: "; gets(Name);
fprintf(tFile, "%s\n", Name);
fclose(tFile);
cout << endl;*/
//Write binary file To tmp or create tmp
FILE *Load = fopen("FASS.inv", "wb");
/*cout << "Enter the following information\n";
cout << "Name: "; gets(Name);*/
cout << "Bitmap: ";
//Open Directory
_TCHAR szFileTitle[MAX_PATH] = {0};
_TCHAR szTitle[MAX_PATH] = _TEXT("Open Dammit");
OPENFILENAME openfile;
memset(&openfile,0,sizeof(openfile));
openfile.lStructSize = sizeof(openfile);
openfile.lpstrTitle = szTitle;
openfile.Flags = OFN_FILEMUSTEXIST;
openfile.lpstrFile = szFileTitle;
openfile.nMaxFile = MAX_PATH;
openfile.lpstrFilter = ("Bitmap Files (*.bmp)\0*.bmp\0\0");
if(GetOpenFileName(&openfile) != FALSE)
{
//Read the open file
FILE *file = fopen(szFileTitle, "rb");
//Read from the open file and write to FASS.inv all the bitmap
while(!feof(file)){
fgets(Bitmap, MAX_SIZE, file);
fputs(Bitmap, Load);
}
fclose(file);
}
fclose(Load);
cout << endl << endl;
//Read tmp file
//FILE *FASS = fopen("c:\\1.bmp", "rb");
FILE *FASS = fopen(szFileTitle, "rb");
if( FASS== NULL )
printf( "The file fscanf.out was not opened\n" );
else
{
fptr = (float *)img->Data;
sz_pix = img->rows * img->cols;
for(x=0; x<sz_pix; ++x)
{
fread(fptr,sizeof(float),2,FASS);
fptr += 2;
}
//Read from tmp file and assign data to Bitmap
//Read from tmp file and assign data to Name
//fscanf(FASS, "%s\n", Name);
fseek( FASS, 0L, SEEK_SET );
fscanf(FASS, "%s\n", Bitmap);
//Print information
cout << "Information about the FASS";
//cout << "\nName: " << Name;
cout << "\nBitmap: " << Bitmap;
fclose(FASS);
}
cout << endl;
return 0;
}
__________________
ck.
|