如何没有高手帮小弟我解决这个有关问题,代码比较长
怎么没有高手帮我解决这个问题,代码比较长
/* =======================================================*
// cl show_rgb.cpp
// for rainbow
// img rgb file:
// line1: img_w img_h
// line2...: RRGGBBrrggbbRRGGBB in %2X%2X%2X and no space
L_o_o_n_i_e
* ========================================================*/
#include "StdAfx.h"
#include <Afxwin.h>
#include <process.h>
#include <math.h>
#include <Winuser.h>
#include <string>
#include <cstring>
#include <windows.h>
#include <stdio.h>
#define ULONG_PTR ULONG
#include "GdiPlus.h"
#pragma comment(lib, "gdiplus.lib")
using namespace Gdiplus;
//#include <iostream.h>
#include <iostream>
#define DEBUG 1
#pragma comment (lib, "User32.lib")
using namespace std;
using namespace Gdiplus;
typedef struct
{
float x;
float y;
}MY_POINT;
typedef struct
{
int r;
int g;
int b;
}MY_RGB;
typedef struct
{
MY_POINT pt;
MY_RGB rgb;
}MY_ORDER;
struct _GdiplusToken {
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
_GdiplusToken()
{
//VERIFY( GdiplusStartup(&gdiplusToken, &gdiplusStar*/tupInput, NULL) == Ok);
}
~_GdiplusToken()
{
GdiplusShutdown(gdiplusToken);
}
}GdiplusToken;
HWND hWndMain;
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
BOOL InitWindowsClass(HINSTANCE hInstance);
BOOL InitWindows(HINSTANCE hInstance,int nCmdShow);
void OnDisplayMessage(char *str);
char one_line[80],pname[80],namein[80],str[120];
int len,NN;
LPTSTR argv;
FILE *fin;
RECT RectX;
int x_shift=10,y_shift=20;
COLORREF *img;
int img_w,img_h;
unsigned int r,g,b;
MY_ORDER order[86617610];
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInst,LPSTR lpszCmdLine,int nCmdShow)
{
MSG Msg;
int i,j,k;
if ( (fin = fopen("E:\\left3.txt","r"))==NULL)
{
sprintf(str,"Can not open %s",namein); OnDisplayMessage( str);exit(0);
};
fscanf(fin,"%d %d\n",&img_w,&img_h);
if (DEBUG==1)
{
sprintf(str,"img_w=%d img_h=%d\n",img_w,img_h);
OnDisplayMessage( str);
}
img = (COLORREF *) malloc (sizeof(COLORREF) * img_w * img_h);//存储分配内存空间
if (!img)
{
sprintf(str,"No enough memory foe img"); OnDisplayMessage( str);exit(0);
}
MY_POINT point;
MY_RGB rrggbb;
int num=0;
int i_o=0;
while(!feof(fin))
{
//if (i_o>=20000) break;
if (num==0)
{
num++;
continue;
}
i_o++;
if (EOF==fscanf(fin,"%f",&point.x))break; if (EOF==fgetc(fin))break;
if (EOF==fscanf(fin,"%f",&point.y))break; if (EOF==fgetc(fin))break;
if (EOF==fscanf(fin,"%d",&rrggbb.r))break; if (EOF==fgetc(fin))break;
if (EOF==fscanf(fin,"%d",&rrggbb.g))break; if (EOF==fgetc(fin))break;
if (EOF==fscanf(fin,"%d",&rrggbb.b))break; if (EOF==fgetc(fin))break;
order[i_o-1].pt.x=point.x;
order[i_o-1].pt.y=point.y;
order[i_o-1].rgb.r=rrggbb.r;
order[i_o-1].rgb.g=rrggbb.g;
order[i_o-1].rgb.b=rrggbb.b;
}
fclose(fin);
if(!InitWindowsClass(hInstance))
return FALSE;
if(!InitWindows(hInstance,nCmdShow))
return FALSE;
ShowWindow(hWndMain,nCmdShow);
UpdateWindow(hWndMain);
while(GetMessage(&Msg,NULL,0,0))
/* =======================================================*
// cl show_rgb.cpp
// for rainbow
// img rgb file:
// line1: img_w img_h
// line2...: RRGGBBrrggbbRRGGBB in %2X%2X%2X and no space
L_o_o_n_i_e
* ========================================================*/
#include "StdAfx.h"
#include <Afxwin.h>
#include <process.h>
#include <math.h>
#include <Winuser.h>
#include <string>
#include <cstring>
#include <windows.h>
#include <stdio.h>
#define ULONG_PTR ULONG
#include "GdiPlus.h"
#pragma comment(lib, "gdiplus.lib")
using namespace Gdiplus;
//#include <iostream.h>
#include <iostream>
#define DEBUG 1
#pragma comment (lib, "User32.lib")
using namespace std;
using namespace Gdiplus;
typedef struct
{
float x;
float y;
}MY_POINT;
typedef struct
{
int r;
int g;
int b;
}MY_RGB;
typedef struct
{
MY_POINT pt;
MY_RGB rgb;
}MY_ORDER;
struct _GdiplusToken {
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
_GdiplusToken()
{
//VERIFY( GdiplusStartup(&gdiplusToken, &gdiplusStar*/tupInput, NULL) == Ok);
}
~_GdiplusToken()
{
GdiplusShutdown(gdiplusToken);
}
}GdiplusToken;
HWND hWndMain;
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
BOOL InitWindowsClass(HINSTANCE hInstance);
BOOL InitWindows(HINSTANCE hInstance,int nCmdShow);
void OnDisplayMessage(char *str);
char one_line[80],pname[80],namein[80],str[120];
int len,NN;
LPTSTR argv;
FILE *fin;
RECT RectX;
int x_shift=10,y_shift=20;
COLORREF *img;
int img_w,img_h;
unsigned int r,g,b;
MY_ORDER order[86617610];
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInst,LPSTR lpszCmdLine,int nCmdShow)
{
MSG Msg;
int i,j,k;
if ( (fin = fopen("E:\\left3.txt","r"))==NULL)
{
sprintf(str,"Can not open %s",namein); OnDisplayMessage( str);exit(0);
};
fscanf(fin,"%d %d\n",&img_w,&img_h);
if (DEBUG==1)
{
sprintf(str,"img_w=%d img_h=%d\n",img_w,img_h);
OnDisplayMessage( str);
}
img = (COLORREF *) malloc (sizeof(COLORREF) * img_w * img_h);//存储分配内存空间
if (!img)
{
sprintf(str,"No enough memory foe img"); OnDisplayMessage( str);exit(0);
}
MY_POINT point;
MY_RGB rrggbb;
int num=0;
int i_o=0;
while(!feof(fin))
{
//if (i_o>=20000) break;
if (num==0)
{
num++;
continue;
}
i_o++;
if (EOF==fscanf(fin,"%f",&point.x))break; if (EOF==fgetc(fin))break;
if (EOF==fscanf(fin,"%f",&point.y))break; if (EOF==fgetc(fin))break;
if (EOF==fscanf(fin,"%d",&rrggbb.r))break; if (EOF==fgetc(fin))break;
if (EOF==fscanf(fin,"%d",&rrggbb.g))break; if (EOF==fgetc(fin))break;
if (EOF==fscanf(fin,"%d",&rrggbb.b))break; if (EOF==fgetc(fin))break;
order[i_o-1].pt.x=point.x;
order[i_o-1].pt.y=point.y;
order[i_o-1].rgb.r=rrggbb.r;
order[i_o-1].rgb.g=rrggbb.g;
order[i_o-1].rgb.b=rrggbb.b;
}
fclose(fin);
if(!InitWindowsClass(hInstance))
return FALSE;
if(!InitWindows(hInstance,nCmdShow))
return FALSE;
ShowWindow(hWndMain,nCmdShow);
UpdateWindow(hWndMain);
while(GetMessage(&Msg,NULL,0,0))