谁可以帮我将以下的C算法换成DELPHI!(200分)

  • 主题发起人 主题发起人 gdtkd
  • 开始时间 开始时间
G

gdtkd

Unregistered / Unconfirmed
GUEST, unregistred user!
谁可以帮我将以下的C算法换成DELPHI!
谢谢!

//-------------------------------------------------------------
#include "stdafx.h"
#include <stdlib.h>
#include <iostream.h>
#include <memory.h>
#include <math.h>
#include <stdio.h>
#include <string.h>

#define ENGLISH 0
#define CHINESE 1
#define FILENAME_MAX_LENGTH 256 //&amp;Icirc;&amp;Auml;&amp;frac14;&amp;thorn;&amp;Atilde;&amp;ucirc;×&amp;icirc;&amp;sup3;¤256×&amp;Ouml;·&amp;ucirc;
#define READ_MAX_LENGTH 1024 //×&amp;ordf;&amp;raquo;&amp;raquo;&amp;Icirc;&amp;Auml;&amp;frac14;&amp;thorn;&amp;micro;&amp;Auml;×&amp;icirc;&amp;acute;ó&amp;sup3;¤&amp;para;&amp;Egrave;
#define WRITE_MAX_LENGTH 1024 //×&amp;ordf;&amp;raquo;&amp;raquo;&amp;Icirc;&amp;Auml;&amp;frac14;&amp;thorn;&amp;micro;&amp;Auml;×&amp;icirc;&amp;acute;ó&amp;sup3;¤&amp;para;&amp;Egrave;


int Str2Hex(char * str);

char * Convert(char * inFileName,char * outFilename )
{
FILE * outFile,* inFile;
int j;

outFile=fopen(outFilename, "wb") ;
char str[] = "0605041582000064F00000480E01";
fputs( str , outFile );

inFile=fopen(inFileName, "rb") ;
int b;

for( b = 0;b < 14;b++)
{
fseek(inFile, 118 + 36*(13-b), SEEK_SET);
if (inFile==NULL)
{
if (inFile==NULL)
cout<<inFileName<<" Input File Open Error !"<<endl ;
}else
{
while (!feof(inFile))
{
for(int i = 0;i < 9
i++)
{
char tmp[5];
fread(tmp, 4, 1, inFile);
int tmpHex = Str2Hex(tmp)

fprintf(outFile, "%02x", tmpHex);
//j += sprintf( buffer , "%d");
}
break;
}
}
}

fclose(outFile) ;
fclose(inFile) ;


FILE *otbstr;
char buffer[281];
int i, ch;

if( (otbstr = fopen( outFilename, "r" )) == NULL )
exit( 0 );

ch = fgetc( otbstr );
for( i=0
(i < 280 ) &amp;&amp
( feof( otbstr ) == 0 )
i++ )
{
buffer = (char)ch;
ch = fgetc( otbstr );
}

buffer = '/0';
printf( "%s", buffer );

fclose(otbstr)


return buffer;

}


int Str2Hex(char * str)
{
int hex = 0;

for(int i = 3
i >= 0
i--)
{
int lowByte = str%16;
hex += lowByte * pow(2, 8 - ( i + 1 ) * 2);

int highByte = str/16;
hex += highByte * pow( 2, 8 - ( i + 1 ) * 2 + 1);
}

return hex;
}


int main(int argc, char* argv[])
{

char infilename[] = "test3.bmp";
char outfilename[] = "bmp2yyr";

Convert(infilename, outfilename);

return 0;
}

 
结束问题!
 
后退
顶部