Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > C++ Programming
|
C++ Programming General discussions for the C++ language. For questions specific to Microsoft's Visual C++ variant, see the Visual C++ forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C++ Programming section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old January 10th, 2005, 12:49 PM
ck ck is offline
Authorized User
 
Join Date: Dec 2004
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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.
Reply With Quote
  #2 (permalink)  
Old January 13th, 2005, 12:12 AM
ck ck is offline
Authorized User
 
Join Date: Dec 2004
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi,
 do some1 know how to define the image size?? means...when i write & read the image, the image in the temporary file will be the same with the original image size...means(my original image is 1.21MB, then when the program write into & read from the temporary file, it also must be the same size(1.21MB)...so, how to fix this problem???
 thanks for ur kindness for helping.....

best regards,
ck

Reply With Quote





Similar Threads
Thread Thread Starter Forum Replies Last Post
what's wrong with this code? hertendreef Visual Basic 2005 Basics 0 March 2nd, 2007 10:29 AM
What's wrong with this code? appleseed C++ Programming 2 November 25th, 2006 08:17 AM
What's wrong with this code? AlDugan XSLT 3 May 19th, 2006 12:06 PM
What Wrong Of My Code ck C++ Programming 0 January 27th, 2005 08:35 AM
what's wrong with this code? miguel.ossa ASP.NET 1.0 and 1.1 Basics 2 January 21st, 2004 11:33 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.