新手求帮助,saveimage 存出来的文件名是乱码~~用的VS2013

===================================代码================================
#include <boost/numeric/ublas/matrix.hpp>
#include <graphics.h>
#include <iostream>
#include <stdlib.h>
#include <time.h>
#include <conio.h>
using namespace std;
using namespace boost::numeric;
extern double MatrixPrdouble(ublas::matrix<double> K, int N, double nnz, double *row_ind, double *col_prt, double *val);
int main(double ColororNot, double PodoublesorSquares)
{
ColororNot = 11;
PodoublesorSquares = 0;
double x, y;
x = GetSystemMetrics(SM_CXSCREEN);
y = GetSystemMetrics(SM_CYSCREEN);
cout << "This monitor's resolution is " << x << " x " << y << endl;
/*随机产生矩阵及CSC数组*/
//初始化变量
int A = 0, B = 100, X = 0;
int nnz = 0;
double diff = 0, col_ind_val = 0;
const double N = 50;
ublas::matrix<double> K_E(N, N);
//产生随机矩阵
for (int i = 0; i < N; i = i + 1)
{
for (int j = 0; j < N; j = j + 1)
{
//K[i][j] = rand() % (B - A + 1) + A;
X = A + B * rand() / RAND_MAX;
if (X % 2 == 0)
{
K_E(i, j) = X;
}
else if (X % 2 != 0)
{
X = 0;
K_E(i, j) = X;
}
if (K_E(i, j) != 0)
{
nnz = nnz + 1;
}
}
}
//for (double i = 0; i < N; i = i + 1)
//{
//for (double j = 0; j < N; j = j + 1)
//{
//cout << K[i][j] << " ";
//}
//cout << endl;
//}
//申请内存
double *val = (double *)malloc(sizeof(double)*nnz);
double *row_ind = (double *)malloc(sizeof(double)*nnz);
double *col_ind = (double *)malloc(sizeof(double)*nnz);
double *col_prt = (double *)malloc(sizeof(double)*(N + 1));
double *col_prt_diff = (double *)malloc(sizeof(double)*(N));
//得到CSC数组
MatrixPrdouble(K_E, N, nnz, row_ind, col_prt, val);
//for (double i = 0; i < nnz; i = i + 1)
//{
//cout << "row_ind " << row_ind[i] << endl;
//}
//for (double i = 0; i < nnz; i = i + 1)
//{
//cout << "val " << val[i] << endl;
//}
//for (double i = 0; i < N + 1; i = i + 1)
//{
//cout << "col_prt " << col_prt[i] << endl;
//}
//得到三元组
for (int i = 0; i < N; i = i + 1)
{
for (int j = col_prt[i]; j < col_prt[i + 1]; j = j + 1)
{
col_ind[j] = col_ind_val;
}
col_ind_val = col_ind_val + 1;
}
col_ind[nnz - 1] = N - 1;
/*画图*/
COLORREF Background_C = RGB(255, 255, 255);
COLORREF Line_C = RGB(0, 0, 0);
COLORREF Fill_C[11];
if (ColororNot == 0)
{
//设置颜色(彩色)
Fill_C[0] = RGB(0, 0, 255);
Fill_C[1] = RGB(0, 127, 255);
Fill_C[2] = RGB(0, 255, 255);
Fill_C[3] = RGB(0, 255, 127);
Fill_C[4] = RGB(0, 255, 0);
Fill_C[5] = RGB(127, 255, 0);
Fill_C[6] = RGB(255, 255, 0);
Fill_C[7] = RGB(255, 127, 0);
Fill_C[8] = RGB(255, 0, 0);
Fill_C[9] = RGB(255, 0, 127);
Fill_C[10] = RGB(127, 0, 255);
}
else if (ColororNot != 0)
{
//设置颜色(灰度)
Fill_C[0] = RGB(225, 225, 225);
Fill_C[1] = RGB(216, 216, 216);
Fill_C[2] = RGB(192, 192, 192);
Fill_C[3] = RGB(168, 168, 168);
Fill_C[4] = RGB(144, 144, 144);
Fill_C[5] = RGB(120, 120, 120);
Fill_C[6] = RGB(96, 96, 96);
Fill_C[7] = RGB(72, 72, 72);
Fill_C[8] = RGB(48, 48, 48);
Fill_C[9] = RGB(24, 24, 24);
Fill_C[10] = RGB(0, 0, 0);
}
//布置画布
initgraph(x, y, SHOWCONSOLE);
setbkcolor(Background_C);
cleardevice();
//画出矩阵边框
long double high_diff = 0.02 * y, length_diff = (x - (y - 2 * high_diff)) / 2;
long double offset = 0;
long double Frame_left = length_diff, Frame_top = high_diff - offset;
long double Frame_right = x - length_diff, Frame_bottom = y - high_diff - offset;
setlinecolor(Line_C);
setlinestyle(PS_SOLID, 1, NULL, 0);
rectangle(Frame_left - 1, Frame_top - 1, Frame_right + 1, Frame_bottom + 1);
rectangle(Frame_left - 2, Frame_top - 2, Frame_right + 2, Frame_bottom + 2);
rectangle(Frame_left - 3, Frame_top - 3, Frame_right + 3, Frame_bottom + 3);
//画出元素
long double zonelength = (y - 2 * high_diff) / (N);
long double Element_left = 0, Element_top = 0;
long double Element_right = 0, Element_bottom = 0;
double maxmax = val[0], minmin = val[0], maxmin;
int zonecolor = 0;
for (int i = 0; i < nnz; i = i + 1)
{
if (maxmax < val[i])
{
maxmax = val[i];
}
if (minmin > val[i])
{
minmin = val[i];
}
}
maxmin = (maxmax - minmin);
if (PodoublesorSquares == 0)
{
//方块
for (int i = 0; i < nnz; i = i + 1)
{
Element_top = Frame_top + (row_ind[i] * zonelength);
Element_bottom = Frame_top + ((row_ind[i] + 1) * zonelength);
Element_left = Frame_left + (col_ind[i] * zonelength);
Element_right = Frame_left + ((col_ind[i] + 1) * zonelength);
zonecolor = floor(10 * ((val[i] - minmin) / maxmin));
setfillcolor(Fill_C[zonecolor]);
fillrectangle(Element_left, Element_top, Element_right, Element_bottom);
//solidrectangle(Element_left, Element_top, Element_right, Element_bottom);
}
cout << "zonelength " << zonelength << endl;
cout << "N " << N << endl;
cout << " Frame_right - Frame_left " << Frame_right - Frame_left << endl;
}
else if (PodoublesorSquares != 0)
{
//点
for (int i = 0; i < nnz; i = i + 1)
{
zonecolor = floor(10 * ((val[i] - minmin) / maxmin));
putpixel(Frame_left + col_ind[i] * zonelength, Frame_top + row_ind[i] * zonelength, Fill_C[zonecolor]);
}
}
LPCTSTR Address_LPCTSTR = (LPCTSTR)"\\test.bmp";
saveimage(Address_LPCTSTR);
getchar(); // 按任意键继续
closegraph(); // 关闭图形界面
return 0;
}
double MatrixPrdouble(ublas::matrix<double> K, int N, double nnz, double *row_ind, double *col_prt, double *val)
{
//申请内存
int k = 0, h = 1;
double *col_ind_M = (double *)malloc(sizeof(double)*nnz);
//获得CSC数组
for (int j = 0; j < N; j = j + 1)
{
for (int i = 0; i < N; i = i + 1)
{
if (K(i, j) != 0)
{
val[k] = K(i, j);
row_ind[k] = i;
col_ind_M[k] = j;
k = k + 1;
}
}
}
//获得列指针
col_prt[0] = 0;
for (int i = 0; i < k; i = i + 1)
{
if (col_ind_M[i] != col_ind_M[i + 1])
{
col_prt[h] = i + 1;
h = h + 1;
}
}
col_prt[N] = nnz - 1;
//for (int i = 0; i < k; i = i + 1)
//{
//cout << "row_ind " << row_ind[i] << endl;
//}
//for (int i = 0; i < k; i = i + 1)
//{
//cout << "val " << val[i] << endl;
//}
//for (int i = 0; i < N + 1; i = i + 1)
//{
//cout << "col_prt " << col_prt[i] << endl;
//}
return 0;
}

===================================代码================================
#include <boost/numeric/ublas/matrix.hpp>
#include <graphics.h>
#include <iostream>
#include <stdlib.h>
#include <time.h>
#include <conio.h>
using namespace std;
using namespace boost::numeric;
extern double MatrixPrdouble(ublas::matrix<double> K, int N, double nnz, double *row_ind, double *col_prt, double *val);
int main(double ColororNot, double PodoublesorSquares)
{
ColororNot = 11;
PodoublesorSquares = 0;
double x, y;
x = GetSystemMetrics(SM_CXSCREEN);
y = GetSystemMetrics(SM_CYSCREEN);
cout << "This monitor's resolution is " << x << " x " << y << endl;
/*随机产生矩阵及CSC数组*/
//初始化变量
int A = 0, B = 100, X = 0;
int nnz = 0;
double diff = 0, col_ind_val = 0;
const double N = 50;
ublas::matrix<double> K_E(N, N);
//产生随机矩阵
for (int i = 0; i < N; i = i + 1)
{
for (int j = 0; j < N; j = j + 1)
{
//K[i][j] = rand() % (B - A + 1) + A;
X = A + B * rand() / RAND_MAX;
if (X % 2 == 0)
{
K_E(i, j) = X;
}
else if (X % 2 != 0)
{
X = 0;
K_E(i, j) = X;
}
if (K_E(i, j) != 0)
{
nnz = nnz + 1;
}
}
}
//for (double i = 0; i < N; i = i + 1)
//{
//for (double j = 0; j < N; j = j + 1)
//{
//cout << K[i][j] << " ";
//}
//cout << endl;
//}
//申请内存
double *val = (double *)malloc(sizeof(double)*nnz);
double *row_ind = (double *)malloc(sizeof(double)*nnz);
double *col_ind = (double *)malloc(sizeof(double)*nnz);
double *col_prt = (double *)malloc(sizeof(double)*(N + 1));
double *col_prt_diff = (double *)malloc(sizeof(double)*(N));
//得到CSC数组
MatrixPrdouble(K_E, N, nnz, row_ind, col_prt, val);
//for (double i = 0; i < nnz; i = i + 1)
//{
//cout << "row_ind " << row_ind[i] << endl;
//}
//for (double i = 0; i < nnz; i = i + 1)
//{
//cout << "val " << val[i] << endl;
//}
//for (double i = 0; i < N + 1; i = i + 1)
//{
//cout << "col_prt " << col_prt[i] << endl;
//}
//得到三元组
for (int i = 0; i < N; i = i + 1)
{
for (int j = col_prt[i]; j < col_prt[i + 1]; j = j + 1)
{
col_ind[j] = col_ind_val;
}
col_ind_val = col_ind_val + 1;
}
col_ind[nnz - 1] = N - 1;
/*画图*/
COLORREF Background_C = RGB(255, 255, 255);
COLORREF Line_C = RGB(0, 0, 0);
COLORREF Fill_C[11];
if (ColororNot == 0)
{
//设置颜色(彩色)
Fill_C[0] = RGB(0, 0, 255);
Fill_C[1] = RGB(0, 127, 255);
Fill_C[2] = RGB(0, 255, 255);
Fill_C[3] = RGB(0, 255, 127);
Fill_C[4] = RGB(0, 255, 0);
Fill_C[5] = RGB(127, 255, 0);
Fill_C[6] = RGB(255, 255, 0);
Fill_C[7] = RGB(255, 127, 0);
Fill_C[8] = RGB(255, 0, 0);
Fill_C[9] = RGB(255, 0, 127);
Fill_C[10] = RGB(127, 0, 255);
}
else if (ColororNot != 0)
{
//设置颜色(灰度)
Fill_C[0] = RGB(225, 225, 225);
Fill_C[1] = RGB(216, 216, 216);
Fill_C[2] = RGB(192, 192, 192);
Fill_C[3] = RGB(168, 168, 168);
Fill_C[4] = RGB(144, 144, 144);
Fill_C[5] = RGB(120, 120, 120);
Fill_C[6] = RGB(96, 96, 96);
Fill_C[7] = RGB(72, 72, 72);
Fill_C[8] = RGB(48, 48, 48);
Fill_C[9] = RGB(24, 24, 24);
Fill_C[10] = RGB(0, 0, 0);
}
//布置画布
initgraph(x, y, SHOWCONSOLE);
setbkcolor(Background_C);
cleardevice();
//画出矩阵边框
long double high_diff = 0.02 * y, length_diff = (x - (y - 2 * high_diff)) / 2;
long double offset = 0;
long double Frame_left = length_diff, Frame_top = high_diff - offset;
long double Frame_right = x - length_diff, Frame_bottom = y - high_diff - offset;
setlinecolor(Line_C);
setlinestyle(PS_SOLID, 1, NULL, 0);
rectangle(Frame_left - 1, Frame_top - 1, Frame_right + 1, Frame_bottom + 1);
rectangle(Frame_left - 2, Frame_top - 2, Frame_right + 2, Frame_bottom + 2);
rectangle(Frame_left - 3, Frame_top - 3, Frame_right + 3, Frame_bottom + 3);
//画出元素
long double zonelength = (y - 2 * high_diff) / (N);
long double Element_left = 0, Element_top = 0;
long double Element_right = 0, Element_bottom = 0;
double maxmax = val[0], minmin = val[0], maxmin;
int zonecolor = 0;
for (int i = 0; i < nnz; i = i + 1)
{
if (maxmax < val[i])
{
maxmax = val[i];
}
if (minmin > val[i])
{
minmin = val[i];
}
}
maxmin = (maxmax - minmin);
if (PodoublesorSquares == 0)
{
//方块
for (int i = 0; i < nnz; i = i + 1)
{
Element_top = Frame_top + (row_ind[i] * zonelength);
Element_bottom = Frame_top + ((row_ind[i] + 1) * zonelength);
Element_left = Frame_left + (col_ind[i] * zonelength);
Element_right = Frame_left + ((col_ind[i] + 1) * zonelength);
zonecolor = floor(10 * ((val[i] - minmin) / maxmin));
setfillcolor(Fill_C[zonecolor]);
fillrectangle(Element_left, Element_top, Element_right, Element_bottom);
//solidrectangle(Element_left, Element_top, Element_right, Element_bottom);
}
cout << "zonelength " << zonelength << endl;
cout << "N " << N << endl;
cout << " Frame_right - Frame_left " << Frame_right - Frame_left << endl;
}
else if (PodoublesorSquares != 0)
{
//点
for (int i = 0; i < nnz; i = i + 1)
{
zonecolor = floor(10 * ((val[i] - minmin) / maxmin));
putpixel(Frame_left + col_ind[i] * zonelength, Frame_top + row_ind[i] * zonelength, Fill_C[zonecolor]);
}
}
LPCTSTR Address_LPCTSTR = (LPCTSTR)"\\test.bmp";
saveimage(Address_LPCTSTR);
getchar(); // 按任意键继续
closegraph(); // 关闭图形界面
return 0;
}
double MatrixPrdouble(ublas::matrix<double> K, int N, double nnz, double *row_ind, double *col_prt, double *val)
{
//申请内存
int k = 0, h = 1;
double *col_ind_M = (double *)malloc(sizeof(double)*nnz);
//获得CSC数组
for (int j = 0; j < N; j = j + 1)
{
for (int i = 0; i < N; i = i + 1)
{
if (K(i, j) != 0)
{
val[k] = K(i, j);
row_ind[k] = i;
col_ind_M[k] = j;
k = k + 1;
}
}
}
//获得列指针
col_prt[0] = 0;
for (int i = 0; i < k; i = i + 1)
{
if (col_ind_M[i] != col_ind_M[i + 1])
{
col_prt[h] = i + 1;
h = h + 1;
}
}
col_prt[N] = nnz - 1;
//for (int i = 0; i < k; i = i + 1)
//{
//cout << "row_ind " << row_ind[i] << endl;
//}
//for (int i = 0; i < k; i = i + 1)
//{
//cout << "val " << val[i] << endl;
//}
//for (int i = 0; i < N + 1; i = i + 1)
//{
//cout << "col_prt " << col_prt[i] << endl;
//}
return 0;
}